問題現象:
[root@mysql-ncss-i-mysql-ha-1 mysql]# mysql -uroot -pnsfocus
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.7.25 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: mysql-ncss-i-mysql-ha-0.mysql
Master_User: root
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 41944286
Relay_Log_File: mysql-ncss-i-mysql-ha-1-relay-bin.000002
Relay_Log_Pos: 41944452
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
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: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 41944286
Relay_Log_Space: 41944677
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
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: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'bogus data in log event; the first event 'mysql-bin.000001' at 154, the last event read from './mysql-bin.000001' at 41944286, the last byte read from './mysql-bin.000001' at 41944305.'
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 100
Master_UUID: 22fbf4f1-a22e-11e9-9ce8-82c0d16debf7
Master_Info_File: /usr/local/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 190709 13:33:40
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
解決方法:
https://www.percona.com/forums/questions-discussions/47015-multiple-slaves-error-bogus-data-in-log-event
https://www.linuxidc.com/Linux/2017-09/146671.htm
https://www.percona.com/blog/2013/09/13/enabling-crash-safe-slaves-with-mysql-5-6/
1、innodb_flush_log_at_trx_commit & sync_binlog set to 1 on master
2、Stop MySQL on slave
3、Add relay_log_info_repository = TABLE and relay_log_recovery = ON in my.cnf
4、Restart MySQL and relax