我意识到这里有很多问题可以回答这个问题 - 但到目前为止似乎没有一个对我有用。
我尝试过:
sudo update-rc.d mysql defaults
这导致了语言环境错误,我修复了这个问题我该如何解决我的语言环境问题?通过改变/etc/environment
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
现在,通过update-rc.d
再次尝试,我得到:
update-rc.d: warning: /etc/init.d/mysql missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
System start/stop links for /etc/init.d/mysql already exist.
我发现了一个建议http://ubuntuforums.org/showthread.php?t=1313898使用:
user@computer:/etc/init.d$ sudo update-rc.d -f mystartupscript remove
user@computer:/etc/init.d$ sudo update-rc.d mystartupscript defaults
user@computer:/etc/init.d$ sudo chmod +x ./mystartupscript
但是我是否冒着破坏 mysql 实现的风险?它在生产服务器上,所以我不能只是尝试一下,然后突然无法再次启动 mysql。
最后,mysql 服务器需要在启动时运行。我们遇到过几次来自主机的服务器重启,每次出现这种情况时,数据库都不会启动,托管页面也会一直处于关闭状态,直到手动启动 mysql。
编辑: /etc/init.d/mysql
内容
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"
if [ "$JOB" = "upstart-job" ]; then
if [ -z "$1" ]; then
echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
fi
JOB="$1"
INITSCRIPT="$1"
shift
else
if [ -z "$1" ]; then
echo "Usage: $0 COMMAND" 1>&2
exit 1
fi
fi
COMMAND="$1"
shift
if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=echo
else
ECHO=:
fi
$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
# Only check if jobs are disabled if the currently _running_ version of
# Upstart (which may be older than the latest _installed_ version)
# supports such a query.
#
# This check is necessary to handle the scenario when upgrading from a
# release without the 'show-config' command (introduced in
# Upstart for Ubuntu version 0.9.7) since without this check, all
# installed packages with associated Upstart jobs would be considered
# disabled.
#
# Once Upstart can maintain state on re-exec, this change can be
# dropped (since the currently running version of Upstart will always
# match the latest installed version).
UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')
if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
then
initctl show-config -e "$JOB"|grep -q '^ start on' || DISABLED=1
fi
case $COMMAND in
status)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
$COMMAND "$JOB"
;;
start|stop)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
if status "$JOB" 2>/dev/null | grep -q ' start/'; then
RUNNING=1
fi
if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
exit 0
elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
exit 0
elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
exit 0
fi
$COMMAND "$JOB"
;;
restart)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
$ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
if status "$JOB" 2>/dev/null | grep -q ' start/'; then
RUNNING=1
fi
if [ -n "$RUNNING" ] ; then
stop "$JOB"
fi
# If the job is disabled and is not currently running, the job is
# not restarted. However, if the job is disabled but has been forced into the
# running state, we *do* stop and restart it since this is expected behaviour
# for the admin who forced the start.
if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
exit 0
fi
start "$JOB"
;;
reload|force-reload)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
reload "$JOB"
;;
*)
$ECHO
$ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
$ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
exit 1
esac
答案1
好的,您还可以尝试另外两件事:尝试运行命令
user@computer:/etc/init.d$ sudo update-rc.d -f mysql remove
user@computer:/etc/init.d$ sudo update-rc.d mysql defaults
看看输出是什么。应该有许多符号链接被创建在 中/etc/rcX.d
。
其次,查看是否有一个/etc/init/mysql.override
文件将启动 mysql 启动设置为manual
upstart,即更现代的 Ubuntu 启动系统。
答案2
但是我是否有风险在这里破坏我的 mysql 实现?
不太可能。无论如何它都不会妨碍您手动启动 MySQL,因此如果它失败了,对您来说它只是保持不变:没有自动启动,但仍然可以手动启动。
这虽然……
/etc/init.d/mysql 的系统启动/停止链接已存在。
... 让我相信自动启动已经有一个启动/停止功能。这也让我相信您在自动启动方面遇到了某种问题,更改它可能无法解决该问题(如果有的话)。
在更改之前,您能否确保 /var/log/syslog(可能是 syslog)中的日志中没有指出 mysql 自动启动问题的通知。因为如果有,最好修复它。