点击上方"蓝字"

关注我们,享更多干货!

1

MySQL Enterprise Backup介绍

MySQL Enterprise Backup 8.0.26是MySQL 8.0.26的一个备份工具。它是一个多平台、高性能的工具,提供了丰富的功能,如热(在线)备份、增量和差异备份、选择性备份和恢复、支持直接云存储备份、备份加密和压缩,以及许多其他有价值的功能。

虽然优化使用InnoDB表,MySQL企业备份能够备份和恢复由MySQL支持的任何类型的存储引擎创建的所有类型的表。读和写进程的并行性(在独立的多线程中执行)及其块级并行性(不同的线程可以在单个文件中读取、处理或写入不同的块)允许备份和恢复进程以极高的速度完成,与使用mysqldump等工具进行逻辑备份相比,通常可以获得显著的性能提升。

2

备份整库与恢复

1.全备份数据库

[root@localhost bin]# ./mysqlbackup --user=test --password=test  --socket=/tmp/mysql_sandbox8026.sock --backup-image=/data/mbackup/my_full.mbi  --backup-dir=/data/mbackup backup-to-image --show-progress
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--user=test
--password=xxxx
--socket=/tmp/mysql_sandbox8026.sock
--backup-image=/data/mbackup/my_full.mbi
--backup-dir=/data/mbackup
backup-to-image
--show-progressIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'backup-to-image' run mysqlbackupprints "mysqlbackup completed OK!".210906 17:51:20 MAIN     INFO: Establishing connection to server.
210906 17:51:20 MAIN     INFO: No SSL options specified.
210906 17:51:20 MAIN     INFO: MySQL server version is '8.0.26'
210906 17:51:20 MAIN     INFO: MySQL server compile os version is 'Linux'
210906 17:51:20 MAIN     INFO: Got some server configuration information from running server.210906 17:51:20 MAIN     INFO: Establishing connection to server for locking.
210906 17:51:20 MAIN     INFO: No SSL options specified.
210906 17:51:20 MAIN     INFO: Backup directory exists: '/data/mbackup'
210906 17:51:20 MAIN     INFO: MySQL server version_comment is 'MySQL Community Server - GPL'
210906 17:51:20 MAIN     INFO: Mysqlbackup component not installed.
210906 17:51:20 MAIN     INFO: MEB logfile created at /data/mbackup/meta/MEB_2021-09-06.17-51-20_backup-to-image.log210906 17:51:20 MAIN     INFO: The MySQL server has no active keyring.
--------------------------------------------------------------------Server Repository Options:
--------------------------------------------------------------------datadir                        = /root/sandboxes/msb_8_0_26/data/innodb_data_home_dir           = innodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /root/sandboxes/msb_8_0_26/data/innodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /root/sandboxes/msb_8_0_26/data/innodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32--------------------------------------------------------------------Backup Config Options:
--------------------------------------------------------------------datadir                        = /data/mbackup/datadirinnodb_data_home_dir           = /data/mbackup/datadirinnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /data/mbackup/datadirinnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /data/mbackup/datadirinnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32Backup Image Path = /data/mbackup/my_full.mbi
210906 17:51:20 MAIN     INFO: Unique generated backup id for this is 16309218803692985210906 17:51:20 MAIN     INFO: Copying the server config file '/root/sandboxes/msb_8_0_26/data/auto.cnf'
210906 17:51:20 MAIN     INFO: Creating 14 buffers each of size 16777216.
210906 17:51:20 MAIN     INFO: The server is not configured for redo log archiving. The system variable innodb_redo_log_archive_dirs is not set.
210906 17:51:20 MAIN     INFO: Found checkpoint at lsn 18223719.
210906 17:51:20 MAIN     INFO: Starting log scan from lsn = 18223616 at offset = 18217472 and checkpoint = 18223719 in file /root/sandboxes/msb_8_0_26/data/ib_logfile0.
210906 17:51:20 MAIN     INFO: Full Image Backup operation starts with following threads1 read-threads    6 process-threads    1 write-threads
210906 17:51:20 RPR1     INFO: Progress: 0 of 44 MB; state: Copying metadata
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/backup-my.cnf.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_create.xml.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/datadir/backup-auto.cnf.
210906 17:51:20 RLP1     INFO: Starting to parse redo log at lsn = 18223701, whereas checkpoint_lsn = 18223719 and start_lsn = 18223616.
210906 17:51:20 RDR1     INFO: Starting to copy all innodb files...
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/ibdata1.
210906 17:51:20 RDR1     INFO: Starting to copy all undo files...
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_002.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_001.
210906 17:51:20 RDR1     INFO: Starting to lock instance for backup...
210906 17:51:20 RDR1     INFO: The server instance is locked for backup.
210906 17:51:20 RDR1     INFO: The server instance is unlocked after 0.001 seconds.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/sys/sys_config.ibd.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/test/test.ibd.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql/backup_progress.ibd.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql.ibd.
210906 17:51:20 RDR1     INFO: Completing the copy of innodb files.
210906 17:51:20 RDR1     INFO: Requesting a dump of the InnoDB buffer pool
210906 17:51:20 RDR1     INFO: Waiting for the dump of the InnoDB buffer pool to complete
210906 17:51:20 RDR1     INFO: The dump of the InnoDB buffer pool completed
210906 17:51:20 RDR1     INFO: Binary Log Basename: '/root/sandboxes/msb_8_0_26/data/binlog'
210906 17:51:20 RDR1     INFO: Binary Log Index:    '/root/sandboxes/msb_8_0_26/data/binlog.index'
210906 17:51:20 RDR1     INFO: Relay Channel:      'group_replication_applier'
210906 17:51:20 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_applier'
210906 17:51:20 RDR1     INFO: Relay Channel:      'group_replication_recovery'
210906 17:51:20 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_recovery'
210906 17:51:20 RDR1     INFO: Starting to copy Binlog files.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000001.
210906 17:51:20 RDR1     INFO: Starting to lock instance for backup...
210906 17:51:20 RDR1     INFO: The server instance is locked for backup.
210906 17:51:20 RDR1     INFO: The MySQL server has no active keyring.
210906 17:51:20 RDR1     INFO: Requesting flush of redo log reading after LSN 18292873.
210906 17:51:20 RDR1     INFO: Requesting flush of redo log processing after LSN 18292873.
210906 17:51:20 RDR1     INFO: Completed flush of redo log reading after LSN 18292873.
210906 17:51:20 RDR1     INFO: Waiting to process redo log LSN 18292873, have 18292435.
210906 17:51:20 RDR1     INFO: Completed flush of redo log processing after LSN 18292873.
210906 17:51:20 RDR1     INFO: Starting to read-lock tables...
210906 17:51:20 RDR1     INFO: No tables to read-lock.
210906 17:51:20 RDR1     INFO: Opening backup source directory '/root/sandboxes/msb_8_0_26/data'
210906 17:51:20 RDR1     INFO: Starting to copy non-innodb files in subdirs of '/root/sandboxes/msb_8_0_26/data'
210906 17:51:20 WTR1     INFO: Adding database directory: datadir/mysql
210906 17:51:20 WTR1     INFO: Adding database directory: datadir/performance_schema
210906 17:51:20 RDR1     INFO: Completing the copy of all non-innodb files.
210906 17:51:20 WTR1     INFO: Adding database directory: datadir/sys
210906 17:51:20 WTR1     INFO: Adding database directory: datadir/test
210906 17:51:20 RDR1     INFO: Requesting consistency information...
210906 17:51:20 RDR1     INFO: Locked the consistency point for 1762 microseconds.
210906 17:51:20 RDR1     INFO: Consistency point server_uuid '00008026-0000-0000-0000-000000008026'.
210906 17:51:20 RDR1     INFO: Consistency point gtid_executed ''.
210906 17:51:20 RDR1     INFO: Consistency point binary_log_file 'binlog.000002'.
210906 17:51:20 RDR1     INFO: Consistency point binary_log_position 1365.
210906 17:51:20 RDR1     INFO: Consistency point InnoDB lsn 18293311.
210906 17:51:20 RDR1     INFO: Consistency point InnoDB lsn_checkpoint 18223719.
210906 17:51:20 RDR1     INFO: Requesting completion of redo log copy after LSN 18293311.
210906 17:51:20 RLW1     INFO: A copied database page was modified at 18223719. (This is the highest lsn found on a page)
210906 17:51:20 RLW1     INFO: Scanned log up to lsn 18293311.
210906 17:51:20 RLW1     INFO: Was able to parse the log up to lsn 18293311.
210906 17:51:20 RLW1     INFO: Copied redo loglog_start_lsn    18223616start_checkpoint 18223719start_lsn        18223719last_checkpoint  18223719consistency_lsn  18293311log_end_lsn      18293311
210906 17:51:20 RLR1     INFO: Redo log reader waited 32 times for a total of 160.00 ms for logs to generate.
210906 17:51:20 RDR1     INFO: Truncating binary log index '/data/mbackup/datadir/binlog.index' to 32.
210906 17:51:20 RDR1     INFO: Truncating binary log 'binlog.000002' to 1365.
210906 17:51:20 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000002.
210906 17:51:20 RDR1     INFO: Completed the copy of binlog files...
210906 17:51:20 RDR1     INFO: The server instance is unlocked after 0.053 seconds.
210906 17:51:20 RDR1     INFO: Reading all global variables from the server.
210906 17:51:20 RDR1     INFO: Completed reading of all 615 global variables from the server.
210906 17:51:20 RDR1     INFO: Writing server defaults files 'server-my.cnf' and 'server-all.cnf' for server '8.0.26' in '/data/mbackup'.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_variables.txt.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/datadir/ibbackup_logfile.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/server-all.cnf.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/server-my.cnf.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_content.xml.
210906 17:51:20 RDR1     INFO: Copying meta file /data/mbackup/meta/image_files.xml.
210906 17:51:20 MAIN     INFO: Progress: 70 of 70 MB; state: Completed
210906 17:51:20 MAIN     INFO: Full Image Backup operation completed successfully.
210906 17:51:20 MAIN     INFO: Backup image created successfully.
210906 17:51:20 MAIN     INFO: Image Path = /data/mbackup/my_full.mbi
210906 17:51:20 MAIN     INFO: MySQL binlog position: filename binlog.000002, position 1365-------------------------------------------------------------Parameters Summary
-------------------------------------------------------------Start LSN                  : 18223616Last Checkpoint LSN        : 18223719End LSN                    : 18293311
-------------------------------------------------------------mysqlbackup completed OK

2.验证备份有效性

[root@localhost bin]# ./mysqlbackup --backup-image=/data/mbackup/my_full.mbi  validate
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--backup-image=/data/mbackup/my_full.mbi
validateIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'validate' run mysqlbackupprints "mysqlbackup completed OK!".210907 09:05:50 MAIN     INFO: Backup Image MEB version string: 8.0.26
210907 09:05:50 MAIN     INFO: MySQL server version is '8.0.26'
210907 09:05:50 MAIN     INFO: The backup image has no keyring.
210907 09:05:50 MAIN     INFO: Creating 14 buffers each of size 16777216.
210907 09:05:50 MAIN     INFO: Validate operation starts with following threads1 read-threads    6 process-threads
210907 09:05:50 MAIN     INFO: Validating image ... /data/mbackup/my_full.mbi
210907 09:05:50 PCR1     INFO: Validate: [Dir]: meta
210907 09:05:51 PCR1     INFO: Validate: [Dir]: datadir/mysql
210907 09:05:51 PCR3     INFO: Validate: [Dir]: datadir/performance_schema
210907 09:05:51 PCR4     INFO: Validate: [Dir]: datadir/sys
210907 09:05:51 PCR4     INFO: Validate: [Dir]: datadir/test
210907 09:05:51 MAIN     INFO: datadir/mysql.ibd validated.
210907 09:05:51 MAIN     INFO: datadir/mysql/backup_progress.ibd validated.
210907 09:05:51 MAIN     INFO: datadir/ibdata1 validated.
210907 09:05:51 MAIN     INFO: datadir/undo_002 validated.
210907 09:05:51 MAIN     INFO: datadir/undo_001 validated.
210907 09:05:51 MAIN     INFO: datadir/sys/sys_config.ibd validated.
210907 09:05:51 MAIN     INFO: datadir/test/test.ibd validated.
210907 09:05:51 MAIN     INFO: Validate operation completed successfully.
210907 09:05:51 MAIN     INFO: Backup Image validation successful.
210907 09:05:51 MAIN     INFO: Source Image Path = /data/mbackup/my_full.mbimysqlbackup completed OK!

3.恢复全备份数据库

恢复前关闭MySQL,并清空MySQL数据目录,这一步和Xtrabackup一样。

[root@localhost bin]# ./mysqlbackup  --datadir=/root/sandboxes/msb_8_0_26/data  --backup-image=/data/mbackup/my_full.mbi  --backup-dir=/data/mbackup/tmp  copy-back-and-apply-log
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--datadir=/root/sandboxes/msb_8_0_26/data
--backup-image=/data/mbackup/my_full.mbi
--backup-dir=/data/mbackup/tmp
copy-back-and-apply-logIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'copy-back-and-apply-log' run mysqlbackupprints "mysqlbackup completed OK!".210907 09:14:42 MAIN     INFO: Backup Image MEB version string: 8.0.26
210907 09:14:42 MAIN     INFO: MySQL server version is '8.0.26'
210907 09:14:42 MAIN     INFO: Backup directory exists: '/data/mbackup/tmp'
210907 09:14:42 MAIN  WARNING: If you restore to a server of a different version, the innodb_data_file_path parameter might have a different default. In that case you need to add 'innodb_data_file_path=ibdata1:12M:autoextend' to the target server configuration.
210907 09:14:42 MAIN  WARNING: If you restore to a server of a different version, the innodb_log_files_in_group parameter might have a different default. In that case you need to add 'innodb_log_files_in_group=2' to the target server configuration.
210907 09:14:42 MAIN  WARNING: If you restore to a server of a different version, the innodb_log_file_size parameter might have a different default. In that case you need to add 'innodb_log_file_size=50331648' to the target server configuration.
210907 09:14:42 MAIN     INFO: MEB logfile created at /data/mbackup/tmp/meta/MEB_2021-09-07.09-14-42_copy-back-and-apply-log.log210907 09:14:42 MAIN     INFO: The backup image has no keyring.
--------------------------------------------------------------------Server Repository Options:
--------------------------------------------------------------------datadir                        = /root/sandboxes/msb_8_0_26/datainnodb_data_home_dir           = /root/sandboxes/msb_8_0_26/datainnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /root/sandboxes/msb_8_0_26/datainnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /root/sandboxes/msb_8_0_26/datainnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = Nullinnodb_checksum_algorithm      = crc32--------------------------------------------------------------------Backup Config Options:
--------------------------------------------------------------------datadir                        = /data/mbackup/tmp/datadirinnodb_data_home_dir           = /data/mbackup/tmp/datadirinnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /data/mbackup/tmp/datadirinnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /data/mbackup/tmp/datadirinnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32210907 09:14:42 MAIN     INFO: Creating 14 buffers each of size 16777216.
210907 09:14:42 MAIN     INFO: Copy-back-and-apply-log from image operation starts with following threads1 read-threads    6 process-threads    1 write-threads
210907 09:14:42 PCR1     INFO: Copying database directory: meta
210907 09:14:42 RDR1     INFO: Copying ibdata1.
210907 09:14:42 RDR1     INFO: Copying undo_002.
210907 09:14:42 RDR1     INFO: Copying undo_001.
210907 09:14:42 RDR1     INFO: Copying sys/sys_config.ibd.
210907 09:14:42 RDR1     INFO: Copying test/test.ibd.
210907 09:14:42 RDR1     INFO: Copying mysql/backup_progress.ibd.
210907 09:14:42 RDR1     INFO: Copying mysql.ibd.
210907 09:14:42 RDR1     INFO: Copying binlog.000001.
210907 09:14:42 PCR3     INFO: Copying database directory: mysql
210907 09:14:42 PCR6     INFO: Copying database directory: performance_schema
210907 09:14:42 RDR1     INFO: Binary Log Basename: 'binlog'
210907 09:14:42 PCR5     INFO: Copying database directory: sys
210907 09:14:42 RDR1     INFO: Binlog Log Index:    '/root/sandboxes/msb_8_0_26/data/binlog.index'
210907 09:14:42 PCR1     INFO: Copying database directory: test
210907 09:14:42 RDR1     INFO: Copying binlog.000002.
210907 09:14:42 MAIN     INFO: read_backup_variables_txt_file: '/data/mbackup/tmp/meta/backup_variables.txt'
210907 09:14:42 MAIN     INFO: backup variable mysql_version=8.0.26
210907 09:14:42 MAIN     INFO: MySQL server version is '8.0.26'
210907 09:14:42 MAIN     INFO: Restoring ...8.0.26 version
210907 09:14:42 MAIN     INFO: backup variable meb_version=8.0.26
210907 09:14:42 MAIN     INFO: backup variable start_lsn=18223616
210907 09:14:42 MAIN     INFO: backup variable last_checkpoint=18223719
210907 09:14:42 MAIN     INFO: backup variable end_lsn=18293311
210907 09:14:42 MAIN     INFO: backup variable apply_log_done=0
210907 09:14:42 MAIN     INFO: backup variable is_incremental=0
210907 09:14:42 MAIN     INFO: backup variable is_incremental_with_redo_log_only=0
210907 09:14:42 MAIN     INFO: backup variable is_partial=0
210907 09:14:42 MAIN     INFO: backup variable is_compressed=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_binlog=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_relaylog=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_unused_pages=0
210907 09:14:42 MAIN     INFO: backup variable is_onlyinnodb=0
210907 09:14:42 MAIN     INFO: backup variable binlog_position=binlog.000002:1365
210907 09:14:42 MAIN     INFO: backup variable binlog_index=binlog.index
210907 09:14:42 MAIN     INFO: backup variable has_tde_tables=0
210907 09:14:42 MAIN     INFO: backup variable start_time_utc=1630921880359728
210907 09:14:42 MAIN     INFO: backup variable end_time_utc=1630921880669709
210907 09:14:42 MAIN     INFO: backup variable consistency_time_utc=1630921880658335
210907 09:14:42 MAIN     INFO: backup variable mysql_version_comment=MySQL Community Server - GPL
210907 09:14:42 MAIN     INFO: backup variable log_bin_name=binlog
210907 09:14:42 MAIN     INFO: backup variable log_bin_index_name=binlog
210907 09:14:42 MAIN     INFO: backup variable innodb_undo_files_count=2
210907 09:14:42 MAIN     INFO: Copy-back operation completed successfully.
210907 09:14:42 MAIN     INFO: Source Image Path = /data/mbackup/my_full.mbi210907 09:14:42 MAIN     INFO: read_backup_variables_txt_file: '/data/mbackup/tmp/meta/backup_variables.txt'
210907 09:14:42 MAIN     INFO: backup variable mysql_version=8.0.26
210907 09:14:42 MAIN     INFO: MySQL server version is '8.0.26'
210907 09:14:42 MAIN     INFO: Restoring ...8.0.26 version
210907 09:14:42 MAIN     INFO: backup variable meb_version=8.0.26
210907 09:14:42 MAIN     INFO: backup variable start_lsn=18223616
210907 09:14:42 MAIN     INFO: backup variable last_checkpoint=18223719
210907 09:14:42 MAIN     INFO: backup variable end_lsn=18293311
210907 09:14:42 MAIN     INFO: backup variable apply_log_done=0
210907 09:14:42 MAIN     INFO: backup variable is_incremental=0
210907 09:14:42 MAIN     INFO: backup variable is_incremental_with_redo_log_only=0
210907 09:14:42 MAIN     INFO: backup variable is_partial=0
210907 09:14:42 MAIN     INFO: backup variable is_compressed=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_binlog=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_relaylog=0
210907 09:14:42 MAIN     INFO: backup variable is_skip_unused_pages=0
210907 09:14:42 MAIN     INFO: backup variable is_onlyinnodb=0
210907 09:14:42 MAIN     INFO: backup variable binlog_position=binlog.000002:1365
210907 09:14:42 MAIN     INFO: backup variable binlog_index=binlog.index
210907 09:14:42 MAIN     INFO: backup variable has_tde_tables=0
210907 09:14:42 MAIN     INFO: backup variable start_time_utc=1630921880359728
210907 09:14:42 MAIN     INFO: backup variable end_time_utc=1630921880669709
210907 09:14:42 MAIN     INFO: backup variable consistency_time_utc=1630921880658335
210907 09:14:42 MAIN     INFO: backup variable mysql_version_comment=MySQL Community Server - GPL
210907 09:14:42 MAIN     INFO: backup variable log_bin_name=binlog
210907 09:14:42 MAIN     INFO: backup variable log_bin_index_name=binlog
210907 09:14:42 MAIN     INFO: backup variable innodb_undo_files_count=2
210907 09:14:42 MAIN     INFO: Creating 14 buffers each of size 65536.
210907 09:14:42 MAIN     INFO: Apply-log operation starts with following threads1 read-threads    1 process-threads    6 apply-threads
210907 09:14:42 MAIN     INFO: Using up to 100 MB of memory.
210907 09:14:42 MAIN     INFO: ibbackup_logfile's creation parameters:start lsn 18223616, end lsn 18293311,start checkpoint 18223719.
210907 09:14:42 MAIN     INFO: Loading the space id : 0, space name : /root/sandboxes/msb_8_0_26/data/ibdata1.
210907 09:14:42 MAIN     INFO: Loading the space id 3 name '/root/sandboxes/msb_8_0_26/data/mysql/backup_progress.ibd'.
210907 09:14:42 MAIN     INFO: Loading the space id 1 name '/root/sandboxes/msb_8_0_26/data/sys/sys_config.ibd'.
210907 09:14:42 MAIN     INFO: Loading the space id 2 name '/root/sandboxes/msb_8_0_26/data/test/test.ibd'.
210907 09:14:42 MAIN     INFO: Loading the space id 4294967294 name '/root/sandboxes/msb_8_0_26/data/mysql.ibd'.
210907 09:14:42 MAIN     INFO: Loading the space id 4294967279 name '/root/sandboxes/msb_8_0_26/data/undo_001'.
210907 09:14:42 MAIN     INFO: Loading the space id 4294967278 name '/root/sandboxes/msb_8_0_26/data/undo_002'.
210907 09:14:42 PCR1     INFO: Starting to parse redo log at lsn = 18223701, whereas checkpoint_lsn = 18223719 and start_lsn = 18223616.
210907 09:14:42 PCR1     INFO: Doing recovery: scanned up to log sequence number 18293311.
210907 09:14:42 PCR1     INFO: Starting to apply a batch of log records to the database....
InnoDB: Progress in percent: 1 2 4 5 7
210907 09:14:42 PCR1     INFO: Create redo log files. target start_lsn 0 last_checkpoint 0 end_lsn 0
210907 09:14:42 PCR1     INFO: Create redo log files. source start_lsn 18223616 last_checkpoint 18223719 end_lsn 18293311
210907 09:14:42 PCR1     INFO: Updating last checkpoint to 18223719 in redo log/
210907 09:14:42 PCR1     INFO: Setting 'ib_logfile0' file size to 50331648
210907 09:14:42 PCR1     INFO: Setting 'ib_logfile1' file size to 50331648
210907 09:14:42 PCR1     INFO: Log file header:format = 4 pad1 = 0 start lsn = 18223616 checkpoint lsn = 18223719 checksum = 601549513creator = MEB 8.0.26
210907 09:14:42 PCR1     INFO: We were able to parse ibbackup_logfile up to lsn 18293311.
210907 09:14:42 PCR1     INFO: Last MySQL binlog file position 0 1365, file name binlog.000002
210907 09:14:42 PCR1     INFO: The first data file is '/root/sandboxes/msb_8_0_26/data/ibdata1'and the new created log files are at '/root/sandboxes/msb_8_0_26/data'
210907 09:14:42 MAIN     INFO: Apply-log operation completed successfully.
210907 09:14:42 MAIN     INFO: Full Backup has been restored successfully.mysqlbackup completed OK! with 3 warnings

4.修改对应的权限后,启动MySQL数据库。

3

流式备份到远程服务器

[root@localhost bin]# ./mysqlbackup  --defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf --backup-image=- --backup-dir=/data/mbackup/ backup-to-image | ssh root@192.168.17.128 'cat > /data/mysqlback_meb/full_back.img'
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf
--backup-image=-
--backup-dir=/data/mbackup/
backup-to-imageIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'backup-to-image' run mysqlbackupprints "mysqlbackup completed OK!".210907 09:56:53 MAIN     INFO: Establishing connection to server.
210907 09:56:53 MAIN     INFO: No SSL options specified.
210907 09:56:53 MAIN     INFO: MySQL server version is '8.0.26'
210907 09:56:53 MAIN     INFO: MySQL server compile os version is 'Linux'
210907 09:56:53 MAIN     INFO: Got some server configuration information from running server.210907 09:56:53 MAIN     INFO: Establishing connection to server for locking.
210907 09:56:53 MAIN     INFO: No SSL options specified.
210907 09:56:53 MAIN     INFO: Backup directory exists: '/data/mbackup/'
210907 09:56:53 MAIN     INFO: MySQL server version_comment is 'MySQL Community Server - GPL'
210907 09:56:53 MAIN     INFO: Mysqlbackup component not installed.
210907 09:56:53 MAIN     INFO: MEB logfile created at /data/mbackup/meta/MEB_2021-09-07.09-56-53_backup-to-image.log210907 09:56:53 MAIN     INFO: The MySQL server has no active keyring.
--------------------------------------------------------------------Server Repository Options:
--------------------------------------------------------------------datadir                        = /root/sandboxes/msb_8_0_26/data/innodb_data_home_dir           = innodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /root/sandboxes/msb_8_0_26/data/innodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /root/sandboxes/msb_8_0_26/data/innodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32--------------------------------------------------------------------Backup Config Options:
--------------------------------------------------------------------datadir                        = /data/mbackup/datadirinnodb_data_home_dir           = /data/mbackup/datadirinnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /data/mbackup/datadirinnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /data/mbackup/datadirinnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32210907 09:56:53 MAIN     INFO: Backup Image Path = 'stdout'
210907 09:56:53 MAIN     INFO: Unique generated backup id for this is 16309798139744045210907 09:56:53 MAIN     INFO: Copying the server config file '/root/sandboxes/msb_8_0_26/data/auto.cnf'
210907 09:56:53 MAIN     INFO: Creating 14 buffers each of size 16777216.
210907 09:56:54 MAIN     INFO: The server is not configured for redo log archiving. The system variable innodb_redo_log_archive_dirs is not set.
210907 09:56:54 MAIN     INFO: Found checkpoint at lsn 18516859.
210907 09:56:54 MAIN     INFO: Starting log scan from lsn = 18516480 at offset = 294912 and checkpoint = 18516859 in file /root/sandboxes/msb_8_0_26/data/ib_logfile0.
210907 09:56:54 MAIN     INFO: Full Image Backup operation starts with following threads1 read-threads    6 process-threads    1 write-threads
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/backup-my.cnf.
210907 09:56:54 RLP1     INFO: Starting to parse redo log at lsn = 18516550, whereas checkpoint_lsn = 18516859 and start_lsn = 18516480.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_create.xml.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/datadir/backup-auto.cnf.
210907 09:56:54 RDR1     INFO: Starting to copy all innodb files...
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/ibdata1.
210907 09:56:54 RDR1     INFO: Starting to copy all undo files...
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_002.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_001.
210907 09:56:54 RDR1     INFO: Starting to lock instance for backup...
210907 09:56:54 RDR1     INFO: The server instance is locked for backup.
210907 09:56:54 RDR1     INFO: The server instance is unlocked after 0.001 seconds.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/sys/sys_config.ibd.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/test/test.ibd.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql/backup_progress.ibd.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql/backup_history.ibd.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql.ibd.
210907 09:56:54 RDR1     INFO: Completing the copy of innodb files.
210907 09:56:54 RDR1     INFO: Requesting a dump of the InnoDB buffer pool
210907 09:56:54 RDR1     INFO: Waiting for the dump of the InnoDB buffer pool to complete
210907 09:56:54 RDR1     INFO: The dump of the InnoDB buffer pool completed
210907 09:56:54 RDR1     INFO: Binary Log Basename: '/root/sandboxes/msb_8_0_26/data/binlog'
210907 09:56:54 RDR1     INFO: Binary Log Index:    '/root/sandboxes/msb_8_0_26/data/binlog.index'
210907 09:56:54 RDR1     INFO: Relay Channel:      'group_replication_applier'
210907 09:56:54 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_applier'
210907 09:56:54 RDR1     INFO: Relay Channel:      'group_replication_recovery'
210907 09:56:54 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_recovery'
210907 09:56:54 RDR1     INFO: Starting to copy Binlog files.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000001.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000002.
210907 09:56:54 RDR1     INFO: Starting to lock instance for backup...
210907 09:56:54 RDR1     INFO: The server instance is locked for backup.
210907 09:56:54 RDR1     INFO: The MySQL server has no active keyring.
210907 09:56:54 RDR1     INFO: Requesting flush of redo log reading after LSN 18522383.
210907 09:56:54 RDR1     INFO: Requesting flush of redo log processing after LSN 18522383.
210907 09:56:54 RDR1     INFO: Waiting to read redo log LSN 18522383, have 18521991.
210907 09:56:54 RDR1     INFO: Completed flush of redo log reading after LSN 18522393.
210907 09:56:54 RDR1     INFO: Completed flush of redo log processing after LSN 18522393.
210907 09:56:54 RDR1     INFO: Starting to read-lock tables...
210907 09:56:54 RDR1     INFO: No tables to read-lock.
210907 09:56:54 RDR1     INFO: Opening backup source directory '/root/sandboxes/msb_8_0_26/data'
210907 09:56:54 RDR1     INFO: Starting to copy non-innodb files in subdirs of '/root/sandboxes/msb_8_0_26/data'
210907 09:56:54 WTR1     INFO: Adding database directory: datadir/mysql
210907 09:56:54 WTR1     INFO: Adding database directory: datadir/performance_schema
210907 09:56:54 RDR1     INFO: Completing the copy of all non-innodb files.
210907 09:56:54 WTR1     INFO: Adding database directory: datadir/sys
210907 09:56:54 WTR1     INFO: Adding database directory: datadir/test
210907 09:56:54 RDR1     INFO: Requesting consistency information...
210907 09:56:54 RDR1     INFO: Locked the consistency point for 5289 microseconds.
210907 09:56:54 RDR1     INFO: Consistency point server_uuid '2891d993-0f79-11ec-ad13-0050563345b0'.
210907 09:56:54 RDR1     INFO: Consistency point gtid_executed ''.
210907 09:56:54 RDR1     INFO: Consistency point binary_log_file 'binlog.000003'.
210907 09:56:54 RDR1     INFO: Consistency point binary_log_position 156.
210907 09:56:54 RDR1     INFO: Consistency point InnoDB lsn 18522786.
210907 09:56:54 RDR1     INFO: Consistency point InnoDB lsn_checkpoint 18517232.
210907 09:56:54 RDR1     INFO: Requesting completion of redo log copy after LSN 18522786.
210907 09:56:54 RLR1     INFO: Redo log reader waited 122 times for a total of 610.00 ms for logs to generate.
210907 09:56:54 RLW1     INFO: A copied database page was modified at 18517214. (This is the highest lsn found on a page)
210907 09:56:54 RLW1     INFO: Scanned log up to lsn 18522786.
210907 09:56:54 RLW1     INFO: Was able to parse the log up to lsn 18522786.
210907 09:56:54 RLW1     INFO: Copied redo loglog_start_lsn    18516480start_checkpoint 18516859start_lsn        18516859last_checkpoint  18517232consistency_lsn  18522786log_end_lsn      18522786
210907 09:56:54 RDR1     INFO: Truncating binary log index '/data/mbackup/datadir/binlog.index' to 48.
210907 09:56:54 RDR1     INFO: Truncating binary log 'binlog.000003' to 156.
210907 09:56:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000003.
210907 09:56:54 RDR1     INFO: Completed the copy of binlog files...
210907 09:56:54 RDR1     INFO: The server instance is unlocked after 0.033 seconds.
210907 09:56:54 RDR1     INFO: Reading all global variables from the server.
210907 09:56:54 RDR1     INFO: Completed reading of all 615 global variables from the server.
210907 09:56:54 RDR1     INFO: Writing server defaults files 'server-my.cnf' and 'server-all.cnf' for server '8.0.26' in '/data/mbackup/'.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_variables.txt.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/datadir/ibbackup_logfile.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/server-all.cnf.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/server-my.cnf.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/meta/backup_content.xml.
210907 09:56:54 RDR1     INFO: Copying meta file /data/mbackup/meta/image_files.xml.
210907 09:56:54 MAIN     INFO: Full Image Backup operation completed successfully.
210907 09:56:54 MAIN     INFO: Backup image created successfully.
210907 09:56:54 MAIN     INFO: Image Path = 'stdout'
210907 09:56:54 MAIN     INFO: MySQL binlog position: filename binlog.000003, position 156-------------------------------------------------------------Parameters Summary
-------------------------------------------------------------Start LSN                  : 18516480Last Checkpoint LSN        : 18517232End LSN                    : 18522786
-------------------------------------------------------------mysqlbackup completed OK!

4

增量备份

[root@localhost bin]# ./mysqlbackup --defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf \
>  --incremental --incremental-base=history:last_backup \
>  --backup-dir=/data/inc_meb_01 \
>  --backup-image=incremental_image1.bi \
>  backup-to-image
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf
--incremental
--incremental-base=history:last_backup
--backup-dir=/data/inc_meb_01
--backup-image=incremental_image1.bi
backup-to-imageIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'backup-to-image' run mysqlbackupprints "mysqlbackup completed OK!".210907 10:39:54 MAIN     INFO: Establishing connection to server.
210907 10:39:54 MAIN     INFO: No SSL options specified.
210907 10:39:54 MAIN     INFO: MySQL server version is '8.0.26'
210907 10:39:54 MAIN     INFO: MySQL server compile os version is 'Linux'
210907 10:39:54 MAIN     INFO: Got some server configuration information from running server.210907 10:39:54 MAIN     INFO: Establishing connection to server for locking.
210907 10:39:54 MAIN     INFO: No SSL options specified.
210907 10:39:54 MAIN     INFO: Backup directory exists: '/data/inc_meb_01'
210907 10:39:54 MAIN     INFO: MySQL server version_comment is 'MySQL Community Server - GPL'
210907 10:39:54 MAIN     INFO: Mysqlbackup component not installed.
210907 10:39:54 MAIN     INFO: No SSL options specified.
210907 10:39:54 MAIN     INFO: Location of last successful backup: /data/mbackup/.
210907 10:39:54 MAIN     INFO: End time of last successful backup: 2021-09-07 09:56:54.
210907 10:39:54 MAIN     INFO: Last backup type: FULL.
210907 10:39:54 MAIN     INFO: Using start_lsn=18522786, calculated from backup_history table of MySQL server.
210907 10:39:54 MAIN     INFO: Using "full-scan" algorithm for this incremental backup.
210907 10:39:54 MAIN     INFO: MEB logfile created at /data/inc_meb_01/meta/MEB_2021-09-07.10-39-54_backup-to-image.log210907 10:39:54 MAIN     INFO: The MySQL server has no active keyring.
--------------------------------------------------------------------Server Repository Options:
--------------------------------------------------------------------datadir                        = /root/sandboxes/msb_8_0_26/data/innodb_data_home_dir           = innodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /root/sandboxes/msb_8_0_26/data/innodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /root/sandboxes/msb_8_0_26/data/innodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32--------------------------------------------------------------------Backup Config Options:
--------------------------------------------------------------------datadir                        = /data/inc_meb_01/datadirinnodb_data_home_dir           = /data/inc_meb_01/datadirinnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /data/inc_meb_01/datadirinnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /data/inc_meb_01/datadirinnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32Backup Image Path = /data/inc_meb_01/incremental_image1.bi
210907 10:39:54 MAIN     INFO: Unique generated backup id for this is 16309823944083403210907 10:39:54 MAIN     INFO: Copying the server config file '/root/sandboxes/msb_8_0_26/data/auto.cnf'
210907 10:39:54 MAIN     INFO: Creating 15 buffers each of size 17301504.
210907 10:39:54 MAIN     INFO: The server is not configured for redo log archiving. The system variable innodb_redo_log_archive_dirs is not set.
210907 10:39:54 MAIN     INFO: Found checkpoint at lsn 18529828.
210907 10:39:54 MAIN     INFO: Starting log scan from lsn = 18529792 at offset = 308224 and checkpoint = 18529828 in file /root/sandboxes/msb_8_0_26/data/ib_logfile0.
210907 10:39:54 MAIN     INFO: Incremental Image Backup operation starts with following threads1 read-threads    6 process-threads    1 write-threads
210907 10:39:54 RDR1     INFO: Copying meta file /data/inc_meb_01/backup-my.cnf.
210907 10:39:54 RDR1     INFO: Copying meta file /data/inc_meb_01/meta/backup_create.xml.
210907 10:39:54 RDR1     INFO: Copying meta file /data/inc_meb_01/datadir/backup-auto.cnf.
210907 10:39:54 RDR1     INFO: Starting to copy all innodb files...
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/ibdata1.
210907 10:39:54 RDR1     INFO: Starting to copy all undo files...
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_002.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_001.
210907 10:39:54 RDR1     INFO: Starting to lock instance for backup...
210907 10:39:54 RDR1     INFO: The server instance is locked for backup.
210907 10:39:54 RLP1     INFO: Starting to parse redo log at lsn = 18529810, whereas checkpoint_lsn = 18529828 and start_lsn = 18529792.
210907 10:39:54 RDR1     INFO: The server instance is unlocked after 0.003 seconds.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/sys/sys_config.ibd.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/test/test.ibd.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql/backup_progress.ibd.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql/backup_history.ibd.
210907 10:39:54 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql.ibd.
210907 10:39:55 RDR1     INFO: Completing the copy of innodb files.
210907 10:39:55 RDR1     INFO: Requesting a dump of the InnoDB buffer pool
210907 10:39:55 RDR1     INFO: Waiting for the dump of the InnoDB buffer pool to complete
210907 10:39:55 RDR1     INFO: The dump of the InnoDB buffer pool completed
210907 10:39:55 RDR1     INFO: Binary Log Basename: '/root/sandboxes/msb_8_0_26/data/binlog'
210907 10:39:55 RDR1     INFO: Binary Log Index:    '/root/sandboxes/msb_8_0_26/data/binlog.index'
210907 10:39:55 RDR1     INFO: Relay Channel:      'group_replication_applier'
210907 10:39:55 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_applier'
210907 10:39:55 RDR1     INFO: Relay Channel:      'group_replication_recovery'
210907 10:39:55 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_recovery'
210907 10:39:55 RDR1     INFO: Starting to copy Binlog files.
210907 10:39:55 RDR1     INFO: Starting to lock instance for backup...
210907 10:39:55 RDR1     INFO: The server instance is locked for backup.
210907 10:39:55 RDR1     INFO: The MySQL server has no active keyring.
210907 10:39:55 RDR1     INFO: Requesting flush of redo log reading after LSN 18536275.
210907 10:39:55 RDR1     INFO: Requesting flush of redo log processing after LSN 18536275.
210907 10:39:55 RDR1     INFO: Completed flush of redo log reading after LSN 18536275.
210907 10:39:55 RDR1     INFO: Completed flush of redo log processing after LSN 18536275.
210907 10:39:55 RDR1     INFO: Starting to read-lock tables...
210907 10:39:55 RDR1     INFO: No tables to read-lock.
210907 10:39:55 RDR1     INFO: Opening backup source directory '/root/sandboxes/msb_8_0_26/data'
210907 10:39:55 RDR1     INFO: Starting to copy non-innodb files in subdirs of '/root/sandboxes/msb_8_0_26/data'
210907 10:39:55 WTR1     INFO: Adding database directory: datadir/mysql
210907 10:39:55 WTR1     INFO: Adding database directory: datadir/performance_schema
210907 10:39:55 RDR1     INFO: Completing the copy of all non-innodb files.
210907 10:39:55 WTR1     INFO: Adding database directory: datadir/sys
210907 10:39:55 WTR1     INFO: Adding database directory: datadir/test
210907 10:39:55 RDR1     INFO: Requesting consistency information...
210907 10:39:55 RDR1     INFO: Locked the consistency point for 512 microseconds.
210907 10:39:55 RDR1     INFO: Consistency point server_uuid '2891d993-0f79-11ec-ad13-0050563345b0'.
210907 10:39:55 RDR1     INFO: Consistency point gtid_executed ''.
210907 10:39:55 RDR1     INFO: Consistency point binary_log_file 'binlog.000003'.
210907 10:39:55 RDR1     INFO: Consistency point binary_log_position 444.
210907 10:39:55 RDR1     INFO: Consistency point InnoDB lsn 18536752.
210907 10:39:55 RDR1     INFO: Consistency point InnoDB lsn_checkpoint 18529828.
210907 10:39:55 RDR1     INFO: Requesting completion of redo log copy after LSN 18536752.
210907 10:39:55 RLW1     INFO: A copied database page was modified at 18530251. (This is the highest lsn found on a page)
210907 10:39:55 RLW1     INFO: Scanned log up to lsn 18536752.
210907 10:39:55 RLW1     INFO: Was able to parse the log up to lsn 18536752.
210907 10:39:55 RLW1     INFO: Copied redo loglog_start_lsn    18529792start_checkpoint 18529828start_lsn        18529828last_checkpoint  18529828consistency_lsn  18536752log_end_lsn      18536752
210907 10:39:55 RLR1     INFO: Redo log reader waited 99 times for a total of 495.00 ms for logs to generate.
210907 10:39:55 RDR1     INFO: Truncating binary log index '/data/inc_meb_01/datadir/binlog.index' to 48.
210907 10:39:55 RDR1     INFO: Truncating binary log 'binlog.000003' to 444.
210907 10:39:55 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000003.
210907 10:39:55 RDR1     INFO: Completed the copy of binlog files...
210907 10:39:55 RDR1     INFO: The server instance is unlocked after 0.058 seconds.
210907 10:39:55 RDR1     INFO: Reading all global variables from the server.
210907 10:39:55 RDR1     INFO: Completed reading of all 615 global variables from the server.
210907 10:39:55 RDR1     INFO: Writing server defaults files 'server-my.cnf' and 'server-all.cnf' for server '8.0.26' in '/data/inc_meb_01'.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/meta/backup_variables.txt.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/datadir/ibbackup_logfile.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/server-all.cnf.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/server-my.cnf.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/datadir/ibbackup_ibd_files.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/meta/backup_content.xml.
210907 10:39:55 RDR1     INFO: Copying meta file /data/inc_meb_01/meta/image_files.xml.
210907 10:39:55 MAIN     INFO: Incremental Image Backup operation completed successfully.
210907 10:39:55 MAIN     INFO: Backup image created successfully.
210907 10:39:55 MAIN     INFO: Image Path = /data/inc_meb_01/incremental_image1.bi
210907 10:39:55 MAIN     INFO: Backup contains changes from lsn 18522787 to lsn 18536752
210907 10:39:55 MAIN     INFO: MySQL binlog position: filename binlog.000003, position 444-------------------------------------------------------------Parameters Summary
-------------------------------------------------------------Start LSN                  : 18522787Last Checkpoint LSN        : 18529828End LSN                    : 18536752
-------------------------------------------------------------mysqlbackup completed OK!

5

备份部分表

[root@localhost bin]#  ./mysqlbackup  --defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf \
>  --backup-dir=/data/parti_meb --backup-image=/data/parti_meb/test.mbi \
>  --include-tables="\.test" \
>  backup-to-image
MySQL Enterprise Backup  Ver 8.0.26-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Starting with following command line ...
./mysqlbackup
--defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf
--backup-dir=/data/parti_meb
--backup-image=/data/parti_meb/test.mbi
--include-tables=\.test
backup-to-imageIMPORTANT: Please check that mysqlbackup run completes successfully.At the end of a successful 'backup-to-image' run mysqlbackupprints "mysqlbackup completed OK!".210907 10:47:24 MAIN     INFO: Establishing connection to server.
210907 10:47:24 MAIN     INFO: No SSL options specified.
210907 10:47:24 MAIN     INFO: MySQL server version is '8.0.26'
210907 10:47:24 MAIN     INFO: MySQL server compile os version is 'Linux'
210907 10:47:24 MAIN     INFO: Got some server configuration information from running server.210907 10:47:24 MAIN     INFO: Establishing connection to server for locking.
210907 10:47:24 MAIN     INFO: No SSL options specified.
210907 10:47:24 MAIN     INFO: Backup directory exists: '/data/parti_meb'
210907 10:47:24 MAIN     INFO: MySQL server version_comment is 'MySQL Community Server - GPL'
210907 10:47:24 MAIN     INFO: Mysqlbackup component not installed.
210907 10:47:24 MAIN     INFO: MEB logfile created at /data/parti_meb/meta/MEB_2021-09-07.10-47-24_backup-to-image.log210907 10:47:24 MAIN     INFO: The MySQL server has no active keyring.
--------------------------------------------------------------------Server Repository Options:
--------------------------------------------------------------------datadir                        = /root/sandboxes/msb_8_0_26/data/innodb_data_home_dir           = innodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /root/sandboxes/msb_8_0_26/data/innodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /root/sandboxes/msb_8_0_26/data/innodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32--------------------------------------------------------------------Backup Config Options:
--------------------------------------------------------------------datadir                        = /data/parti_meb/datadirinnodb_data_home_dir           = /data/parti_meb/datadirinnodb_data_file_path          = ibdata1:12M:autoextendinnodb_log_group_home_dir      = /data/parti_meb/datadirinnodb_log_files_in_group      = 2innodb_log_file_size           = 50331648innodb_undo_directory          = /data/parti_meb/datadirinnodb_undo_tablespaces        = 2innodb_buffer_pool_filename    = ib_buffer_poolinnodb_page_size               = 16384innodb_checksum_algorithm      = crc32Backup Image Path = /data/parti_meb/test.mbi
210907 10:47:24 MAIN     INFO: Unique generated backup id for this is 16309828449845664210907 10:47:24 MAIN     INFO: Copying the server config file '/root/sandboxes/msb_8_0_26/data/auto.cnf'
210907 10:47:24 MAIN     INFO: Creating 14 buffers each of size 16777216.
210907 10:47:25 MAIN     INFO: The server is not configured for redo log archiving. The system variable innodb_redo_log_archive_dirs is not set.
210907 10:47:25 MAIN     INFO: Found checkpoint at lsn 18546663.
210907 10:47:25 MAIN     INFO: Starting log scan from lsn = 18546176 at offset = 324608 and checkpoint = 18546663 in file /root/sandboxes/msb_8_0_26/data/ib_logfile0.
210907 10:47:25 MAIN     INFO: Full Image Backup operation starts with following threads1 read-threads    6 process-threads    1 write-threads
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/backup-my.cnf.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/meta/backup_create.xml.
210907 10:47:25 RLP1     INFO: Starting to parse redo log at lsn = 18546270, whereas checkpoint_lsn = 18546663 and start_lsn = 18546176.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/datadir/backup-auto.cnf.
210907 10:47:25 RDR1     INFO: Starting to copy all innodb files...
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/ibdata1.
210907 10:47:25 RDR1     INFO: Starting to copy all undo files...
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_002.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/undo_001.
210907 10:47:25 RDR1     INFO: Starting to lock instance for backup...
210907 10:47:25 RDR1     INFO: The server instance is locked for backup.
210907 10:47:25 RDR1     INFO: The server instance is unlocked after 0.001 seconds.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/test/test.ibd.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/mysql.ibd.
210907 10:47:25 RDR1     INFO: Completing the copy of innodb files.
210907 10:47:25 RDR1     INFO: Binary Log Basename: '/root/sandboxes/msb_8_0_26/data/binlog'
210907 10:47:25 RDR1     INFO: Binary Log Index:    '/root/sandboxes/msb_8_0_26/data/binlog.index'
210907 10:47:25 RDR1     INFO: Relay Channel:      'group_replication_applier'
210907 10:47:25 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_applier'
210907 10:47:25 RDR1     INFO: Relay Channel:      'group_replication_recovery'
210907 10:47:25 RDR1     INFO: Relay Log Basename: '/root/sandboxes/msb_8_0_26/data/localhost-relay-bin-group_replication_recovery'
210907 10:47:25 RDR1     INFO: Starting to copy Binlog files.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000001.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000002.
210907 10:47:25 RDR1     INFO: Starting to lock instance for backup...
210907 10:47:25 RDR1     INFO: The server instance is locked for backup.
210907 10:47:25 RDR1     INFO: The MySQL server has no active keyring.
210907 10:47:25 RDR1     INFO: Requesting flush of redo log reading after LSN 18548372.
210907 10:47:25 RDR1     INFO: Requesting flush of redo log processing after LSN 18548372.
210907 10:47:25 RDR1     INFO: Completed flush of redo log reading after LSN 18548382.
210907 10:47:25 RDR1     INFO: Completed flush of redo log processing after LSN 18548372.
210907 10:47:25 RDR1     INFO: Starting to read-lock tables...
210907 10:47:25 RDR1     INFO: No tables to read-lock.
210907 10:47:25 RDR1     INFO: Opening backup source directory '/root/sandboxes/msb_8_0_26/data'
210907 10:47:25 RDR1     INFO: Starting to copy non-innodb files in subdirs of '/root/sandboxes/msb_8_0_26/data'
210907 10:47:25 RDR1     INFO: Completing the copy of all non-innodb files.
210907 10:47:25 RDR1     INFO: Requesting consistency information...
210907 10:47:25 RDR1     INFO: Locked the consistency point for 371 microseconds.
210907 10:47:25 RDR1     INFO: Consistency point server_uuid '2891d993-0f79-11ec-ad13-0050563345b0'.
210907 10:47:25 RDR1     INFO: Consistency point gtid_executed ''.
210907 10:47:25 RDR1     INFO: Consistency point binary_log_file 'binlog.000003'.
210907 10:47:25 RDR1     INFO: Consistency point binary_log_position 444.
210907 10:47:25 RDR1     INFO: Consistency point InnoDB lsn 18553468.
210907 10:47:25 RDR1     INFO: Consistency point InnoDB lsn_checkpoint 18546663.
210907 10:47:25 RDR1     INFO: Requesting completion of redo log copy after LSN 18553468.
210907 10:47:25 RLW1     INFO: A copied database page was modified at 18546663. (This is the highest lsn found on a page)
210907 10:47:25 RLW1     INFO: Scanned log up to lsn 18553468.
210907 10:47:25 RLW1     INFO: Was able to parse the log up to lsn 18553468.
210907 10:47:25 RLR1     INFO: Redo log reader waited 34 times for a total of 170.00 ms for logs to generate.
210907 10:47:25 RLW1     INFO: Copied redo loglog_start_lsn    18546176start_checkpoint 18546663start_lsn        18546663last_checkpoint  18546663consistency_lsn  18553468log_end_lsn      18553468
210907 10:47:25 RDR1     INFO: Truncating binary log index '/data/parti_meb/datadir/binlog.index' to 48.
210907 10:47:25 RDR1     INFO: Truncating binary log 'binlog.000003' to 444.
210907 10:47:25 RDR1     INFO: Copying /root/sandboxes/msb_8_0_26/data/binlog.000003.
210907 10:47:25 RDR1     INFO: Completed the copy of binlog files...
210907 10:47:25 RDR1     INFO: The server instance is unlocked after 0.031 seconds.
210907 10:47:25 RDR1     INFO: Reading all global variables from the server.
210907 10:47:25 RDR1     INFO: Completed reading of all 615 global variables from the server.
210907 10:47:25 RDR1     INFO: Writing server defaults files 'server-my.cnf' and 'server-all.cnf' for server '8.0.26' in '/data/parti_meb'.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/meta/backup_variables.txt.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/datadir/ibbackup_logfile.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/server-all.cnf.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/server-my.cnf.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/meta/backup_content.xml.
210907 10:47:25 RDR1     INFO: Copying meta file /data/parti_meb/meta/image_files.xml.
210907 10:47:25 MAIN     INFO: Full Image Backup operation completed successfully.
210907 10:47:25 MAIN     INFO: Backup image created successfully.
210907 10:47:25 MAIN     INFO: Image Path = /data/parti_meb/test.mbi
210907 10:47:25 MAIN     INFO: MySQL binlog position: filename binlog.000003, position 444-------------------------------------------------------------Parameters Summary
-------------------------------------------------------------Start LSN                  : 18546176Last Checkpoint LSN        : 18546663End LSN                    : 18553468
-------------------------------------------------------------mysqlbackup completed OK!

6

恢复增量备份

在执行增量恢复之前,要先恢复完整全量备份,即上面第2大点备份整库与恢复中的第3小点。

[root@localhost bin]# ./mysqlbackup --defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf   --backup-image=/data/inc_meb_01/incremental_image1.bi \
>  --backup-dir=/data/inc_meb_01/tmp  --datadir=/root/sandboxes/msb_8_0_26/data --incremental \
>  copy-back-and-apply-log
......
210907 11:25:11 PCR1     INFO: Log file header:format = 4 pad1 = 0 start lsn = 18539520 checkpoint lsn = 18539594 checksum = 2666310026creator = MEB 8.0.26
210907 11:25:11 PCR1     INFO: We were able to parse ibbackup_logfile up to lsn 18544528.
210907 11:25:11 PCR1     INFO: Last MySQL binlog file position 0 443, file name binlog.000004
210907 11:25:11 PCR1     INFO: The first data file is '/root/sandboxes/msb_8_0_26/data/ibdata1'and the new created log files are at '/root/sandboxes/msb_8_0_26/data'
210907 11:25:11 MAIN     INFO: Apply-log operation completed successfully.
210907 11:25:11 MAIN     INFO: Incremental backup applied successfully.mysqlbackup completed OK! with 3 warnings

7

恢复部分备份

恢复单表的前提是MySQL正在运行。

[root@localhost bin]#  ./mysqlbackup --defaults-file=/root/sandboxes/msb_8_0_26/my.sandbox.cnf  --backup-dir=/data/parti_meb/tmp --backup-image=/data/parti_meb/test.mbi  --include-tables="^test\.test"   copy-back-and-apply-log
......
210907 11:49:37 PCR1     INFO: backup variable log_bin_index_name=binlog
210907 11:49:37 PCR1     INFO: backup variable innodb_undo_files_count=2
210907 11:49:37 PCR1     INFO: Last MySQL binlog file position 0 731, file name binlog.000004
210907 11:49:37 PCR1     INFO: The first data file is '/root/sandboxes/msb_8_0_26/data/ibdata1'and the new created log files are at '/root/sandboxes/msb_8_0_26/data/'
210907 11:49:37 MAIN     INFO: Importing table: `test`.`test`.
210907 11:49:37 MAIN     INFO: Analyzing table: `test`.`test`.
210907 11:49:37 MAIN     INFO: Apply-log operation completed successfully.
210907 11:49:37 MAIN     INFO: Backup has been restored successfully.mysqlbackup completed OK!

8

总结

  1. MySQL Enterprise Backup(MEB)是收费工具,可以跨平台运行,MEB版8.0.26只能用于MySQL 8.0.26,有相应的版本对应。

  2. MEB功能较多,像压缩备份、并行备份、加密、流式传输、表空间传输、备份REDO归档、备份到云等,感兴趣的朋友可以自行测试。

参考 :https://dev.mysql.com/doc/mysql-enterprise-backup/8.0/en/


墨天轮原文链接:https://www.modb.pro/db/107670?sjhy(复制到浏览器或者点击“阅读原文”立即查看)

关于作者

黄江平,云和恩墨MySQL DBA, Oracle OCP。现服务于金融证券行业,负责MySQL数据库SQL优化、数据库故障处理、备份恢复、迁级升级、性能优化,有10年的数据库运维经验。

END

推荐阅读:267页!2020年度数据库技术年刊

推荐下载:2020数据技术嘉年华PPT下载

2020数据技术嘉年华近50个PPT下载、视频回放已上传墨天轮平台,可在“数据和云”公众号回复关键词“2020DTC”获得!

你知道吗?我们的视频号里已经发布了很多精彩的内容,快去看看吧!↓↓↓

点击下图查看更多 ↓

云和恩墨大讲堂 | 一个分享交流的地方

长按,识别二维码,加入万人交流社群

请备注:云和恩墨大讲堂

  点个“在看”

你的喜欢会被看到❤

MySQLBackup 8.0.26 备份与恢复相关推荐

  1. Tomcat7.0.26的连接数控制bug的问题排查

    参考:http://ifeve.com/tomcat7-0-26-connect-bug/ 首先感谢@烈元一起排查此问题.今天发现线上一台机器,监控一直在告警,一看是健康检查不通过,就上去查看了下,首 ...

  2. Windows XP环境下Apache2.2.21和Tomcat7.0.26下的整合

    用到这个纯属偶然吧,实训的进行系统设计时自己觉得用下Apache和Tomcat整合下较好.因此网上查找了一些,自己实现了一下.我们都知道Tomcat 应用于服务器JSP处理是比较强的,但遇到一些诸如H ...

  3. 关于Mysql8.0.26版本与IDEA连接的配置

    关于Mysql8.0.26版本与IDEA连接的配置 driver=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/mybatis?us ...

  4. Windows环境下MySQL8.0.26下载安装详细步骤

    概述 1. MySQL Community Server 社区版本,开源免费,自由下载,但不提供官方技术支持,适用于 大多数普通用户.  2. MySQL Enterprise Edition 企业版 ...

  5. libusb系列-007-Qt下使用libusb1.0.26源码

    libusb系列-007-Qt下使用libusb1.0.26源码 文章目录 libusb系列-007-Qt下使用libusb1.0.26源码 摘要 安装编译环境 确认需要的文件 开始编译 错误1:找不 ...

  6. mysql 8.0.26学习笔记超详细入门到精通

    目录 1.基本的SELECT语句 1.1 查询表中特定字段 1.2 字段取别名 1.3 数据去重 1.4 数据空值替换 1.5 显示表的结构 1.6 条件查询where 2.算术运算符 3.比较运算符 ...

  7. linux安装mysql-8.0.26

    Mysql8.0.26安装实践 该安装步骤参考自官方文档: MySQL :: MySQL 8.0 Reference Manual :: 2 Installing and Upgrading MySQ ...

  8. tensorflow 1.13.1 requires wheel>=0.26, which is not installed. After October 2020 you may exper

    安装tensorflow时出现如下错误: 键入命令时在后面加上  --use-feature=2020-resolver 即可 还有如下错误: 这四个错误的解决方法一样,以第一个为例输入如下命令: p ...

  9. ProgeCAD 2009 Pro 9.0.26.6 (建筑CAD)iv.rar

    MIKE.ZERO.2007水利模型系统].DHI.MIKE.ZERO.V2007 授权文件/ Mvtec.Halcon v8.02 1CD 世界上最全能的机器视觉软件_好用/    2600 Ni. ...

最新文章

  1. 5.创建表,使用alter进行表信息的增删改,Oracle回收站,集合运算
  2. android 服务端 漏洞,安卓漏洞 CVE 2017-13287 复现详解-
  3. python 图表_使用Streamlit-Python将动画图表添加到仪表板
  4. Oracle数据库性能问题分析的一种常规思路
  5. Android AES加密算法及事实上现
  6. Python机器学习全流程项目实战精讲(2018版)
  7. 关于JAVA是值传递还是引用传递的问题
  8. SIGCHLD waitpid, 小心子进程结束事件被偷了
  9. C#多线程的用法2-线程的生命周期
  10. Java第五次作业 ,面向对象高级特性(抽象类与接口)
  11. python实现栅栏密码加解密
  12. mysql-repeatable read可以避免幻读
  13. pocketpc同步驱动_PocketPC上的NewsBreak RSS Feed阅读器和播客
  14. 微信小程序-云开发云调用API没有权限(no permission)问题
  15. rpx 和 rem 详解
  16. TARS 斩获 2018 年最佳原创开源软件奖
  17. uCLinux LINUX区别
  18. Hadoop相关参数调优
  19. 机器视觉测量技术真的简单吗
  20. pytorch visdom安装启动问题

热门文章

  1. Bootstrap导航栏注释
  2. 数据库健康状况监视_监视数据库运行状况和行为:哪些指标重要?
  3. devops 开发_DevOps如何消除开发瓶颈
  4. docker 安全性_使用最新的安全性增强来调整Docker
  5. html(+css)/01/html语言基础,标记,标记语法,html文档结构
  6. HTML5 canvas中使用路径
  7. 在Linux中切换用户的命令是set,Linux基础命令---切换用户su
  8. python中plot函数的属性_Python matplotlib 学习-绘图函数
  9. sql server ssl安全错误_渗透测试 丨 SQL注入的攻与防
  10. python如何将多张excel表内数据求和_Excel批量操作,把你的工作效率提升10倍以上(1)...