Preface
 
    Sometimes,the threads(especially the SQL_Thread) will be terminated by accident.The slave will stop until we fix the relevant error or just skip them.There's many methods we can use to solve these kind of issues.For example,we can set "sql_salve_skip_counter" in mysql client and we can set "slave_skip_errors" in my.cnf as well(static parameter,need to restart mysqld).Further more,set "slave_exec_mode=idempotent" may also be useful.It can skip the "duplicate-key" or "no-key-found" errors.It means that we don't need to pay more attention to error 1062 and 1032 any more if we do so.Is there any other method can solve these skipping error issues?Surely there is one.
 
Introduce
 
    pt-slave-restart is the one who can skip specific errors and restart the slave automatically.But considering of the consistency of data,we'd better do think twice when skipping errors by it.There're two test below.Let's see how the pt-slave-restart works.
 
Procedure
 
Usage
 pt-slave-restart [OPTIONS] [DSN]
Common parameter
 --always //Start slaves if there's no error,it will prevent to you stop slave manully.
--check-relay-log //Check the relay log file before checking errors on slave.
--error-length //Specify the max length to print.
--error-number //Specify the number of errors you want to make the slave try to restart.
--error-text //Specify the text of errors you want to make the slave try to restart.
--max-sleep //Specify the maximum sleep time after it polling the slave.
--min-sleep //Specify the minimum sleep time after it polling the slave.
--monitor //whether to monitor the slave(default)
--master-uuid //Specify the master-uuid you want to skip,if you have multiple writing node.
--recurse //If you want to execute pt-slave-restart on master.It's dispensable option.
--recurse-method //This option is used together with "--recurse".It specify the method to find slaves.
--sleep //Specify the interval of sleep time in checking the slave.
--until-master //run until this master logfile,position then exit.
--until-relay //run until this relay logfile,position then exit.
Example
 
1.Test of automatically restart slave.
 
Execute pt-slave-restart with "--always".
 [root@zlm1 :: ~]
#pt-slave-restart --recurse= --always -h192.168.56. -P3306 -urepl -prepl4slave
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/bin/pt-slave-restart line .
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/bin/pt-slave-restart line . # A software update is available:
--21T12:: P=,h=192.168.56.101,p=...,u=repl relay-bin. //It has begun to monitor the slave to automatically startup.
Check whether the slave replication is normal.
 zlm@192.168.56.101: [(none)]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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:
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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)
Stop slave replication.
 zlm@192.168.56.101: [(none)]>stop slave;
Query OK, rows affected (0.03 sec) zlm@192.168.56.101: [(none)]>show slave status\G
*************************** . row ***************************
Slave_IO_State:
Master_Host: 192.168.56.100
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: No //IO_Thread has stopped.
Slave_SQL_Running: No //SQL_Thread has stopped.
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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) //Wait for a while and check it again. zlm@192.168.56.101: [(none)]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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 //IO_Thread has started again.
Slave_SQL_Running: Yes //SQL_Thread has started again.
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:
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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)
The output is added one line which shows the connection status of slave on master.
 # A software update is available:
--21T12:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
--21T12:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
Check the general log of slave to see the details.
 [root@zlm2 :: /data/mysql/mysql3306/data]
#tail -f zlm2.log
mysqld, Version: 5.7.-log (MySQL Community Server (GPL)). started with:
Tcp port: Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
--21T10::.049221Z Query stop slave
--21T10::.598248Z Query show slave status
--21T10::.080665Z Query SHOW SLAVE STATUS
--21T10::.081848Z Query START SLAVE
--21T10::.084221Z Connect Out repl@192.168.56.100:
--21T10::.086327Z Query SHOW SLAVE STATUS
--21T10::.570310Z Quit
--21T10::.782934Z Connect zlm@zlm2 on using TCP/IP
--21T10::.784208Z Query select @@version_comment limit
--21T10::.785102Z Query select USER()
--21T10::.440909Z Query show slave status
--21T10::.535233Z Query show slave status
--21T10::.087271Z Query SHOW SLAVE STATUS
...
2.Test of skipping error of  replication.
 
Do some operations on master.
 zlm@192.168.56.100: [zlm]>show tables;
+---------------+
| Tables_in_zlm |
+---------------+
| test_gbk |
| test_utf8 |
| test_utf8mb4 |
+---------------+
rows in set (0.00 sec) zlm@192.168.56.100: [zlm]>drop table test_gbk,test_utf8,test_utf8mb4;
Query OK, rows affected (0.04 sec) zlm@192.168.56.100: [zlm]>show tables;
Empty set (0.00 sec) zlm@192.168.56.100: [zlm]>create table test(
-> id int,
-> name varchar()
-> ) engine=innodb;
Query OK, rows affected (0.03 sec) zlm@192.168.56.100: [zlm]>alter table test add primary key(id);
Query OK, rows affected (0.01 sec)
Records: Duplicates: Warnings: zlm@192.168.56.100: [zlm]>alter table test modify column id int unsigned not null auto_increment;
Query OK, rows affected (0.02 sec)
Records: Duplicates: Warnings: zlm@192.168.56.100: [zlm]>show create table test\G
*************************** . row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int() unsigned NOT NULL AUTO_INCREMENT,
`name` varchar() DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>insert into test values(,'zlm');
Query OK, row affected (0.00 sec) zlm@192.168.56.100: [zlm]>select * from test;
+----+------+
| id | name |
+----+------+
| | zlm |
+----+------+
row in set (0.00 sec)
Check the slave status on slave.
 zlm@192.168.56.101: [zlm]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error: Error 'Unknown table 'zlm.test_gbk,zlm.test_utf8,zlm.test_utf8mb4'' on query. Default database: 'zlm'. Query: 'DROP TABLE `test_gbk`,`test_utf8`,`test_utf8mb4` /* generated by server */'
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: Error 'Unknown table 'zlm.test_gbk,zlm.test_utf8,zlm.test_utf8mb4'' on query. Default database: 'zlm'. Query: 'DROP TABLE `test_gbk`,`test_utf8`,`test_utf8mb4` /* generated by server */'
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) zlm@192.168.56.101: [zlm]>show tables;
+----------------+
| Tables_in_zlm |
+----------------+
| semi_sync_test |
| t1 |
| t2 |
| t3 |
| test |
| test_flashbk |
+----------------+
rows in set (0.00 sec) //There're no target tables at all.So error 1051 occurs.
Try to skip the error 1051 on master.
 
 [root@zlm1 :: ~]
#pt-slave-restart --recurse= --error-number= -h192.168.56. -P3306 -urepl -prepl4slave
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
Error is not in --error-numbers. //error 1050 occurs then.
Check replicaiton slave status again.
 zlm@192.168.56.101: [zlm]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error: Error 'Table 'test' already exists' on query. Default database: 'zlm'. Query: 'create table test(
id int,
name varchar()
) engine=innodb'
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: Error 'Table 'test' already exists' on query. Default database: 'zlm'. Query: 'create table test(
id int,
name varchar()
) engine=innodb'
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)
Continue to skip error 1050 on master.
 [root@zlm1 :: ~]
#pt-slave-restart --recurse= --error-number= -h192.168.56. -P3306 -urepl -prepl4slave
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
Error is not in --error-numbers.
Check the slave status one more time.
 zlm@192.168.56.101: [zlm]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error: Error 'Multiple primary key defined' on query. Default database: 'zlm'. Query: 'alter table test add primary key(id)'
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: Error 'Multiple primary key defined' on query. Default database: 'zlm'. Query: 'alter table test add primary key(id)'
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) zlm@192.168.56.101: [zlm]>show create table test\G
*************************** . row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` bigint() NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
PRIMARY KEY (`id`) //The table "test" had been added primary key what hit the error.
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8mb4
row in set (0.00 sec)
Continue to skip error 1068 on master.
 [root@zlm1 :: ~]
#pt-slave-restart --recurse= --error-number= -h192.168.56. -P3306 -urepl -prepl4slave
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin.
Error is not in --error-numbers.
Check the slave status the fourth times.
 zlm@192.168.56.101: [zlm]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error: Column of table 'zlm.test' cannot be converted from type 'varchar(30(bytes))' to type 'varchar(80(bytes) utf8mb4)'
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: Column of table 'zlm.test' cannot be converted from type 'varchar(30(bytes))' to type 'varchar(80(bytes) utf8mb4)'
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec) //Table "test" on master is utf8 menas its column varchar(10) contain 30 bytes
//Table "test" on slave is utf8mb4 means its column varchar(20) contain 80 bytes.
//They cannot be converted.Thus the error 1677 occurs.
Continue to skip error 1677 on master.
 [root@zlm1 :: ~]
#pt-slave-restart --recurse= --error-number= -h192.168.56. -P3306 -urepl -prepl4slave
--21T13:: P=,h=192.168.56.101,p=...,u=repl relay-bin. //No more error appears anymore.
Check the slave status the fifth times.
 zlm@192.168.56.101: [zlm]>show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.100
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 //The SQL_Thread is normal now.No errors found.
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:
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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e
Master_Info_File: /data/mysql/mysql3306/data/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: 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Executed_Gtid_Set: 27af30ca--11e8-ad7e-080027de0e0e:,
2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.01 sec) //Util now,we've skipped all the errors dynamically.But it doesn't guarantee the consistency of table "test" at all.
See what will happen on test of slave.
 zlm@192.168.56.101: [zlm]>show create table test\G
*************************** . row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int() unsigned NOT NULL AUTO_INCREMENT,
`name` varchar() NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= DEFAULT CHARSET=utf8mb4
row in set (0.00 sec) zlm@192.168.56.101: [zlm]>select count(*) from test;
+----------+
| count(*) |
+----------+
| |
+----------+
row in set (0.02 sec) //No change happened.
Summary
  • pt-slave-restart is tool use to avoid slave replication terminated accidentally due to different errors.
  • On account of "skip-slave-errors" is a static parameter,pt-slave-restart is more convenient to skip errors dynamically.
  • Unless you know the influence or consequences of the skipping operation.Don't skip any errors automatically.It's not safe to keep data consistency.
  • It's not recommended to use parameter "--aways",factitiously check and restart is more reliable.
 

Percona-Tookit工具包之pt-slave-restart的更多相关文章

  1. 关于 percona monitoring plugins插件报slave is stoped on ip地址

    思路:肯定是某个item触发了触发器 去看触发器,找到 slave is stoped,如下图 看到键是mysql.running-slave ,然后去定义key的文件中查看该键对应的脚本,修改脚本. ...

  2. Linux后台开发工具箱

    https://files-cdn.cnblogs.com/files/aquester/Linux后台开发工具箱.pdf 目录 目录 1 1. 前言 3 2. 脚本类工具 3 2.1. sed命令- ...

  3. Mysql: pt-table-checksum 和 pt-table-sync 检查主从一致性,实验过程

    一.安装 percona 包 1.安装仓库的包 https://www.percona.com/doc/percona-repo-config/yum-repo.html sudo yum insta ...

  4. Linux后台开发工具箱-葵花宝典

    Linux后台开发工具箱-葵花宝典 一见 2016/11/4 目录 目录 1 1. 前言 4 2. 脚本类工具 4 2.1. 双引号和单引号 4 2.2. 取脚本完整文件路径 5 2.3. 环境变量和 ...

  5. 推荐几款MySQL相关工具

    前言: 随着互联网技术的不断发展, MySQL 相关生态也越来越完善,越来越多的工具涌现出来.一些公司或个人纷纷开源出一些不错的工具,本篇文章主要介绍几款 MySQL 相关实用工具.提醒下,这里并不介 ...

  6. TokuDB存储引擎

    TokuDB是Tokutek公司开发的基于ft-index(Fractal Tree Index)键值对的存储引擎. 它使用索引加快查询速度,具有高扩展性,并支持hot scheme modifica ...

  7. [知识库分享系列] 二、.NET(ASP.NET)

    最近时间又有了新的想法,当我用新的眼光在整理一些很老的知识库时,发现很多东西都已经过时,或者是很基础很零碎的知识点.如果分享出去大家不看倒好,更担心的是会误人子弟,但为了保证此系列的完整,还是选择分享 ...

  8. Docker私有仓库1

    一.搭建私有仓库 #环境 Ip 192.168.0.34 X86云主机 [root@lh- /]# uname -a Linux lh- -.el7.x86_64 # SMP Thu Mar :: U ...

  9. etcd安装和所遇到的坑

    首先参照 https://www.cnblogs.com/lyzw/p/6016789.html来安装 虚拟机:VMware® Workstation 12 Pro 系统:CentOS Linux r ...

  10. SQL慢查询安装过程

    SQL慢查询 基本操作 打开防火墙 firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload 安 ...

随机推荐

  1. express不是内部命令

    有时用npm install express -g安装完express时,在写express -v会显示express不是内部命令 这样的话如果自己的安装没有问题的话就要考虑到环境变量了 win7 P ...

  2. ZOJ - 2112 Dynamic Rankings(BIT套主席树)

    纠结了好久的一道题,以前是用线段树套平衡树二分做的,感觉时间复杂度和分块差不多了... 终于用BIT套函数式线段树了过了,120ms就是快,此题主要是卡内存. 假设离散后有ns个不同的值,递归层数是l ...

  3. 1.3配置存储单元(nbu重删池)

    1.3配置存储单元 在备份或归档操作时,NetBackup将数据通过存储单元写到物理介质上,NetBackup支持三种类型的存储单元.即: 介质管理器.磁盘和NDMP. 1.3.1介质管理存储单元配置 ...

  4. iOS 有些库只能在真机上运行,不能在模拟器上运行的解决方式

    在开发中,多少肯定会用到第三方的东西,或许大家也和我一样遇到到这样的情况,有些库正好适合自己的需求,但是这个库却只支持真机上运行,在模拟器上编译却不通过, 一般情况下,.a静态包,你刚刚导入的时候,不 ...

  5. 20145238-荆玉茗 《Java程序设计》第五次实验报告

    实验五 Java网络编程及安全 一.实验内容 1.运行下载的TCP代码,结对进行,一人服务器,一人客户端: 2.利用加解密代码包,编译运行代码,一人加密,一人解密: 3.集成代码,一人加密后通过TCP ...

  6. node.js 练习3 调用函数

    (1)创建n3-1.js,并输入代码 (2)创建User.js ,并输入代码 (3)运行cmd (4)在浏览器上查看 (5) 再次查看cmd

  7. ipython notebook的使用

    刚开始使用python,用的是ipython notebook,感觉很好用. 写的程序主要是处理文件的,读写txt文件,生成xml文件,其中参考http://www.cnblogs.com/wangs ...

  8. Linux赋予普通用户root权限

    本文以新建用户admin来举例,请自行替换自己需要的用户 方法一: vi编辑 /etc/sudoers 文件,找到 root    ALL=(ALL)     ALL,在下面添加一行,如下所示: ## ...

  9. 如何将一个div水平垂直居中

    方案一: div绝对定位水平垂直居中[margin:auto实现绝对定位元素的居中], 兼容性:,IE7及之前版本不支持 div{ width: 200px; height: 200px; backg ...

  10. 基于asp.net MVC 的服务器和客户端的交互(一)

    架构思想 三层架构 提出了一种基于ASP.NET开发方式的三层架构的Web应用系统构造思想.其基本内容是:将面向对象的UML建模与Web应用系统开发 相结合,将整个系统分成适合ASP.NET开发方式的 ...