If 10 of the DB within the word, their own manual ssh in, clean enough, but hundreds of Taiwan, it is necessary to write a script. General idea: In a db hop above, write a script, access the slave, remotely get the Binlog location on the copy master, and then remotely to purge master Binlog.
1, establish slave dbserver list slavelist; A slave line.
2, remotely obtain the Binlog location above slave db and Slave's master hostname (perhaps an IP address)
3, get the Binlog location and master hostname, and then ssh to remotely clean up the binlog above master
4,shell for loop operation Step 2 and step 3.
Companion script 1:clean_binlog.sh
Copy Code code as follows:
#!/bin/bash
# p1 the slave MySQL DB server
Db03=$1
Echo $dbserver;
ster_log_file= ' ssh $db mysql-uxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--s
Sl-cert=/opt/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \ "show Slave status\G;\" | Grep-i Master_log_file
"`;
# echo ##### get binlog information
Log_file= ' echo $ster _log_file | awk ' {print $} ';
db01tmp= ' ssh $db mysql-uxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--s
Sl-cert=/opt/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \ "show Slave status\G;\" | Grep-i Master_host
"`;
Copy Code code as follows:
# get Master host name or IP address
Db01= ' echo $db 01tmp | awk ' {print $} '
# Start cleaning up Binlog log information
Copy Code code as follows:
SSH $db "Mysql-uxxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--ssl-cert=/op
T/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \ "Purge master logs to ' $log _file '; \" "
# Check Master's Binlog information
Copy Code code as follows:
SSH $db "Df-h/mysql/binlog";
Copy Code code as follows:
<strong><span style= "COLOR: #ff0000" ></SPAN></STRONG>
shipped with Batch for loop Script 2:
For S in ' Cat slavelist '; do sh clean_binlog.sh $s; Done
This is a relatively rough solution, there must be some deficiencies, my 128 group is a mm combination, so this operation is possible, the structure of different estimates will be changed, here also involves purge before the Binlog backup and so on (with a dedicated backup machine and backup script).