在 Ubuntu 嘗試用 chkconfig 管理 MySQL 自啟動遇到連串報錯,最終發現 Ubuntu 屬於 Debian 系,應使用 update-rc.d 而非 chkconfig。
# chkconfig --list
The program 'chkconfig' is currently not installed.
# apt-get install chkconfig
# chkconfig --list | grep mysql
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig mysql on
/sbin/insserv: No such file or directory
# ln -s /usr/lib/insserv/insserv /sbin/insserv
# chkconfig mysql on
The script you are attempting to invoke has been converted to an Upstart job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'mysql' missing LSB tags and overrides
...
chkconfig 是 RedHat/Fedora 系工具,依賴 SysV init 腳本與 LSB 標籤。/etc/init/mysql.conf),非標準 SysV 腳本,chkconfig/insserv 無法識別。/sbin/insserv 軟鏈接只會引發更多錯誤。
# 刪除誤建的軟鏈接
rm -f /sbin/insserv
# 使用 Debian/Ubuntu 原生工具
sudo update-rc.d mysql defaults
# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Runlevel 2-5 顯示 on 即表示開機自啟動已生效。
systemctl enable mysql。chkconfig,需安裝 sysv-rc-conf 或手動管理 /etc/rc*.d/ 軟鏈接,不推薦。