Linux网络服务

来自CloudWiki
跳转至: 导航搜索

Linux网络服务管理

什么是服务

服务(service) 服务相当于支持系统运行的一些必要程序,默默运行在系统后台的,他可以为应用程序提供一些更有特色的东西,比如播放MP3,开启一个播放MP3的服务,用户点击开始按钮通知服务开启,点击关闭按钮通知服务关闭,如果你禁用这个服务,那别人想播放MP3那是不行的,而且服务之间是有可能互相依靠的。

常用网络服务

由于linux系统的稳定性和安全性,目前Internet上基于linux操作平台架设的网络服务越来越多。运行于linux系统下的常用网络服务器软件及其守护进程名,如表所示。

服务的启动脚本

在linux中,每个服务都会有相应的服务器启动脚本,该脚本可用于实现启动服务,重启服务,停止和查询服务等功能,在服务器启动脚本中,一般还有对该脚本功能的简要说明和使用方法。

所有的服务器启动脚本都存放在/etc/rc.d/init.d目录中,脚本名称与服务名称相对应。

[root@cloud17 ~]# ls /etc/rc.d/init.d

abrtd         dnsmasq       mdmonitor       oddjobd      saslauthd
acpid         firstboot     messagebus      portreserve  single
atd           functions     microcode_ctl   postfix      smartd
auditd        haldaemon     netconsole      psacct       snmpd
autofs        halt          netfs           rdisc        snmptrapd
avahi-daemon  htcacheclean  network         restorecond  sshd
bluetooth     httpd         NetworkManager  rhnsd        sssd
certmonger    ip6tables     nfs             rpcbind      sysstat
cgconfig      iptables      nfslock         rpcgssd      udev-post
cgred         irqbalance    nscd            rpcidmapd    wpa_supplicant
cpuspeed      kdump         nslcd           rpcsvcgssd   ypbind
crond         killall       ntpd            rsyslog
cups          lvm2-monitor  ntpdate         sandbox

通过service命令管理服务(重点掌握)

用法为:service 服务名 {start|stop|restart|status}

service httpd status #查看服务状态

service httpd start #启动服务

service httpd stop #关闭服务

service httpd restart #重启服务

通过chkconfig命令配置服务的启动状态

[root@cloud17 ~]# chkconfig --list

NetworkManager  0:off   1:off   2:on    3:on    4:on    5:on    6:off
abrtd           0:off   1:off   2:off   3:on    4:off   5:on    6:off
acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off

chkconfig --list httpd

chkconfig --level 235 httpd on

chkconfig httpd on


实验

1.实现真机和虚拟机之间的网络互通.