标签:日常
一、故障现象
使用脚本:
#!/bin/bash declare -a arr arr=($(echo "show slave status\G" | /usr/local/mysql/bin/mysql -uroot -pDdFour_123 | grep -E ‘Running|Error‘ | awk ‘{print $2}‘)) if [ ${arr[0]} == ‘No‘ -o ${arr[1]} == ‘No‘ ] ;then zabbix_sender -z 172.16.200.46 -p 10051 -s dd4_mysql_slave -k mysql_slave -o "Error:${arr[2]}" &> /dev/null else zabbix_sender -z 172.16.200.46 -p 10051 -s dd4_mysql_slave -k mysql_slave -o "ok" &> /dev/null fi
向zabbix发送告警信息:结果zabbix一直不断告警
查看MySQL从库 error.log
151224 12:28:48 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log ‘mysql-bin.000110‘ at position 33780541
151224 12:28:49 [Note] Slave: received end packet from server, apparent master shutdown:
151224 12:28:49 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log ‘mysql-bin.000110‘ at position 33780541
151224 12:28:49 [Note] Slave: received end packet from server, apparent master shutdown:
151224 12:28:49 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log ‘mysql-bin.000110‘ at position 33781835
出现大量错误信息:首先想到的是重新start slave;会出现
Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND;?
Could not execute Update_rows event on table dd4.dd4_sessions;
等一大堆I/O NO 或 sql NO
最终是停掉slave:重新导入数据使 数据同步重新 start slave
还是会报一些错误,最后怀疑是主库出了问题 :
在 master 数据库:连接上去查看 发现 too many connections mysql 导致网站无法打开,只能重启数据库
mysql> show processlist; 查看数据库连接 http://blog.csdn.net/starnight_cbj/article/details/4492555
#mysql> kill `id`; 杀死异常连接进程
通过查看主数据库状态信息,发现中午拷贝了一台从库服务器,并开启了MySQL(MySQL默认开机启动复制线程),在不停dump bin.log
关闭MySQL vim /etc/my.cnf [ mysqld ] skip-slave-start 再启动MySQL
重新恢复MySQL-SLAVE:Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; 还是报错通过日志分析发现是数据库保存了 用户session会一直变动,在my.cnf里面,设置slave-skip-errors=1032 然后从新启动mysql数据库
为不影响主库业务。再找维护时间做数据同步
标签:日常
原文地址:http://hjt353.blog.51cto.com/8636273/1727974