基于Xtrabackup备份集来恢复某个误删除的表(drop)
Hostname | IP/Port | Identity | OS Version | MySQL Version | GTID Mode | Binlog Format |
zlm2 | 192.168.1.101/3306 | master | CentOS 7.0 | 5.7.21 | on | row |
zlm3 | 192.168.1.102/3306 | slave | CentOS 7.0 | 5.7.21 | on | row |
[root@zlm2 :: ~]
#innobackupex --defaults-file=/data/mysql/mysql3306/my.cnf -uroot -pPassw0rd /data/backup
xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
:: innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!". ... //Omitted the procedure. :: Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): ''
xtrabackup: Stopping log copying thread.
. :: >> log scanned up to () :: Executing UNLOCK TABLES
:: All tables unlocked
:: [] Copying ib_buffer_pool to /data/backup/--27_07--/ib_buffer_pool
:: [] ...done
:: Backup created in directory '/data/backup/2018-07-27_07-57-43/'
MySQL binlog position: filename 'mysql-bin.000035', position '', GTID of the last change '1b7181ee-6eaf-11e8-998e-080027de0e0e:1-3730220'
:: [] Writing /data/backup/--27_07--/backup-my.cnf
:: [] ...done
:: [] Writing /data/backup/--27_07--/xtrabackup_info
:: [] ...done
xtrabackup: Transaction log of lsn () to () was copied.
:: completed OK!
(zlm@192.168.1.101 )[sysbench]>show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest1 |
| sbtest2 |
| sbtest3 |
| sbtest4 |
| sbtest5 |
| sbtest6 |
| sbtest7 |
+--------------------+
rows in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>select count(*) from sbtest7;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>show master status;
+------------------+----------+--------------+------------------+------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------------+
| mysql-bin. | | | | 1b7181ee-6eaf-11e8-998e-080027de0e0e:- |
+------------------+----------+--------------+------------------+------------------------------------------------+
row in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>flush logs;
Query OK, rows affected (0.02 sec) (zlm@192.168.1.101 )[sysbench]>delete from sbtest7 limit ;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.101 )[sysbench]>select count(*) from sbtest7;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>show master status;
+------------------+----------+--------------+------------------+------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------------+
| mysql-bin. | | | | 1b7181ee-6eaf-11e8-998e-080027de0e0e:- |
+------------------+----------+--------------+------------------+------------------------------------------------+
row in set (0.00 sec)
(zlm@192.168.1.101 )[sysbench]>drop table sbtest7;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.101 )[sysbench]>show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest1 |
| sbtest2 |
| sbtest3 |
| sbtest4 |
| sbtest5 |
| sbtest6 |
+--------------------+
rows in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>show master status;
+------------------+----------+--------------+------------------+------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------------+
| mysql-bin. | | | | 1b7181ee-6eaf-11e8-998e-080027de0e0e:- |
+------------------+----------+--------------+------------------+------------------------------------------------+
row in set (0.00 sec)
[root@zlm2 :: /data/backup]
#ls -l
total
drwxr-x--- root root Jul : --27_07-- [root@zlm2 :: /data/backup]
#tar cf innobkex_full.tar --27_07--/ [root@zlm2 :: /data/backup]
#ls -l
total
drwxr-x--- root root Jul : --27_07--
-rw-r--r-- root root Jul : innobkex_full.tar [root@zlm2 :: /data/backup]
#scp innobkex_full.tar zlm3:/data/backup
root@zlm3's password:
innobkex_full.tar % 183MB .5MB/s : [root@zlm2 :: /data/backup]
#
[root@zlm3 :: /data/backup]
#ls -l
total
-rw-r--r-- root root Jul : innobkex_full.tar [root@zlm3 :: /data/backup]
#tar xf innobkex_full.tar [root@zlm3 :: /data/backup]
#ls -l
total
drwxr-x--- root root Jul : --27_07--
-rw-r--r-- root root Jul : innobkex_full.tar [root@zlm3 :: /data/backup]
#cd --27_07--/ [root@zlm3 :: /data/backup/--27_07--]
#ls -l
total
-rw-r----- root root Jul : backup-my.cnf
-rw-r----- root root Jul : ib_buffer_pool
-rw-r----- root root Jul : ibdata1
drwxr-x--- root root Jul : mysql
drwxr-x--- root root Jul : performance_schema
drwxr-x--- root root Jul : sys
drwxr-x--- root root Jul : sysbench
-rw-r----- root root Jul : xtrabackup_binlog_info
-rw-r----- root root Jul : xtrabackup_checkpoints
-rw-r----- root root Jul : xtrabackup_info
-rw-r----- root root Jul : xtrabackup_logfile [root@zlm3 :: /data/backup/--27_07--]
#cd sysbench/ [root@zlm3 :: /data/backup/--27_07--/sysbench]
#ls -l
total
-rw-r----- root root Jul : db.opt
-rw-r----- root root Jul : sbtest1.frm
-rw-r----- root root Jul : sbtest1.ibd
-rw-r----- root root Jul : sbtest2.frm
-rw-r----- root root Jul : sbtest2.ibd
-rw-r----- root root Jul : sbtest3.frm
-rw-r----- root root Jul : sbtest3.ibd
-rw-r----- root root Jul : sbtest4.frm
-rw-r----- root root Jul : sbtest4.ibd
-rw-r----- root root Jul : sbtest5.frm
-rw-r----- root root Jul : sbtest5.ibd
-rw-r----- root root Jul : sbtest6.frm
-rw-r----- root root Jul : sbtest6.ibd
-rw-r----- root root Jul : sbtest7.frm
-rw-r----- root root Jul : sbtest7.ibd [root@zlm3 :: /data/backup/--27_07--/sysbench]
#mv sbtest7* ../ [root@zlm3 :: /data/backup/--27_07--/sysbench]
#ls -l
total
-rw-r----- root root Jul : db.opt
-rw-r----- root root Jul : sbtest1.frm
-rw-r----- root root Jul : sbtest1.ibd
-rw-r----- root root Jul : sbtest2.frm
-rw-r----- root root Jul : sbtest2.ibd
-rw-r----- root root Jul : sbtest3.frm
-rw-r----- root root Jul : sbtest3.ibd
-rw-r----- root root Jul : sbtest4.frm
-rw-r----- root root Jul : sbtest4.ibd
-rw-r----- root root Jul : sbtest5.frm
-rw-r----- root root Jul : sbtest5.ibd
-rw-r----- root root Jul : sbtest6.frm
-rw-r----- root root Jul : sbtest6.ibd [root@zlm3 :: /data/backup/--27_07--/sysbench]
#rm -f sbtest* //Delete all those irrelevant tables which I'm not going to rescue.It can extremly reduce the content I need. [root@zlm3 :: /data/backup/--27_07--/sysbench]
#mv ../sbtest* . [root@zlm3 :: /data/backup/--27_07--/sysbench]
#ls -l
total
-rw-r----- root root Jul : db.opt
-rw-r----- root root Jul : sbtest7.frm
-rw-r----- root root Jul : sbtest7.ibd
[root@zlm3 :: /data/backup/--27_07--/sysbench]
#innobackupex --defaults-file=/data/mysql/mysql3306/my.cnf --apply-log /data/backup/--27_07--/
xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group= --innodb_log_file_size= --innodb_fast_checksum= --innodb_page_size= --innodb_log_block_size= --innodb_undo_directory=./ --innodb_undo_tablespaces= --server-id= --redo-log-version=
xtrabackup: recognized client arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:100M:autoextend --innodb_log_files_in_group= --innodb_log_file_size= --innodb_fast_checksum= --innodb_page_size= --innodb_log_block_size= --innodb_undo_directory=./ --innodb_undo_tablespaces= --server-id= --redo-log-version=
:: innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully.
At the end of a successful apply-log run innobackupex
prints "completed OK!". innobackupex version 2.4. based on MySQL server 5.7. Linux (x86_64) (revision id: 170eb8c)
xtrabackup: cd to /data/backup/--27_07--/ ... //Omitted. InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
InnoDB: New log files created, LSN=
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn
InnoDB: Doing recovery: scanned up to log sequence number (%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position , file name mysql-bin.
InnoDB: Removed temporary tablespace data file: "ibtmp1"
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now MB.
InnoDB: redo rollback segment(s) found. redo rollback segment(s) are active.
InnoDB: non-redo rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.7. started; log sequence number
xtrabackup: starting shutdown with innodb_fast_shutdown =
InnoDB: page_cleaner: 1000ms intended loop took 18267ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number
:: completed OK! [root@zlm3 :: /data/backup/--27_07--/sysbench]
#cd .. [root@zlm3 :: /data/backup/--27_07--]
#ls -l
total
-rw-r----- root root Jul : backup-my.cnf
-rw-r----- root root Jul : ib_buffer_pool
-rw-r----- root root Jul : ibdata1
-rw-r----- root root Jul : ib_logfile0
-rw-r----- root root Jul : ib_logfile1
-rw-r----- root root Jul : ib_logfile2
-rw-r----- root root Jul : ibtmp1
drwxr-x--- root root Jul : mysql
drwxr-x--- root root Jul : performance_schema
drwxr-x--- root root Jul : sys
drwxr-x--- root root Jul : sysbench
-rw-r----- root root Jul : xtrabackup_binlog_info
-rw-r--r-- root root Jul : xtrabackup_binlog_pos_innodb
-rw-r----- root root Jul : xtrabackup_checkpoints
-rw-r----- root root Jul : xtrabackup_info
-rw-r----- root root Jul : xtrabackup_logfile
-rw-r--r-- root root Jul : xtrabackup_master_key_id [root@zlm3 :: /data/backup/--27_07--]
#cat xtrabackup_binlog_info
mysql-bin. 1b7181ee-6eaf-11e8-998e-080027de0e0e:- [root@zlm3 :: /data/backup/--27_07--]
#cat xtrabackup_binlog_pos_innodb
mysql-bin. //The result of "show master status;" on zlm2.
(zlm@192.168.1.101 )[(none)]>show master status;
+------------------+----------+--------------+------------------+------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------------+
| mysql-bin. | | | | 1b7181ee-6eaf-11e8-998e-080027de0e0e:- | //The newest GTID is "uuid:1-3730222"
+------------------+----------+--------------+------------------+------------------------------------------------+
row in set (0.00 sec)
[root@zlm3 :: /data/backup/--27_07--]
#ps aux|grep mysqld
mysql 0.0 20.2 pts/ Sl : : mysqld --defaults-file=/data/mysql/mysql3306/my.cnf
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /data/backup/--27_07--]
#mysqladmin shutdown [root@zlm3 :: /data/backup/--27_07--]
#ps aux|grep mysqld
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /data/backup/--27_07--]
#innobackupex --defaults-file=/data/mysql/mysql3306/my.cnf --copy-back /data/backup/--27_07--/
xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
:: innobackupex: Starting the copy-back operation IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!". innobackupex version 2.4. based on MySQL server 5.7. Linux (x86_64) (revision id: 170eb8c)
Original data directory /data/mysql/mysql3306/data is not empty! //The data directory need to be cleaned. [root@zlm3 :: /data/backup/--27_07--]
#cd /data/mysql/mysql3306/data [root@zlm3 :: /data/mysql/mysql3306/data]
#ls -l
total
-rw-r----- mysql mysql Jul : auto.cnf
-rw-r----- mysql mysql Jul : error.log
-rw-r----- mysql mysql Jul : ib_buffer_pool
-rw-r----- mysql mysql Jul : ibdata1
-rw-r----- mysql mysql Jul : ib_logfile0
-rw-r----- mysql mysql Jul : ib_logfile1
-rw-r----- mysql mysql Jul : ib_logfile2
drwxr-x--- mysql mysql Jul : mysql
drwxr-x--- mysql mysql Jul : performance_schema
-rw-r----- mysql mysql Jul : relay-bin.
-rw-r----- mysql mysql Jul : relay-bin.
-rw-r----- mysql mysql Jul : relay-bin-group_replication_applier.
-rw-r----- mysql mysql Jul : relay-bin-group_replication_applier.index
-rw-r----- mysql mysql Jul : relay-bin-group_replication_recovery.
-rw-r----- mysql mysql Jul : relay-bin-group_replication_recovery.index
-rw-r----- mysql mysql Jul : relay-bin.index
-rw-r----- mysql mysql Jul : slow.log
drwxr-x--- mysql mysql Jul : sys
drwxr-x--- mysql mysql Jul : sysbench
-rw-r----- mysql mysql Jul : xtrabackup_info [root@zlm3 :: /data/mysql/mysql3306/data]
#rm -rf * [root@zlm3 :: /data/mysql/mysql3306/data]
#ls -l
total [root@zlm3 :: /data/mysql/mysql3306/data]
#innobackupex --defaults-file=/data/mysql/mysql3306/my.cnf --copy-back /data/backup/--27_07--/
xtrabackup: recognized server arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
xtrabackup: recognized client arguments: --datadir=/data/mysql/mysql3306/data --tmpdir=/data/mysql/mysql3306/tmp --open_files_limit= --server-id= --log_bin=/data/mysql/mysql3306/logs/mysql-bin --innodb_buffer_pool_size=100M --innodb_data_file_path=ibdata1:100M:autoextend --innodb_flush_log_at_trx_commit= --innodb_log_buffer_size=8M --innodb_log_file_size=100M --innodb_log_files_in_group= --innodb_max_dirty_pages_pct= --innodb_file_per_table= --innodb_io_capacity= --innodb_flush_method=O_DIRECT --server-id=
:: innobackupex: Starting the copy-back operation IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!". innobackupex version 2.4. based on MySQL server 5.7. Linux (x86_64) (revision id: 170eb8c)
:: [] Copying ib_logfile0 to /data/mysql/mysql3306/data/ib_logfile0
:: [] ...done
:: [] Copying ib_logfile1 to /data/mysql/mysql3306/data/ib_logfile1
:: [] ...done
:: [] Copying ib_logfile2 to /data/mysql/mysql3306/data/ib_logfile2
:: [] ...done
:: [] Copying ibdata1 to /data/mysql/mysql3306/data/ibdata1
:: [] ...done ... //Omitted. :: [] Copying ./ib_buffer_pool to /data/mysql/mysql3306/data/ib_buffer_pool
:: [] ...done
:: [] Copying ./xtrabackup_info to /data/mysql/mysql3306/data/xtrabackup_info
:: [] ...done
:: [] Copying ./xtrabackup_binlog_pos_innodb to /data/mysql/mysql3306/data/xtrabackup_binlog_pos_innodb
:: [] ...done
:: [] Copying ./xtrabackup_master_key_id to /data/mysql/mysql3306/data/xtrabackup_master_key_id
:: [] ...done
:: [] Copying ./ibtmp1 to /data/mysql/mysql3306/data/ibtmp1
:: [] ...done
:: completed OK!
[root@zlm3 :: /data/mysql/mysql3306/data]
#sh /root/mysqld.sh [root@zlm3 :: /data/mysql/mysql3306/data]
#ps aux|grep mysqld
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld [root@zlm3 :: /data/mysql/mysql3306/data]
#tail -f error.log
--27T08::22.902146+: [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
--27T08::22.902161+: [ERROR] InnoDB: Plugin initialization aborted with error Generic error
--27T08::23.503758+: [ERROR] Plugin 'InnoDB' init function returned error.
--27T08::23.503784+: [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
--27T08::23.503792+: [ERROR] Failed to initialize builtin plugins.
--27T08::23.503796+: [ERROR] Aborting --27T08::23.503801+: [Note] Binlog end
--27T08::23.504149+: [Note] mysqld: Shutdown complete ^C [root@zlm3 :: /data/mysql/mysql3306/data]
#chown -R mysql.mysql * [root@zlm3 :: /data/mysql/mysql3306/data]
#ls -l
total
-rw-r----- mysql mysql Jul : error.log
-rw-r----- mysql mysql Jul : ib_buffer_pool
-rw-r----- mysql mysql Jul : ibdata1
-rw-r----- mysql mysql Jul : ib_logfile0
-rw-r----- mysql mysql Jul : ib_logfile1
-rw-r----- mysql mysql Jul : ib_logfile2
-rw-r----- mysql mysql Jul : ibtmp1
-rw-r----- mysql mysql Jul : innodb_status.
drwxr-x--- mysql mysql Jul : mysql
drwxr-x--- mysql mysql Jul : performance_schema
drwxr-x--- mysql mysql Jul : sys
drwxr-x--- mysql mysql Jul : sysbench
-rw-r----- mysql mysql Jul : xtrabackup_binlog_pos_innodb
-rw-r----- mysql mysql Jul : xtrabackup_info
-rw-r----- mysql mysql Jul : xtrabackup_master_key_id [root@zlm3 :: /data/mysql/mysql3306/data]
#sh /root/mysqld.sh [root@zlm3 :: /data/mysql/mysql3306/data]
#ps aux|grep mysqld
mysql 3.0 17.7 pts/ Sl : : mysqld --defaults-file=/data/mysql/mysql3306/my.cnf
root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld (zlm@192.168.1.102 )[(none)]>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| sysbench |
+--------------------+
rows in set (0.01 sec) (zlm@192.168.1.102 )[(none)]>use sysbench
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
(zlm@192.168.1.102 )[sysbench]>show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest7 |
+--------------------+
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>select count(*) from sbtest7;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.00 sec) //Compare the output of server zlm2.
(zlm@192.168.1.101 )[sysbench]>show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest1 |
| sbtest2 |
| sbtest3 |
| sbtest4 |
| sbtest5 |
| sbtest6 |
+--------------------+
rows in set (0.00 sec)
(zlm@192.168.1.102 )[sysbench]>show slave status\G
Empty set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show master status;
+------------------+----------+--------------+------------------+------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------------+
| mysql-bin. | | | | 1b7181ee-6eaf-11e8-998e-080027de0e0e:- |
+------------------+----------+--------------+------------------+------------------------------------------------+
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>change master to \
-> master_host='192.168.1.101',\
-> master_port=,\
-> master_user='repl',\
-> master_password='repl4slave',\
-> master_auto_position=;
Query OK, rows affected, warnings (0.05 sec)
(zlm@192.168.1.102 )[sysbench]>start slave io_thread;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: repl
Master_Port:
Connect_Retry:
Master_Log_File: mysql-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 1b7181ee-6eaf-11e8-998e-080027de0e0e
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e: //The newest transaction has been retrieved.
Executed_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)
(zlm@192.168.1.102 )[sysbench]>change replication filter replicate_do_table=(sysbench.sbteset7);
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: repl
Master_Port:
Connect_Retry:
Master_Log_File: mysql-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table: sysbench.sbteset7
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 1b7181ee-6eaf-11e8-998e-080027de0e0e
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:
Executed_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)
[root@zlm2 :: ~]
#mysqlbinlog -v --base64-output=decode-rows /data/mysql/mysql3306/logs/mysql-bin.
mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin.
mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin.
mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin.index
mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. mysql-bin. [root@zlm2 :: ~]
#mysqlbinlog -v --base64-output=decode-rows /data/mysql/mysql3306/logs/mysql-bin. > .log [root@zlm2 :: ~]
#tail - .log
### @=
### @='32005756334-91141508143-50354766020-63389724388-71947328293-08845712532-56754824208-47077542818-55826128113-56514840054'
### @='22255110541-96175917050-58709546750-68026622026-27581577227'
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/;
# at
# :: server id end_log_pos GTID last_committed= sequence_number= rbr_only=no
SET @@SESSION.GTID_NEXT= '1b7181ee-6eaf-11e8-998e-080027de0e0e:3730222'/*!*/; //Here's the GTID we need.
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
use `sysbench`/*!*/;
SET TIMESTAMP=/*!*/;
DROP TABLE `sbtest7` /* generated by server */
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
(zlm@192.168.1.102 )[sysbench]>start slave sql_thread until sql_before_gtids='1b7181ee-6eaf-11e8-998e-080027de0e0e:3730222';
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: repl
Master_Port:
Connect_Retry:
Master_Log_File: mysql-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File: mysql-bin.
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table: sysbench.sbteset7
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: SQL_BEFORE_GTIDS
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 1b7181ee-6eaf-11e8-998e-080027de0e0e
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:
Executed_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>select count(*) from sbtest7;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.00 sec) //Why the amount of record isn't 9990?
(zlm@192.168.1.102 )[sysbench]>stop slave;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[sysbench]>start slave;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: repl
Master_Port:
Connect_Retry:
Master_Log_File: mysql-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File: mysql-bin.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table: sysbench.sbteset7
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 1b7181ee-6eaf-11e8-998e-080027de0e0e
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:
Executed_Gtid_Set: 1b7181ee-6eaf-11e8-998e-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest7 |
+--------------------+
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>select count(*) from sbtest7;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.01 sec) //Even though it has executed the newest GTID "uuid:3730222",the amount of record is unchanged.
[root@zlm3 :: /data/mysql/mysql3306/data]
#cd ../logs [root@zlm3 :: /data/mysql/mysql3306/logs]
#ls -l
total
-rw-r----- mysql mysql Jul : mysql-bin.
-rw-r----- mysql mysql Jul : mysql-bin.
-rw-r----- mysql mysql Jul : mysql-bin.
-rw-r----- mysql mysql Jul : mysql-bin.index [root@zlm3 :: /data/mysql/mysql3306/logs]
#mysqlbinlog -v --base64-output=decode-rows mysql-bin. > .log [root@zlm3 :: /data/mysql/mysql3306/logs]
#cat .log
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at
# :: server id end_log_pos Start: binlog v , server v 5.7.-log created :: at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/; //It shows that transactions in this binlog file have been rolled back!!!
# at
# :: server id end_log_pos Previous-GTIDs
# 1b7181ee-6eaf-11e8-998e-080027de0e0e:- //The rolled back GTID is from 3730215 to 3730221.
# at
# :: server id end_log_pos GTID last_committed= sequence_number= rbr_only=no
SET @@SESSION.GTID_NEXT= '1b7181ee-6eaf-11e8-998e-080027de0e0e:3730222'/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
SET @@session.pseudo_thread_id=/*!*/;
SET @@session.foreign_key_checks=, @@session.sql_auto_is_null=, @@session.unique_checks=, @@session.autocommit=/*!*/;
SET @@session.sql_mode=/*!*/;
SET @@session.auto_increment_increment=, @@session.auto_increment_offset=/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=,@@session.collation_connection=,@@session.collation_server=/*!*/;
SET @@session.lc_time_names=/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
COMMIT
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
基于Xtrabackup备份集来恢复某个误删除的表(drop)的更多相关文章
- 利用binlog server及Xtrabackup备份集来恢复误删表(drop)
Preface Today I'm gonna test how to rescue a dropped table from binlog server based on a ful ...
- 基于mysqldump备份集来恢复某个误操作的表(drop,truncate)
Preface How to rescue a dropped or truncated table online?Dropping or truncating is ddl oper ...
- 基于全备份+binlog方式恢复数据
基于全备份+binlog方式恢复数据 将bkxt从库的全备份在rescs5上恢复一份,用cmdb操作 恢复全备后执行如下操作 set global read_only=OFF; stop slave; ...
- MySQL 基于xtrabackup备份—热备工具
xtrabackup(仅对InnoDB存储引擎支持热备) percona公司开发 改进的MySQL分支:percona-server 存储引擎改进:InnoDB —> XtraDB 使用本地的R ...
- 【RAC】将单实例备份集恢复为rac数据库
[RAC]将单实例备份集恢复为rac数据库 一.1 BLOG文档结构图 一.2 前言部分 一.2.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识, ...
- Percona XtraBackup 备份原理说明【转】
本文来自:http://mysql.taobao.org/monthly/2016/03/07/ 前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MyS ...
- MySQL · 物理备份 · Percona XtraBackup 备份原理
http://mysql.taobao.org/monthly/2016/03/07/ 前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MySQL 数据 ...
- Percona XtraBackup 备份原理
前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MySQL 数据库物理热备的备份工具,支持 MySQl(Oracle).Percona Server 和 ...
- XtraBackup 备份原理
来着淘宝技术: http://mysql.taobao.org/monthly/2016/03/07/ https://github.com/alibaba/AliSQL 前言 Percona Xtr ...
随机推荐
- pat甲级1085
1085 Perfect Sequence (25 分) Given a sequence of positive integers and another positive integer p. T ...
- POJ-2155 Matrix---二维树状数组+区域更新单点查询
题目链接: https://vjudge.net/problem/POJ-2155 题目大意: 给一个n*n的01矩阵,然后有两种操作(m次)C x1 y1 x2 y2是把这个小矩形内所有数字异或一遍 ...
- mm_struct简要解析
http://blog.chinaunix.net/uid-20729583-id-1884615.html struct mm_struct { /* 指向线性区对象的链表头 ...
- 2019.03.09 ZJOI2019模拟赛 解题报告
得分: \(20+0+40=60\)(\(T1\)大暴力,\(T2\)分类讨论写挂,\(T3\)分类讨论\(40\)分) \(T1\):天空碎片 一道神仙数学题,貌似需要两次使用中国剩余定理. 反正不 ...
- linux服务器安装nginx及使用
Nginx在个人的使用之后,感觉非常的方便,所以在这里给出自己安装配置方案.它是一款高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.负载均衡是个不错的选择. ...
- textkit
更详细的内容可以参考官方文档 <Text Programming Guide for iOS>. “Text Kit指的是UIKit框架中用于提供高质量排版服务的一些类和协议,它让程序能够 ...
- 【学时总结】 ◆学时·II◆ IDA*算法
[学时·II] IDA*算法 ■基本策略■ 如果状态数量太多了,优先队列也难以承受:不妨再回头看DFS-- A*算法是BFS的升级,那么IDA*算法是对A*算法的再优化,同时也是对迭代加深搜索(IDF ...
- 将 cmd 中命令输出内容保存为 TXT 文本文件
如果执行的命令输出内容较多,那么 cmd 控制台将会自动清除前面的内容,那么如何将屏幕的所有内容导出到文本文件? 下面给出简单的演示例子 ping百度,不会自动结束,按 Ctrl+C 强制结束,pin ...
- python的多继承C3(mro)算法
多继承的继承顺序按照C3算法进行顺序继承 例一 按照深度A类从左往右有三条可继承的"路" 先按照深度优先的算法,将每一路的每一个节点加到列表中 B = [B,D,F,H] C = ...
- Android内购订单验证 --- nodejs实现
主代码: function AndroidPlayVerify(inappPurchaseData, inappDataSignature) { let verify = crypto.createV ...