【Linux】【开发环境】【RHEL】开发环境搭建系列之四——安装daytime服务

本文摘要:缘起《UNP》1.5节“一个简单的时间获取服务器程序”这个例子中需要daytime服务#xff0c;为了运行该节的程序#xff0c;故安装下该服务。过程检查是否已安装了daytime服务#xff0c;如目录下有daytime-*文件#xff0c;则表示安装过了[qxhgd#64;local......

缘起


《UNP》1.5节“一个简单的时间获取服务器程序”这个例子中需要daytime服务,为了运行该节的程序,故安装下该服务。


过程


  • 检查是否已安装了daytime服务,如目录下有daytime-*文件,则表示安装过了


[qxhgd@localhost ~]$ cd /etc/xinetd.d/
[qxhgd@localhost xinetd.d]$ ls


  • 安装xinetd服务


[qxhgd@localhost ~]$ sudo yum install xinetd


  • 使能
    下面几个文件,最前面的一行的 “disable=yes”改为“disable=no”


daytime-stream、daytime-dgram、time-dgram、time-stream


  • 重启服务并配置开机启用使能


[qxhgd@localhost ~]$systemctl  restart  xinetd.service     #重启服务 
[qxhgd@localhost ~]$systemctl  enable   xinetd.service      #开机启用


  • 确认服务状态是否正常


[qxhgd@localhost ~]$ systemctl  status  xinetd.service
xinetd.service - Xinetd A Powerful Replacement For Inetd
   Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-04-13 07:28:00 CST; 11h ago
 Main PID: 25942 (xinetd)
    Tasks: 1
   CGroup: /system.slice/xinetd.service
           └─25942 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid

Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing chargen
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing discard
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing discard
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing echo
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing echo
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing tcpmux
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing time
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: removing time
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: xinetd Version 2.3.15 st...
Apr 13 07:28:00 localhost.localdomain xinetd[25942]: Started working: 2 avail...
Hint: Some lines were ellipsized, use -l to show in full.


  • 验证下功能


1、可利用rdate命令:


[root@localhost xinetd.d]# rdate -p -s 192.168.2.100
rdate: [192.168.2.100]  Wed Apr 14 03:17:09 2021


2、也可以利用《UNP》1.5节的程序来验证。


命令汇总


yum install xinetd                       #安装xinetd
systemctl  restart  xinetd.service       #重启服务 
systemctl  enable   xinetd.service       #开机启用
systemctl  status   xinetd.service       #查看状态
rdate -s 192.168.2.100                   #询问系统时间并显示出来

标签