故障现象:
[root@node15 ~]# service mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.Logging to '/www/wdlinux/mysql-5.5.58/data/node15.err'.
.........................................................................................^C
数据库一直卡在这个页面,无法重新启动:
查看进程参数:
[root@node15 ~]# ps -ef | grep mysqld
root 2433 1 0 Feb09 ? 00:00:00 /bin/sh /www/wdlinux/mysql-5.5.58/bin/mysqld_safe --datadir=/www/wdlinux/mysql-5.5.58/data --pid-file=/www/wdlinux/mysql-5.5.58/data/localhost.localdomain.pid
mysql 3125 2433 0 Feb09 ? 02:36:59 /www/wdlinux/mysql-5.5.58/bin/mysqld --basedir=/www/wdlinux/mysql-5.5.58 --datadir=/www/wdlinux/mysql-5.5.58/data --plugin-dir=/www/wdlinux/mysql-5.5.58/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/www/wdlinux/mysql-5.5.58/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
发现:--pid-file=/www/wdlinux/mysql-5.5.58/data/localhost.localdomain.pid
这个PID的命令是通过主机名加pd来标记的,因为现在的主机名变为:
[root@node15 init.d]# hostname
node15
所以数据库在重启时,会找node15.pid文件,但这个文件是不存在的。
现在处理的方法是将localhost.localdomain.pid 复制为node15
[root@node15 data]# cp localhost.localdomain.pid node15.pid
之后再重新启动就可以了:
[root@node15 data]# service mysqld stop
Shutting down MySQL.... ERROR! The server quit without updating PID file (/www/wdlinux/mysql-5.5.58/data/node15.pid).
[root@node15 data]# ps -ef | grep mysqld
root 32476 32360 0 10:16 pts/3 00:00:00 vim mysqld
root 32833 31643 0 10:25 pts/2 00:00:00 grep mysqld
[root@node15 data]# service mysqld start
Starting MySQL SUCCESS!
[root@node15 data]# ps -ef | grep mysqld
root 32476 32360 0 10:16 pts/3 00:00:00 vim mysqld
root 32856 1 2 10:25 pts/2 00:00:00 /bin/sh /www/wdlinux/mysql-5.5.58/bin/mysqld_safe --datadir=/www/wdlinux/mysql-5.5.58/data --pid-file=/www/wdlinux/mysql-5.5.58/data/node15.pid
mysql 33440 32856 21 10:25 pts/2 00:00:01 /www/wdlinux/mysql-5.5.58/bin/mysqld --basedir=/www/wdlinux/mysql-5.5.58 --datadir=/www/wdlinux/mysql-5.5.58/data --plugin-dir=/www/wdlinux/mysql-5.5.58/lib/plugin --user=mysql --log-error=node15.err --pid-file=/www/wdlinux/mysql-5.5.58/data/node15.pid --socket=/tmp/mysql.sock --port=3306
root 33459 31643 0 10:25 pts/2 00:00:00 grep mysqld