故障背景,多实例在运行一段时间后,有天启动机器后,检查发现两个实例都没启动
1、检查实例是否启动:
[root@mysql-slave ~]# netstat -ntulp | grep 330 没任何输出
[root@mysql-slave ~]# ps -aux | grep mysqld mysqld进程没启动
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 2544 0.0 0.0 103252 832 pts/0 S+ 18:08 0:00 grep mysqld
2、手工启动试试
[root@mysql-slave ~]# /db/3306/mysqld start 提示mysql已经正在运行(这不扯淡吗!!!)
MySQL is running...
3、解决方法
[root@mysql-slave ~]# rm -rf /db/3306/tmp/mysql.sock 删除mysql.sock和mysql.pid文件
[root@mysql-slave ~]# rm -rf /db/3306/*.pid
[root@mysql-slave ~]# rm -rf /db/3307/tmp/mysql.sock
[root@mysql-slave ~]# rm -rf /db/3307/*.pid
4、再次尝试启动
[root@mysql-slave ~]# /db/3306/mysqld start
Starting MySQL...
[root@mysql-slave ~]# /db/3307/mysqld start
Starting MySQL...
[root@mysql-slave ~]# netstat -ntulp | grep 330 启动成功
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3253/mysqld
tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 3956/mysqld
[root@mysql-slave ~]# mysql -uroot -pq.1234 -S /db/3306/tmp/mysql.sock 欧了!!!
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.37-log Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
总结:这种情况,可能是非正常关闭mysql造成的,所以,管好机器,养成良好维护习惯!!