服务安装类型主要分两种:
RPM安装和源码包编译安装:
1.RPM包查看: rpm -qa | grep 包名
用chkconfig --list 查看服务自启动命令 只对RPM包安装的服务生效 源码包未必生效
ps -aux (查看系统当中所有启动的进程) ps aux | grep 服务名 如果有返回则说明服务在运行
netstat -tlun (守护进程没有端口是看不到的)
2.源码包查看安装服务
源码包的所有都放置在安装目录当中如果删除该目录那么该服务就会干净的在服务器上消失。
源码包的启动服务一般放置在一个指定的位置如apache: /usr/local/apache2/bin/apactl restart
3.chkconfig 命令是在收索 /etc/rc.d/init.d 所以我可以让源码包支持办法 ln -s /usr/local/apache2/bin/apactl /etc/rc.d/init.d/httpd
但并不推荐这样做: chkconfig --add httpd 开启自启动 chkconfig --level 345 httpd off
1 [root@localhostA1 ~]# chkconfig --help2 chkconfig 版本 1.3.49.3 - 版权 (C) 1997-2000 Red Hat, Inc.3 在 GNU 公共许可的条款下,本软件可以被自由发行。4 5 用法: chkconfig [--list] [--type] [name]6 chkconfig --add 7 chkconfig --del 8 chkconfig --override 9 chkconfig [--level ] [--type ]
主要: RPM包安装的默认位置:
1. /etc/init.d 与 /etc/rc.d/init.d 着两个目录是硬链接目录
2. /etc/sysconfig/ 初始化环境配置文件位置
3. /etc/ 配置文件位置
4. /etc/xinetd.conf xinetd配置文件
5. /etc/xinetd.d/ 基于xinetd服务的启动脚本
6. /var/lib/ 服务产生的数据放在这里
7. /var/log/ 日志
2、独立服务的启动
/etc/init.d/独立服务名 start|stop|restart|status(查看服务的运行状态)
用service 命令启动
service 独立服务名 strat|....| service 是累RHEL发行版特定的
补充: 查看所有RPM包安装服务的运行情况
[root@localhostA1 ~]# service --status-allabrt-ccpp hook is installedabrtd (pid 1582) 正在运行...abrt-dump-oops 已停acpid (pid 1378) 正在运行...atd (pid 1601) 正在运行...auditd (pid 1124) 正在运行...automount (pid 1454) 正在运行...certmonger (pid 1614) 正在运行...Stoppedcgred 已停cpuspeed 已停crond (pid 1590) 正在运行...cupsd (pid 1353) 正在运行...hald (pid 1387) 正在运行...表格:filterChain INPUT (policy ACCEPT)num target prot opt source destination 1 ACCEPT all ::/0 ::/0 state RELATED,ESTABLISHED 2 ACCEPT icmpv6 ::/0 ::/0 3 ACCEPT all ::/0 ::/0 4 ACCEPT tcp ::/0 ::/0 state NEW tcp dpt:22 5 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited Chain FORWARD (policy ACCEPT)num target prot opt source destination 1 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited Chain OUTPUT (policy ACCEPT)num target prot opt source destination 表格:filterChain INPUT (policy ACCEPT)num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)num target prot opt source destination 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)num target prot opt source destination irqbalance 已停Kdump is operationallvmetad 已停Checking for mcelogmcelog (pid 1470) 正在运行...mdmonitor 已停messagebus (pid 1336) 正在运行...模块 netconsole 未被加载配置设备:lo eth0当前的活跃设备:lo eth0rpc.svcgssd 已停rpc.mountd 已停nfsd 已停rpc.rquotad 已停rpc.statd (pid 1209) 正在运行...ntpd 已停numad 已停oddjobd 已停portreserve 已停master (pid 1558) 正在运行...进程记帐被禁用。quota_nld 已停rdisc 已停restorecond 已停rngd 已停rpcbind (pid 1191) 正在运行...rpc.gssd 已停rpc.idmapd (pid 1241) 正在运行...rpc.svcgssd 已停rsyslogd (pid 1149) 正在运行...sandbox is stoppedsaslauthd 已停smartd 已停openssh-daemon (pid 1482) 正在运行...sssd 已停winbindd 已停ypbind 已停
二、RPM包安装的服务于管理:
基于xinetd: 服务本身没有安装 在现在的Linux内核版本中基于xinetd的服务越来越少
telnet-server服务强烈不建议在线上服务器上安装
1 [root@localhost~]#yum -y install xinetd2 [root@localhost~]#yum -y install telnet-server
在安装完xinetd后可以用chkconfig --list 最下面会出现基于xinetd服务的命令
1 基于 xinetd 的服务: 2 chargen-dgram: 关闭 3 chargen-stream: 关闭 4 daytime-dgram: 关闭 5 daytime-stream: 关闭 6 discard-dgram: 关闭 7 discard-stream: 关闭 8 echo-dgram: 关闭 9 echo-stream: 关闭10 rsync: 关闭11 tcpmux-server: 关闭12 time-dgram: 关闭13 time-stream: 关闭
如果要启动telnet服务默认的启动在/etc/xinetd.d/telnet而不是/etc/rc.d/init.d/