大家可以按照我上面的步骤在虚拟机中作个测试,我的重现率是100%。
在init.d中的mysql启动项和早期的版本不一样了。(文件的时间是由于我手工编辑了脚本想echo点信息出来导致时间变更,在故障前后这个脚本没有变动)
代码: 全选
/etc/init.d$ ls -l|grep mysql
lrwxrwxrwx 1 root root 21 2010-05-06 22:38 mysql -> /lib/init/upstart-job
实际的启动配置文件好像变成了下面这个。
/etc/init/mysql.conf
文件内容如下(该文件在启动前后也无变动)
代码: 全选
#################
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1@ubuntu.com>"
start on (net-device-up
and local-filesystems)
stop on runlevel [016]
respawn
env HOME=/etc/mysql
umask 007
pre-start script
#Sanity checks
[ -r $HOME/my.cnf ]
[ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
LC_ALL=C BLOCKSIZE= df --portability /var/lib/mysql/. | tail -n 1 | awk '{ exit ($4<4096) }'
end script
exec /usr/sbin/mysqld
post-start script
while ! /usr/bin/mysqladmin --defaults-file=$HOME/debian.cnf ping
do
sleep 1
done
exec $HOME/debian-start
end script
###############################
/etc/mysql$ ls -l|grep debian-start
-rwxr-xr-x 1 root root 1198 2010-04-14 01:04 debian-start
/etc/mysql/debian-start文件如下(又包含了/usr/share/mysql/debian-start.inc.sh)
代码: 全选
###################################
#!/bin/bash
#
# This script is executed by "/etc/init.d/mysql" on every (re)start.
#
# Changes to this file will be preserved when updating the Debian package.
#
source /usr/share/mysql/debian-start.inc.sh
MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf"
MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf"
MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables"
MYCHECK_PARAMS="--all-databases --fast --silent"
MYCHECK_RCPT="root"
# The following commands should be run when the server is up but in background
# where they do not block the server start and in one shell instance so that
# they run sequentially. They are supposed not to echo anything to stdout.
# If you want to disable the check for crashed tables comment
# "check_for_crashed_tables" out.
# (There may be no output to stdout inside the background process!)
echo "Checking for corrupt, not cleanly closed and upgrade needing tables."
(
upgrade_system_tables_if_necessary;
check_root_accounts;
check_for_crashed_tables;
) >&2 &
exit 0
####################################
查看了/var/run/mysqld、/var/run。也没有sock文件和pid文件。
运行
代码: 全选
/etc/mysql$ sudo service mysql status
mysql respawn/post-start, (post-start) process 1010
代码: 全选
ps -aux|grep 1010
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root 1010 0.3 0.1 4088 588 ? Ss 17:41 0:00 /bin/sh -e /proc/self/fd/11
steam 1110 0.0 0.1 7616 904 pts/0 S+ 17:41 0:00 grep --color=auto 1010
感觉是由于使用了错误的帐号启动了mysql服务导致服务启动过程出错,在添加了user=mysql参数后,也无法再次成功启动了。这个让我很诧异。启动脚本均未受变动。/var/lib/mysql中似乎也没异常出现。
如果这个是服务mysql服务脚本的问题的话还好。若是服务管理本身的问题。。那么很多其他服务应该也会遇到相关问题的。