After the mysql master-slave settings, if the operation is improper, the data on server B of server A will be automatically deleted simultaneously. If the deletion is wrong, it means that you have not backed up the database, the following section describes how to safely delete the binary log of mysql master-slave replication. For more information, see.
Method
// Before deleting logs, check the log files currently used by the master and slave servers,
// Log on to the mysql terminal of the server to delete the log
# Mysql-u root-pxxxxx
// Check the status of the replication master server
Mysql> show master status
+ ------------------ + ----------- + -------------- + ---------------------------------------- +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+ ------------------ + ----------- + -------------- + ---------------------------------------- +
| Mysql-bin.000097 | 541677824 | www | test, mysql, information_schema |
+ ------------------ + ----------- + -------------- + ---------------------------------------- +
// Copy the log file that the master server is currently using: mysql-bin.000097
// Check the replication slave server status
Mysql> show slave statusG
* *************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 202.102.152.3
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000103
Read_Master_Log_Pos: 675107897
Relay_Log_File: www-relay-bin.000443
Relay_Log_Pos: 675097929
Relay_Master_Log_File: mysql-bin.000103
Slave_IO_Running: Yes
Slave_ SQL _Running: Yes
Replicate_Do_DB: www
Replicate_Ignore_DB: test, mysql, information_schema
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: 675107897
Relay_Log_Space: 675098125
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_ SQL _Errno: 0
Last_ SQL _Error:
// The replication master server log file that is being used by the replication slave server is: mysql-bin.000103
// The currently used log file is 000097. What I need to do is to delete all logs before 00095 (Reserved logs for the past few days)
Mysql> purge master logs to 'mysql-bin.000095;
# Ll/usr/local/mysql/var/
// The result shows that all logs before 000097 have been deleted.
// If there are other servers that need to clean up the logs, repeat the above Order.