日期:2014-05-16 浏览次数:20422 次
[xxx@xxxx cacti]$ ssh xxxx "df -h" /dev/mapper/Sys-mysqldata 300G 270G 30G 90% /mysqldata 15G 166M 14G 2% /mysqldata/binlog
[xxx@xxxx cacti]$ ssh xxxx " sudo -u mysql ls /mysqldata/data/" |grep mysql-bin mysql-bin.001350 ....... mysql-bin.002352 mysql-bin.log.index
for i in `cat server03list`; do #循环遍历db列表 # 1 获取数据库的master binlog名称,并在控制台打印出当前执行的db名称 echo $i; binlog=`ssh $i " /opt/mysql/product/5.5.25a/bin/mysql -uxxxx -ppassword --ssl-ca=/ssl/ca-cert.pem --ssl-cert=/ssl/server-cert.pem --ssl-key=/ssl/server-key.pem -e \" show master status;\" "|grep mysql-bin |awk '{print $1}'`; echo $binlog; # 2 开始执行binlog purge清理操作。 ssh $i " /opt/mysql/product/5.5.25a/bin/mysql -uxxxx -ppassword --ssl-ca=/ssl/ca-cert.pem --ssl-cert=/ssl/server-cert.pem --ssl-key=/ssl/server-key.pem -e \" purge master logs to '$binlog';\" " # 3 check清理完的磁盘空间。 ssh $i "df -h" |grep mysqldata; # 4 输入空行分隔 echo ""; echo ""; echo ""; done;