如何定义服务运行级别顺序位置?

如何定义服务运行级别顺序位置?

我设置了 bind-dlz,并且需要在系统启动时先启动 mysql,这是我所拥有的

[root@semenov]# ./test.sh   
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
named           0:off   1:off   2:off   3:on    4:on    5:on    6:off
lrwxrwxrwx. 1 root root 15 Apr 15 18:57 /etc/rc3.d/S93mysql -> ../init.d/mysql
lrwxrwxrwx. 1 root root 15 Apr 15 18:57 /etc/rc3.d/S90named -> ../init.d/named

这是我在 mysql 初始化脚本中的内容

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 84 16
# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO

所以当我从 chkconfig 中删除命名并只剩下 mysql 时,它以订单号 84 开头:/etc/rc3.d/S84mysql -> ../init.d/mysql

但是当我在 chkconfig 中添加命名时,它的顺序变为 93:/etc/rc3.d/S93mysql -> ../init.d/mysql

因此 mysql 将在 named 之后启动,并且 named 将失败(没有可用的 sql)

知道我做错了什么吗?

这是我在命名初始化脚本中的内容

# chkconfig: 345 90 16
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: true

### BEGIN INIT INFO
# Provides: $named
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start:2 3 4
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: start|stop|status|restart|try-restart|reload|force-reload DNS     server
# Description: control ISC BIND implementation of DNS server
### END INIT INFO

谢谢,德米特里

答案1

根据手册页,如果可用,chkconfig(8)它支持 LSBRequired-StartRequired-Stop超越界限:# chkconfig:

Note that default entries in LSB-delimited 'INIT INFO' sections take
precedence over the default runlevels in the initscript; if any
Required-Start or Required-Stop entries are present, the start and
stop priorities of the script will be adjusted to account for these
dependencies.

您应该能够添加mysql到LSB部分Required-Start的部分并使用重新添加它。namedINIT INFOchkconfig --add

相关内容