Solution: a total of 24 databases, and one database cannot be cleaned up. You need to write a script to Perform Batch operations. The solution is roughly as follows:
1,Creates a master list with one master row.
2,Remotely obtain the binlog location on the master database and the master Host Name (maybe IP address) of the corresponding master)
3,Obtain the binlog location and master host name, and then remotely clear the binlog on the remote master using ssh.
4,Shell for loop operations step 2 and step 3.
for masterdb in `cat master.db.full`;do#1 echo get the binlog position infomationstr_log_files=`ssh $masterdb "/opt/mysql/product/5.5.25a/bin/mysql -uroot --password="" -e \"show slave status\G;\" |grep -i master_Log_File "`echo $str_log_files;log_file=`echo $str_log_files | awk '{print $2}'`; echo $log_file;#2 echo get the master ip address or master hostnamedb01tmp=`ssh $masterdb " /opt/mysql/product/5.5.25a/bin/mysql -uroot --password="" -e \"show slave status\G;\" |grep -i Master_Host "`; db01=`echo $db01tmp | awk '{print $2}'`#3 begin to clear the old binlog ssh $db01 "/opt/mysql/product/5.5.25a/bin/mysql -uroot --password="" -e \"purge master logs to '$log_file';\""#4 check the disk space for masterssh $db01 "df -h"echo " "echo " -- -- -- ";done;
OK, run sh script
Check disk space again and run the check_disk.sh script. The script content is as follows:
for masterdb in `master.db.full`;do ssh $masterdb "df -h" |grep -i mysqldatadir;done;