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. MySQL入门很简单: 15 java访问MySQL数据库

    1. 连接数据库 1.1 下载安装驱动 java通过JDBC(Java Database Connectivity,Java数据库连接)来访问MySQL数据库.JDBC的编程接口提供的接口和类与MyS ...

  2. php通过gbk编码判断 含有连续数字 可用于判断QQ号,手机号等。

    有可能有些输入,不希望让用户的评论或者私信中含有类似于QQ号,手机号的文本,比如交友网站.还有些恶意SEO通过,构造恶意检索词,检索词中包含QQ,手机号等,让百度爬取到,增加展现.也需要将这些检索词屏 ...

  3. IOS 弹框AlterView的使用(IOS8.0以前使用)UIAlertController(IOS9.0使用)

    #pragma mark - 代理方法 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath ...

  4. POJ-3187 Backward Digit Sums---枚举全排列

    题目链接: https://vjudge.net/problem/POJ-3187 题目大意: 输入n,sum,求1~n的数,如何排列之后,相邻两列相加,直到得出最后的结果等于sum,输出1~n的排列 ...

  5. Thread 创建线程

    1.该线程变量 无参数 我们可以把线程的变量 理解为一个 委托.可以指向一个方法.有点像c语言中的指向函数的指针. 第1步我们创建了 Thread变量t1 ,第2步创建了一个方法threadChild ...

  6. Java 压缩文件夹工具类(包含解压)

    依赖jar <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons ...

  7. python读取mat文件

    一.mat文件 mat数据格式是Matlab的数据存储的标准格式.在Matlab中主要使用load()函数导入一个mat文件,使用save()函数保存一个mat文件.对于文件 load('data.m ...

  8. babel 不能统编译Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise的问题

    Babel默认只转换新的JavaScript句法(syntax),而不转换新的API,比如Iterator.Generator.Set.Maps.Proxy.Reflect.Symbol.Promis ...

  9. 返回固定页面的web服务器

    import socket def handle_client(socket_con): """ 接收来自客户端的请求,并接收请求报文,解析,返回 "" ...

  10. (二)活用ComponentScan

    项目改造成spring cloud项目后,有非常多组件是复用的,比如(一)敏感信息混淆的组件,比如数据库.Redis等配置, 比如常用的api组件Swagger配置.每个微服务组件里都会有若干个组件随 ...