Linux中进程分为三类:
1 独立守护进程
大多数服务的进程都是独立守护进程,他们一启动都会监听在某个套接字上等待 请求报文的到来如: httpd(tcp/80)https(tcp/443)mysql(tcp/3306)php(tcp/9000)ssh(tcp/22)
独立守护进程一般都可以用chkconfig --list +服务名 显示其运行级别
独立守护进程都可以用 service 服务名 start|stop|restart|status
2 非独立守护进程
非独立守护进程都没有运行级别,所有的非独立守护进程都由xinetd进程进行控制,xinetd一启动,这些非独立进程才会启动;
3 超级守护进程 Xinetd
Xinetd作为一个超级守护进程它可以代理那些不常用的非独立守护进程监听在相应的端口,如Telnet(tcp/23)Swap(tcp/901)swap是Samba的图形配置软件;这些服务平时很少用,为了节省资源,就由xinetd代理监听在相应端口如swap tcp/901,一旦有请求到来,会先到达xinetd,xinetd再根据请求报文的端口号是901 临时启swap进程,请求响应完毕又会继续关闭swap进程,继续让xinetd监听
所有非独立守护进程的配置文件在/etc/xinetd.d/目录下
下面将进行Telnet的安装和配置
以下操作在192.168.139.2
[[email protected] sh]# yum install telnet //安装telnet客户端
[[email protected] sh]# yum install telnet-server //安装telnet服务器端
[[email protected] sh]# vim /etc/xinetd.d/telnet //编辑telnet的配置文件
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream //stream则为tcp类型,datagrum为udp类型
wait = no //no表示个允许两个人以上同时访问,yes为只同时
允许一个人,要等待
user = root //以root 身份运行
server = /usr/sbin/in.telnetd //进程为telnetd(server)端
log_on_failure += USERID //
disable = no //将yes改为no,则表示允许运行telnet服务,yes表示禁用
}
[[email protected] sh]# service xinetd start //启动xinetd
Starting xinetd: [ OK ]
[[email protected] sh]# chkconfig --list //可以看到telnet服务已近启动
xinetd based services:
chargen-dgram: off
chargen-stream:off
daytime-dgram: off
daytime-stream:off
discard-dgram: off
discard-stream:off
echo-dgram: off
echo-stream: off
tcpmux-server: off
telnet: on
time-dgram: off
[[email protected] sh]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1386/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1465/master
tcp 0 0 :::80 :::* LISTEN 1 762/httpd
tcp 0 0 :::22 :::* LISTEN 1386/sshd
tcp 0 0 :::23 :::* LISTEN 2792/xinetd
tcp 0 0 ::1:25 :::* LISTEN 1465/master
[email protected] sh]# netstat -tnlp |grep xinetd //可以看到xinetd代理监听在23号端口
tcp 0 0 :::23 6575/xinetd
以下操作在192.168.139.4
[[email protected] sh]# yum install telnet //安装telnet客户端
[[email protected] sh]# chkconfig --add telnet //将telnet服务加入系统服务
[[email protected] sh]# useradd hadoop //添加telnet用户,因为telnet为明文传输,所以不允许root登录
[[email protected] sh]# passwd hadoop
[[email protected] sh]# telnet 192.168.139.2 //登录192.168.139.2 telnet_server
Trying 192.168.139.2...
Connected to 192.168.139.2.
Escape character is ‘^]‘.
CentOS release 6.7 (Final)
Kernel 2.6.32-573.el6.x86_64 on an x86_64
login: hadoop
Password:
Last login: Mon Oct 31 04:11:45 from www.jiamian.com
[[email protected] ~]$ ifconfig //IP 192.168.139.2
eth0 Link encap:Ethernet HWaddr 00:0C:29:1C:13:12
inet addr:192.168.139.2 Bcast:192.168.139.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1c:1312/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12937 errors:0 dropped:0 overruns:0 frame:0
TX packets:9614 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1427826 (1.3 MiB) TX bytes:1347748 (1.2 MiB)