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. 正交矩阵、正规矩阵和酉矩阵(转自Ramble Over The Cloud~)

    网址:http://blog.csdn.net/alec1987/article/details/7414450 在数学中,正规矩阵 是与自己的共轭转置交换的复系数方块矩阵,也就是说, 满足 其中 是 ...

  2. IOS NSURLConnection(大文件下载)

    NSURL:请求地址 NSURLRequest:一个NSURLRequest对象就代表一个请求,它包含的信息有 一个NSURL对象 请求方法.请求头.请求体 请求超时 … … NSMutableURL ...

  3. 【BZOJ5084】hashit(后缀自动机水过)

    点此看题面 大致题意: 每次在字符串后面加入或删除一个字符,求本质不同的子串个数. 后缀自动机 先说明,此题后缀自动机的确能过. 但我的后缀自动机比较弱,遇上一个较强的\(Hack\)数据就被卡掉了. ...

  4. 将xml转换成Json,数组,对象格式转换方法

    xml字符串:$simplexml 转换成Json格式:json_encode($simplexml) 转换成数组格式:json_decode(json_encode($simplexml),TRUE ...

  5. 卷积神经网络CNN理解

    自今年七月份以来,一直在实验室负责卷积神经网络(Convolutional Neural Network,CNN),期间配置和使用过theano和cuda-convnet.cuda-convnet2. ...

  6. cudpp库的编译和使用

    项目主页 http://cudpp.github.io/ 根据这个网址的提示进行 https://github.com/cudpp/cudpp/wiki/BuildingCUDPPwithCMake ...

  7. 旋度定理(Curl Theorem)和散度定理(Divergence theorem)

    原文链接 首先说说格林公式(Green's theorem).对于一段封闭曲线,若其围城的区域D为单连通区域(内部任意曲线围城的区域都属于院区域),则有如下公式: 其中其中L为D的边界,取正方向.如果 ...

  8. 最近的阅读list

    fast rcnn 统一了sppnet和rcnn,将原来rcnn分stage的训练合为一个整体的stage,一次完成cls, regression的训练.引入两个loss函数,一个是用来进行cls的, ...

  9. 关于package.json学习

    1.如果要下载npm包,必须有package.json文件,不然会报错,如果缺少必要字符报错,参考报错信息 2.license,指定用户权限,可以不写,不会报错 3.devDependencies,依 ...

  10. 时间复杂度 log n

    时间复杂度 O(log n) 意味着什么? 预先知道算法的复杂度是一回事,了解其后的原理是另一件事情. 不管你是计算机科班出身还是想有效解决最优化问题,如果想要用自己的知识解决实际问题,你都必须理解时 ...