项目要求
一.配置server主机要求如下:
1.server主机的主机名称为 ntp_server.example.com
2.server主机的IP为: 172.25.254.100
3.server主机的时间为1984-11-11 11:11:11
4.配置server主机的时间同步服务要求可以被所有人使用
二.设定clinet主机要求如下
1.client主机的IP为:172.25.254.200
2.client主机的主机名称为: client.example.com
3.同步172.25.254.100主机的时间到达本机
4.用命令显示对于172.25.254.100主机的时间同步情况
实现代码:一
[root@server100 ~]# hostnamectl hostname ntp_server.example.com 修改主机名
[root@ntpserver ~]# systemctl stop chronyd.service 停止 chrony 协议
[root@ntpserver ~]# timedatectl set-time "1984-11-11 11:11:11 " 修改系统时间
[root@ntpserver ~]# rpm -qc chrony 查看 chrony 软件路径
[root@ntpserver ~]# vim /etc/chrony.conf 修改配置文件
[root@server200 ~]# systemctl restart chronyd.service 切记!! 修改配置文件后一点要重启服务
实现代码:二
[root@server200 ~]# hostnamectl hostname client.example.com 修改主机名
[root@server200 ~]# timedatectl 查看系统当前时间
Local time: 五 2024-04-19 14:47:22 CST
Universal time: 五 2024-04-19 06:47:22 UTC
RTC time: 五 2024-04-19 06:47:22
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
[root@server200 ~]# vim /etc/chrony.conf 修改配置文件
[root@server200 ~]# systemctl restart chronyd.service 重启服务
[root@server200 ~]# chronyc sources -v 用命令显示对于172.25.254.100主机的时间同步情况