今天在虛擬機裡做DRBD實驗,使用chkconfig管理服務的時候,出現了問題。
root@node2:/root# chkconfig --list | grep drbd
drbd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
root@node2:/root# chkconfig drbd on
/sbin/insserv: No such file or directory
這是ubuntu 12.04的一個BUG,使用以下方法可以解決
root@node2:/root# whereis insserv
insserv: /etc/insserv /etc/insserv.conf /usr/lib/insserv /usr/share/insserv /usr/share/man/man8/insserv.8.gz
把上面找到的目錄,一個一個的看一遍,發現文件在/usr/lib/裡面
root@node2:/root# ls -l /usr/lib/insserv/
total 56
-rwxr-xr-x 1 root root 56368 Apr 9 19:07 insserv
然後我就做了個連接過去
root@node2:/root# ln -s /usr/lib/insserv /sbin/insserv
root@node2:/root# chkconfig drbd on
/sbin/insserv: Permission denied
從上面看出,報了一個權限不允許,很郁悶
root@node2:/root# ls -l /sbin/insserv
lrwxrwxrwx 1 root root 16 Jun 21 04:27 /sbin/insserv -> /usr/lib/insserv
root@node2:/root# ls -l /usr/lib/insserv
total 56
-rwxr-xr-x 1 root root 56368 Apr 9 19:07 insserv
從上面看出,有權限的啊,好郁悶,最後發現 /usr/lib/insserv竟然是一個目錄
root@node2:~# cd /usr/lib/insserv/
root@node2:/usr/lib/insserv# pwd
/usr/lib/insserv
root@node2:/usr/lib/insserv# ls
insserv
然後就好解決了
root@node2:/usr/lib/insserv# rm -rf /sbin/insserv
URL:http://www.bianceng.cn/OS/Linux/201410/46055.htm
root@node2:/usr/lib/insserv# ln -s /usr/lib/insserv/insserv /sbin/insserv
root@node2:/usr/lib/insserv# chkconfig drbd 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 'friendly-recovery' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `friendly-recovery'
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `friendly-recovery'
報了一堆的其它錯誤,先不管吧,看看服務OK沒
root@node2:/usr/lib/insserv# chkconfig --list | grep drbd
drbd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
root@node2:/usr/lib/insserv#
OK,現在看到服務已經搞定了。Ubuntu還是有Bug的,呵呵,好像還挺多。以前總是玩RedHat,沒發現類似的問題。