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. 初学React:定义一个组件

    接着聊React,今天说说如何创建一个组件类. <!DOCTYPE html> <html lang="en"> <head> <meta ...

  2. 【BZOJ4025】二分图(LCT动态维护图连通性)

    点此看题面 大致题意: 给你一张图以及每条边的出现时间和消失时间,让你求每个时间段这张图是否是二分图. 二分图性质 二分图有一个比较简单的性质,即二分图中不存在奇环. 于是题目就变成了:让你求每个时间 ...

  3. hiho 第135周 九宫

    题目链接:http://hihocoder.com/contest/hiho135/problem/1 由于是九宫格,全排列也就是9! (362880)种方式,我就直接暴力枚举排列好了. #inclu ...

  4. Codeforces 760A Petr and a calendar

    题目链接:http://codeforces.com/problemset/problem/760/A 题意:日历需要多少列. #include <bits/stdc++.h> using ...

  5. 深搜,四色定理,(POJ1129)

    题目链接:http://poj.org/problem?id=1129 解题报告: #include<iostream> #include<cstdio> #include&l ...

  6. P1316 丢瓶盖

    题目描述 陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢? 输入输出 ...

  7. mysql常用命令添加外键主键约束存储过程索引

    数据库连接 mysql -u root -p123456 查看表 show databases 创建数据库设置编码 create table books character set utf8; 创建用 ...

  8. apache单ip配置多端口多站点

    1.修改 /etc/httpd/conf/httpd.conf 添加一个Listen,如: Listen 80 Listen 8001 Listen 8002 2.添加一个VirtualHost #v ...

  9. centos开启rewrite功能

    首先找到 /etc/httpd/conf/httpd.conf 文件,然后修改以下两个地方: 1.取消下面一句的注释 LoadModule rewrite_module modules/mod_rew ...

  10. 项目部署到自己的IIS上

    一般我们只能在本机上才可以开到我们的项目,这个是不需要连网的 如果想让我们的项目在网站中打开,别人也可以看到,就需要把我们的项目部署到服务器上了,输入IP就可以看到我们的项目 发布项目 然后发布网站 ...