Troubleshooting of abnormal shutdown of MySQLSlave (pt-slave-restart)
Troubleshooting of abnormal shutdown of MySQL Slave (pt-slave-restart)
The following three methods are used to handle abnormal shutdown of MySQL Slave.
You can also use the pt-slave-restart command of percona-toolkit.
The percona-toolkit-2.2.8-1.noarch.rpm needs to install some dependency packages.
Yum install perl-DBI perl-DBD-MySQL perl-IO-Socket-SSL perl-Time-HiRes
Handle abnormal shutdown Simulation
1. JAVA programs are constantly written to the Master
2. Disable the Slave VM.
In the JAVA program running, the Server Load balancer virtual machine is forcibly disabled. Then restart Slave.
In addition to the auto-increment ID, this table is the name field. The default value is test.
Now, on slave, change the name field to 'mysql'
Update test set;
3. Use the pt-slave-restart command to fix the error.
1594 errors found
Reconnect to the Master
Refer:
Finally, check the replication status, and it is running properly.
The names entered on the Master node are all test, and the names are changed to mysql after the Slave fault.
Generally, there are two methods (I can think of) to process primary key duplication)
1. Ignore repeated binlog events sent from the Master
2. Use the binlog event of the Master node to update the slave Data.
For the first method, the slave name should be mysql
For the second method, the first part is mysql, And the last part is test.
The test results are as follows. It can be preliminarily indicated that the second method is used.
The following 302 records with the name 'test' are all part of the data that has been executed but has not been written to the file when the system shuts down abnormally.
Pt-slave-restart re-executes the binlog of this part of data, so their name is 'test '.
-------------------------------------- Split line --------------------------------------
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
-------------------------------------- Split line --------------------------------------