12组nodes MySQL DB,每组2台Master-Master,批量清除过期的binlog释放磁盘空间
2013-09-23 16:22
411 查看
接到call,磁盘报警了,发现是大量dml操作导致N多binlog产生,所以需要清除已经sync过的binlog日志,12组nodes MySQL DB,每组2台Master-Master,需要批量清除过期的binlog释放磁盘空间。
方案,总共24台db,一台台进去清理肯定不行,得需要写一个脚本,进行批量操作,方案思路大概如下
1, 建立双master列表masterlist; 一个master一行。
2,远程获取master db上面的binlog位置以及对应master的master主机名(也许是ip地址)
3,拿到binlog位置以及master主机名,然后ssh远程清理掉远程master上面的binlog
4, 采用shell for循环操作step 2以及step 3。
clearbinlog.sh脚本如下
OK,run sh脚本
sh clearbinlog.sh 就可以开始清理所有db的binlog了。
最后再次check disk space,执行check_disk.sh脚本,脚本内容如下:
执行sh check_disk.sh开始check
方案,总共24台db,一台台进去清理肯定不行,得需要写一个脚本,进行批量操作,方案思路大概如下
1, 建立双master列表masterlist; 一个master一行。
2,远程获取master db上面的binlog位置以及对应master的master主机名(也许是ip地址)
3,拿到binlog位置以及master主机名,然后ssh远程清理掉远程master上面的binlog
4, 采用shell for循环操作step 2以及step 3。
clearbinlog.sh脚本如下
for masterdb in `cat master.db.full`;do #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 $2}'`; 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 $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 master ssh $db01 "df -h" echo " " echo " -- -- -- "; done;
OK,run sh脚本
sh clearbinlog.sh 就可以开始清理所有db的binlog了。
最后再次check disk space,执行check_disk.sh脚本,脚本内容如下:
for masterdb in `master.db.full`;do ssh $masterdb "df -h" |grep -i mysqldatadir; done;
执行sh check_disk.sh开始check
相关文章推荐
- 如何批量清除128组节点db上面的过期的binlog,释放磁盘空间。
- 批量清除128组节点db上面过期的binlog释放磁盘空间实现思路
- 如何批量清除128组节点db上面的过期的binlog,释放磁盘空间。(转)
- 如何批量清除128组节点db上面的过期的binlog,释放磁盘空间。
- 批量清除128组节点db上面过期的binlog释放磁盘空间实现思路
- 批量清除过期的binlog释放磁盘空间
- 清理:db上面的过期的binlog,释放磁盘空间。 (转)
- mysql dump binlog master状态
- MySQL 手动清除binlog
- mysql清除binlog
- MySQL中3种清除binlog的方法!
- mysql binlog日志清除
- mysql清除binlog (备忘)
- mysql binlog_do_db参数设置的坑
- mysql5.6设置主从报错1236,Increase max_allowed_packet on master,原因却是Binlog偏移量不对
- mysql主从同步 binlog-do-db replicate-do-db
- Mysql 批量更新操作的时候出错 “Multi-statement transaction required more than 'max_binlog_cache_size' bytes of s
- DOS 批量对多个MYSQL的DB进行更新
- MySQL自动清除binlog的参数设定
- mysql清除binlog