柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!
全部博文(1669)
分类: Mysql/postgreSQL
2011-12-26 10:12:20
昨天启动MySQL时,就不太正常,要多重启几次,不过能启动,也就没放在心上,今天测试测试又出现了问题,MySQL 启动正常,但是无法关闭:
[root@rac2 mysql]# service mysql stop
MySQL server PID file could not befound! [FAILED]
[root@rac2 mysql]# ./mysql.server stop
MySQL server PID file could not befound! [FAILED]
这里提示的PID 文件指:/var/lib/mysql/rac2.pid,该文件和/var/lib/mysql/mysql.sock 文件一样,仅在MySQL 运行时存在,后来的验证如下:
[root@rac2 lib]# ls /var/lib/mysql/rac2.pid
/var/lib/mysql/rac2.pid
[root@rac2 lib]# service mysql stop
Shutting down MySQL. [ OK ]
[root@rac2 lib]# ls /var/lib/mysql/rac2.pid
ls: /var/lib/mysql/rac2.pid: No such fileor directory
所以当我的MySQL 运行正常时,应该是存在这个文件的,google的一个说法是my.cnf 参数文件的basedir 参数错误,注释掉这个参数即可,但是我都没有设过这个参数,所以和这个应该没有关系。
查看了一下默认值:
mysql> show variables like '%basedir%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| basedir | /usr |
+---------------+-------+
1 row in set (0.00 sec)
[root@rac2 ~]# ps -ef|grep mysql
root 2161 1 0 09:38 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rac2.pid
mysql 2418 2161 0 09:38 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/lib/mysql/rac2.err --pid-file=/var/lib/mysql/rac2.pid--socket=/var/lib/mysql/mysql.sock --port=3306
root 3628 3596 0 09:57 pts/1 00:00:00 grep mysql
--log信息
[root@rac2 ~]#cat /var/lib/mysql/rac2.err
111129 9:38:49 [Note] Plugin 'FEDERATED' is disabled.
111129 9:38:49 InnoDB: The InnoDB memory heap is disabled
111129 9:38:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
111129 9:38:49 InnoDB: Compressed tables use zlib 1.2.3
111129 9:38:49 InnoDB: Using Linux native AIO
111129 9:38:49 InnoDB: Initializing buffer pool, size = 128.0M
111129 9:38:50 InnoDB: Completed initialization of buffer pool
111129 9:38:50 InnoDB: highest supported file format is Barracuda.
111129 9:38:50 InnoDB: Waiting for thebackground threads to start
111129 9:38:51 InnoDB: 1.1.8 started; log sequence number 1605950
111129 9:38:52 [Note] Event Scheduler: Loaded 0 events
111129 9:38:52 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.15-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
111129 10:50:36 mysqld_safe Starting mysqlddaemon with databases from /var/lib/mysql
111129 10:50:37 [Note] Plugin 'FEDERATED'is disabled.
111129 10:50:37 InnoDB: The InnoDB memoryheap is disabled
111129 10:50:37 InnoDB: Mutexes andrw_locks use GCC atomic builtins
111129 10:50:37 InnoDB: Compressed tablesuse zlib 1.2.3
111129 10:50:37 InnoDB: Using Linux nativeAIO
111129 10:50:37 InnoDB: Initializing bufferpool, size = 128.0M
111129 10:50:37 InnoDB: Completedinitialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.
111129 10:50:37 InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.
…
InnoDB: Check that you do not already haveanother mysqld process
InnoDB: using the same InnoDB data or logfiles.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already haveanother mysqld process
--这个提示的意思有多个mysqld 进程在运行。
解决方法:
(1)重新用:ps -ef|grep mysql 查询所有的进程,然后把所有的进程kill掉,
(2)重新对相关的目录赋权
[root@rac2 /]# chown mysql.mysql -R/var/lib/mysql/*
[root@rac2 /]# chmod 755 -R/var/lib/mysql/*
--再次启动成功:
[root@rac2 /]# service mysql start
Starting MySQL...... [ OK ]
[root@rac2 /]# ps -ef|grep mysql
root 27936 1 1 14:08 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rac2.pid
mysql 28193 27936 3 14:08 pts/1 00:00:00 /usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/lib/mysql/rac2.err --pid-file=/var/lib/mysql/rac2.pid--socket=/var/lib/mysql/mysql.sock --port=3306
root 28220 3596 0 14:08 pts/1 00:00:00 grep mysql
[root@rac2 /]# ll /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Nov 29 14:08/var/lib/mysql/mysql.sock
再次查看log:
[root@rac2 lib]# tail -20 /var/lib/mysql/rac2.err
111129 14:51:53 [Note] Event Scheduler:Purging the queue. 0 events
111129 14:51:53 InnoDB: Starting shutdown...
111129 14:51:54 InnoDB: Shutdown completed; log sequencenumber 1605950
111129 14:51:54 [Note] /usr/sbin/mysqld:Shutdown complete
111129 14:51:54 mysqld_safe mysqld from pidfile /var/lib/mysql/rac2.pid ended
111129 14:53:34 mysqld_safe Starting mysqlddaemon with databases from /var/lib/mysql
111129 14:53:34 [Note] Plugin 'FEDERATED'is disabled.
111129 14:53:34 InnoDB: The InnoDB memoryheap is disabled
111129 14:53:34 InnoDB: Mutexes andrw_locks use GCC atomic builtins
111129 14:53:34 InnoDB: Compressed tablesuse zlib 1.2.3
111129 14:53:34 InnoDB: Using Linux nativeAIO
111129 14:53:34 InnoDB: Initializing bufferpool, size = 128.0M
111129 14:53:34 InnoDB: Completed initializationof buffer pool
111129 14:53:35 InnoDB: highest supportedfile format is Barracuda.
111129 14:53:35 InnoDB:1.1.8 started; log sequence number 1605950
111129 14:53:35 [Warning] Neither--relay-log nor --relay-log-index were used; so replication may break when thisMySQL server acts as a slave and has his hostname changed!! Please use'--relay-log=rac2-relay-bin' to avoid this problem.
111129 14:53:35 [Note] Event Scheduler:Loaded 0 events
111129 14:53:35 [Note]/usr/sbin/mysqld: ready for connections.
Version: '5.5.15-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
[root@rac2 lib]#
说明:
因为之前没有保留的相关信息,修改之后,虽重复模拟多次,都不能还原当时的故障,所有缺少足够多的一手资料来证明这个问题。但是我这里的2种方法都可以尝试一下:
MySQL server PID file could not befound!
--可能是相关目录的权限问题导致
Check that you do not already have anothermysqld process
--重复进程导致,可以先ps,在kill掉相关进程在重试。