program, a total of 24 db, a set to go in clean-up certainly not, you need to write a script, to do batch operations, the scenario is probably the following ideas
1, set up double master list masterlist; a master row.
2, remotely obtain the Binlog location above the master DB and the master hostname (perhaps IP address) corresponding to master
3, get the Binlog location and master hostname, then ssh remotely clean off the remote master above the Binlog
4, use shell for loop operation Step 2 and step 3.
The clearbinlog.sh script is as follows
[Python]View Plaincopy print?
- For Masterdb in ' cat master.db.full ';d o
- #1 Echo Get the binlog position infomation
- str_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 $} ';
- echo $log _file;
- #2 Echo Get the master IP address or master hostname
- db01tmp= ' ssh $masterdb "/opt/mysql/product/5.5.25a/bin/mysql-uroot--password=""-e \" show Slave status\g;\ " |grep-i master_host "';
- Db01= ' echo $db 01tmp | awk ' {print $} '
- #3 begin to clear the old Binlog
- SSH $db "/opt/mysql/product/5.5.25a/bin/mysql-uroot--password=""-e \" Purge master logs to ' $log _file '; \ ""
- #4 Check the disk space for master
- SSH $db "Df-h"
- echo ""
- echo "------";
- Done
Ok,run SH Script
SH clearbinlog.sh can start cleaning up all db binlog.
Finally, check disk space again and execute the check_disk.sh script with the following script:
[HTML]View Plaincopy print?
- For Masterdb in ' Master.db.full ';d o
- SSH $masterdb "df-h" |grep-i mysqldatadir;
- Done
Execute SH check_disk.sh start check
Bulk purge of expired Binlog free disk space