12组nodes MySQL DB,每组2台Master-Master,批量清除过期的binlog释放磁盘空间
来源:互联网 发布:linux 复制覆盖文件 编辑:程序博客网 时间:2024/06/10 15:27
接到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脚本如下
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脚本
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
- 12组nodes MySQL DB,每组2台Master-Master,批量清除过期的binlog释放磁盘空间
- 12组nodes MySQL DB,每组2台Master-Master,批量清除过期的binlog释放磁盘空间
- 如何批量清除128组节点db上面的过期的binlog,释放磁盘空间。
- mysql清除binlog二进制日志的最简单办法reset master
- mysql dump binlog master状态
- 清理300多台MySQL数据库的过期binlog日志
- 清理300多台MySQL数据库的过期binlog日志
- 关于mysql binlog过期失效的问题
- 清理MySQL数据库的过期binlog日志
- 关于mysql master-slave模式DB服务器的问题发生与解决
- mysql的master-slave模式
- Mysql Master/Slave的配置
- MySQL binlog-ignore-db
- MySQL Master-Master Replication Manager
- MySQL 互备份master-master
- Mysql Master-Master Replication Manager
- MySQL master-master replication configuration
- MySQL之Master-Master配置
- Java中四种引用(强、软、弱、虚)
- Linux shell编程 3 ---- shell中的判断
- ZOJ:2913 Bus Pass
- 消息队列RabbitMQ和ActiveMQ的生产者流量控制
- 使用wait()与notify()改写上面的例子
- 12组nodes MySQL DB,每组2台Master-Master,批量清除过期的binlog释放磁盘空间
- android软件创建快捷方式
- fedora centos,ubuntu关于进程资源限制的问题
- 简单的内存池分析
- 加入header的自定义GridView
- Apache——Rewrite重写规则
- 大数据量,海量数据 处理方法总结
- 2013 ACM/ICPC 长沙网络赛B题解题报告
- Cocos2d-x学习之搭建coocs2d-x2.1.5并编译到android和ios