博客统计信息

51cto专家博客 51cto博客之星
用户名:sery
文章数:191
评论数:2878
访问量:1283148
无忧币:11539
博客积分:8262
博客等级:9
注册日期:2006-03-29

Linux 服务集中管理工具ntsysv
2007-12-20 15:21:15
版权声明:原创作品,如需转载,请与作者联系。否则将追究法律责任。
作者:田逸(sery@163.com
 
Ntsysvredhat 提供的集中管理系统各种服务的工具,在RedHat各个发行版,centos各个版本,都自带这个工具。比起solaris 10SMF来,要方便很多了,因为ntsysv一次就可以选中或取消多个服务,而svcadmin只能一个一个的来。
 
RedHat2种方法启用ntsysv:一种是直接在命令行下执行命令 ntsysv,另外一种是执行setup命令间接进入。不管是哪种方式进入,其结果都是相同的。下面用图示来说明一下这个过程。
回车后出现下列菜单:
光标定位System services ,再按“Tab”键选“Run Tool”,也可以直接回车。
用空白键(最长的那个)选中或取消服务。选中时,服务的前面的方括号里是“*”,反之则表示取消。设置完毕后,按“Tab”到“ok”回车结束配置。如果直接执行命令ntsysv,步骤就比setup少。
 
 
当我们使用ntsysv管理服务时,究竟后面进行的实质是什么?进入当前运行目录/etc/rc3.d(我的系统当前运行级别是3,运行命令 who –r查看之),用命令 ll 列出所有的目录,然后统计一下目录/文件数目:
[root@myest rc3.d]# ll
total 4
lrwxrwxrwx  1 root root 21 Oct 18 12:17 K01tog-pegasus -> ../init.d/tog-pegasus
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K01yum -> ../init.d/yum
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K02haldaemon -> ../init.d/haldaemon
lrwxrwxrwx  1 root root 24 Oct 18 12:17 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K03messagebus -> ../init.d/messagebus
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K03rhnsd -> ../init.d/rhnsd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K05anacron -> ../init.d/anacron
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K10cups -> ../init.d/cups
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K10psacct -> ../init.d/psacct
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K10xfs -> ../init.d/xfs
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K15gpm -> ../init.d/gpm
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K17iiim -> ../init.d/iiim
lrwxrwxrwx  1 root root 13 Oct 18 12:17 K20nfs -> ../init.d/nfs
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K24irda -> ../init.d/irda
lrwxrwxrwx  1 root root 22 Oct 18 12:17 K30courier-imap -> ../init.d/courier-imap
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K35winbind -> ../init.d/winbind
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K40smartd -> ../init.d/smartd
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K44rawdevices -> ../init.d/rawdevices
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K50ibmasm -> ../init.d/ibmasm
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K50netdump -> ../init.d/netdump
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K50xinetd -> ../init.d/xinetd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K56acpid -> ../init.d/acpid
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K68rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K69rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K72autofs -> ../init.d/autofs
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74apmd -> ../init.d/apmd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74nscd -> ../init.d/nscd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K75netfs -> ../init.d/netfs
lrwxrwxrwx  1 root root 25 Oct 18 12:17 K85courier-authlib -> ../init.d/courier-authlib
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K87auditd -> ../init.d/auditd
lrwxrwxrwx  1 root root 20 Oct 18 12:17 K87irqbalance -> ../init.d/irqbalance
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K87portmap -> ../init.d/portmap
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K91isdn -> ../init.d/isdn
lrwxrwxrwx  1 root root 22 Oct 18 12:17 K92arptables_jf -> ../init.d/arptables_jf
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K92iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K94diskdump -> ../init.d/diskdump
lrwxrwxrwx  1 root root 15 Oct 18 12:17 K95kudzu -> ../init.d/kudzu
lrwxrwxrwx  1 root root 17 Oct 18 12:17 K95openibd -> ../init.d/openibd
lrwxrwxrwx  1 root root 14 Oct 18 12:17 K96ipmi -> ../init.d/ipmi
lrwxrwxrwx  1 root root 16 Oct 18 12:17 K96pcmcia -> ../init.d/pcmcia
lrwxrwxrwx  1 root root 18 Oct 18 12:17 K99cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx  1 root root 23 Oct 18 12:17 K99microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx  1 root root 19 Oct 18 12:17 K99readahead -> ../init.d/readahead
lrwxrwxrwx  1 root root 25 Oct 18 12:17 K99readahead_early -> ../init.d/readahead_early
lrwxrwxrwx  1 root root 17 Oct 18 12:17 S10network -> ../init.d/network
lrwxrwxrwx  1 root root 16 Oct 18 12:17 S12syslog -> ../init.d/syslog
lrwxrwxrwx  1 root root 14 Oct 18 12:17 S55sshd -> ../init.d/sshd
lrwxrwxrwx  1 root root 15 Oct 18 12:17 S90crond -> ../init.d/crond
lrwxrwxrwx  1 root root 13 Oct 18 12:17 S95atd -> ../init.d/atd
lrwxrwxrwx  1 root root 11 Jul 30 13:23 S99local -> ../rc.local
全是链接文件,真实的文件在目录/etc/init.d呢。
[root@myest rc3.d]# ll | wc -l
58
现在/etc/rc3.d目录有58个链接文件。接下来,我们使用ntsysv添加一个服务,如“kuzdu”,执行完毕后,再查目录/etc/rc3.d,其结果如下:
[root@myest rc3.d]# ll                                                        
total 4
lrwxrwxrwx  1 root root 21 Dec 20 14:24 K01tog-pegasus -> ../init.d/tog-pegasus
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K01yum -> ../init.d/yum
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K02haldaemon -> ../init.d/haldaemon
lrwxrwxrwx  1 root root 24 Dec 20 14:24 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K03messagebus -> ../init.d/messagebus
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K03rhnsd -> ../init.d/rhnsd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K05anacron -> ../init.d/anacron
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K10cups -> ../init.d/cups
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K10psacct -> ../init.d/psacct
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K10xfs -> ../init.d/xfs
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K15gpm -> ../init.d/gpm
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K17iiim -> ../init.d/iiim
lrwxrwxrwx  1 root root 13 Dec 20 14:24 K20nfs -> ../init.d/nfs
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K24irda -> ../init.d/irda
lrwxrwxrwx  1 root root 22 Dec 20 14:24 K30courier-imap -> ../init.d/courier-imap
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K35winbind -> ../init.d/winbind
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K40smartd -> ../init.d/smartd
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K44rawdevices -> ../init.d/rawdevices
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K50ibmasm -> ../init.d/ibmasm
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K50netdump -> ../init.d/netdump
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K50xinetd -> ../init.d/xinetd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K56acpid -> ../init.d/acpid
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K68rpcidmapd -> ../init.d/rpcidmapd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K69rpcgssd -> ../init.d/rpcgssd
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K72autofs -> ../init.d/autofs
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K73ypbind -> ../init.d/ypbind
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74apmd -> ../init.d/apmd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74nscd -> ../init.d/nscd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K74ntpd -> ../init.d/ntpd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K75netfs -> ../init.d/netfs
lrwxrwxrwx  1 root root 25 Dec 20 14:24 K85courier-authlib -> ../init.d/courier-authlib
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx  1 root root 15 Dec 20 14:24 K85mdmpd -> ../init.d/mdmpd
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K86nfslock -> ../init.d/nfslock
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K87auditd -> ../init.d/auditd
lrwxrwxrwx  1 root root 20 Dec 20 14:24 K87irqbalance -> ../init.d/irqbalance
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K87portmap -> ../init.d/portmap
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K89netplugd -> ../init.d/netplugd
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K91isdn -> ../init.d/isdn
lrwxrwxrwx  1 root root 22 Dec 20 14:24 K92arptables_jf -> ../init.d/arptables_jf
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K92iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K94diskdump -> ../init.d/diskdump
lrwxrwxrwx  1 root root 17 Dec 20 14:24 K95openibd -> ../init.d/openibd
lrwxrwxrwx  1 root root 14 Dec 20 14:24 K96ipmi -> ../init.d/ipmi
lrwxrwxrwx  1 root root 16 Dec 20 14:24 K96pcmcia -> ../init.d/pcmcia
lrwxrwxrwx  1 root root 18 Dec 20 14:24 K99cpuspeed -> ../init.d/cpuspeed
lrwxrwxrwx  1 root root 23 Dec 20 14:24 K99microcode_ctl -> ../init.d/microcode_ctl
lrwxrwxrwx  1 root root 19 Dec 20 14:24 K99readahead -> ../init.d/readahead
lrwxrwxrwx  1 root root 25 Dec 20 14:24 K99readahead_early -> ../init.d/readahead_early
lrwxrwxrwx  1 root root 15 Dec 20 14:24 S05kudzu -> ../init.d/kudzu
lrwxrwxrwx  1 root root 17 Dec 20 14:24 S10network -> ../init.d/network
lrwxrwxrwx  1 root root 16 Dec 20 14:24 S12syslog -> ../init.d/syslog
lrwxrwxrwx  1 root root 14 Dec 20 14:24 S55sshd -> ../init.d/sshd
lrwxrwxrwx  1 root root 15 Dec 20 14:24 S90crond -> ../init.d/crond
lrwxrwxrwx  1 root root 13 Dec 20 14:24 S95atd -> ../init.d/atd
lrwxrwxrwx  1 root root 11 Jul 30 13:23 S99local -> ../rc.local
从输出可以看见多了一个文件 S05kudzu,文件个数现在是59,确实是多了一个。再运行工具ntsysv把这个服务取消,这时目录/etc/rc3.d将删除链接文件S05kuzdu。由此我们可以得出结论,ntsysv的作用就是把目录/etc/init.d的文件在相应运行级别的目录创建或删除链接文件。
 
懂得这个原理后,我们用手工的方法也可以完成这个操作,而且可以把这个方法运用在各种unix/linux操作系统,要程序随系统开机启动就不是难事了。
 
 
                                                                                                      2007-12-20

本文出自 “sery” 博客,转载请与作者联系!

分享至
更多
一键收藏,随时查看,分享好友!
liugaoyang119
1人
了这篇文章
类别:我用linux技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

文章评论

 
2007-12-20 15:27:06
ntsysv一次可以取消多个服务,那还真不错

2007-12-20 15:31:32
沙发没了,仔细看先......

2007-12-20 15:39:14
我用那个ntsysv出来的为什么是乱码呢

2007-12-20 15:40:58
拍砖。。。扔便便。。。

2007-12-20 15:42:29
经典!!!

2007-12-20 15:43:54
很不错 又学到东西了   我去试试

2007-12-22 23:26:44
好东西,我看了两边才弄明白啊!秋香老大加油啊!

2008-06-30 18:13:40
謝謝秋香了,自己也手動去添加試試

2011-08-01 12:31:44
得向田老师学习
博主回复:
2011-08-01 12:35:53
相互学习

2012-04-29 03:14:09
原先/etc/rc3.d/下面有81个链接文件,为什么我在ntsysv 添加来删除去,始终/etc/rc3.d/还是81个~....求解!!!

 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: