免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 853 | 回复: 0
打印 上一主题 下一主题

daemon 学习 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-21 16:44 |只看该作者 |倒序浏览
daemon

登录档的 syslog 这支 daemon 的初始化设定就写入在 /etc/sysconfig/syslog:
[root@www ~]# /etc/init.d/syslog
用法: /etc/init.d/syslog
{start|stop|status|restart|condrestart}
# 什么参数都不加的时候,系统会告诉你可以用的参数有哪些,如上所示。

范例一:观察 syslog 这个 daemon 目前的状态
[root@www ~]# /etc/init.d/syslog status

范例二:重新让 syslog 读取一次配置文件
[root@www ~]# /etc/init.d/syslog restart
正在关闭核心记录器: [ 确定 ]
正在关闭系统记录器: [ 确定 ]
正在启动系统记录器: [ 确定 ]
正在启动核心记录器: [ 确定 ]

由于系统的环境都已经帮你制作妥当,所以利用 /etc/init.d/* 来启动、关闭与观察,就非常的简单!
话虽如此, CentOS 还是有提供另外一支可以启动 stand alone 服务的脚本喔,那就是 service 这个程序。 其实 service 仅是一支 script 啦,他可以分析你下达的 service 后面的参数,然后根据你的参数再到 /etc/init.d/ 去取得正确的服务来 start 或 stop 哩!他的语法是这样的啦:
[root@www ~]# service [service name] (start|stop|restart|...)
[root@www ~]# service --status-all
选项与参数:
service name:亦即是需要启动的服务名称,需与 /etc/init.d/ 对应;
start|... :亦即是该服务要进行的工作。
--status-all:将系统所有的 stand alone 的服务状态通通列出来

范例三:重新启动 crond 这支 daemon :
[root@www ~]# service crond restart
[root@www ~]# /etc/init.d/crond restart
# 这两种方法随便你用哪一种来处理都可以!


Super daemon 的启动方式
必须要在配置文件中设定为启动该 daemon 才行。配置文件就是 /etc/xinetd.d/* 的所有档案。那如何得知 super daemon 所管理的服务是否有启动呢?你可以这样做:
[root@www ~]# grep -i 'disable' /etc/xinetd.d/*
....(前面省略)....
/etc/xinetd.d/rsync:         disable = yes
/etc/xinetd.d/tcpmux-server: disable = yes
/etc/xinetd.d/time-dgram:    disable = yes
/etc/xinetd.d/time-stream:   disable = yes

!假设我想要启动如上的 rsync 这个服务,那么你可以这样做:
# 1. 先修改配置文件成为启动的模样:
[root@www ~]# vim /etc/xinetd.d/rsync
# 请将 disable 那一行改成如下的模样 (原本是 yes 改成 no 就对了)
service rsync
{
        disable = no
        ....(后面省略)....


# 2. 重新启动 xinetd 这个服务
[root@www ~]# /etc/init.d/xinetd restart

# 3. 观察启动的埠口
[root@www ~]# grep 'rsync' /etc/services <==先看看埠口是哪一号
rsync 873/tcp # rsync
rsync 873/udp # rsync
[root@www ~]# netstat -tnlp | grep 873
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 4925/xinetd
# 注意看!启动的服务并非 rsync 喔!而是 xinetd ,因为他要控管 rsync 嘛!

既然这家伙这么重要,那么底下我们就来谈谈 xinetd 这个服务的预设配置文件 /etc/xinetd.conf ,以及各个设定项目的意义啰!
p15


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/100458/showart_2002698.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP