一.配置server主机要求如下:
1.server主机的主机名称为 ntp_server.example.com
2.server主机的IP为: 172.25.254.100
3.server主机的时间为1984-11-11 11:11:11
4.配置server主机的时间同步服务要求可以被所有人使用
主机实现:
[root@server100 ~]# hostnamectl hostname ntp_server.example.com
[root@server100 ~]# hostname
ntpserver.example.com
[root@server100 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.254.100 netmask 255.255.255.0 broadcast 172.25.254.255
inet6 fe80::5208:ee91:4252:4dd6 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f0:ae:25 txqueuelen 1000 (Ethernet)
RX packets 4682 bytes 6651914 (6.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3410 bytes 199254 (194.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 42 bytes 4592 (4.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 42 bytes 4592 (4.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@server100 ~]# systemctl stop chronyd.service
[root@server100 ~]# timedatectl set-time "1984-11-11 11:11:11"
[root@server100 ~]# timedatectl
Local time: 日 1984-11-11 11:11:15 CST
Universal time: 日 1984-11-11 03:11:15 UTC
RTC time: 日 1984-11-11 03:11:16
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
[root@server100 ~]# vim /etc/chrony.conf
# 修改如下几行
allow 0.0.0.0/0
local stratum 10
[root@server100 ~]# systemctl restart chronyd.service
[root@server100 ~]# systemctl disable --now firewalld.service
二.设定clinet主机要求如下
1.client主机的IP为:172.25.254.200
2.client主机的主机名称为: client.example.com
3.同步172.25.254.100主机的时间到达本机
4.用命令显示对于172.25.254.100主机的时间同步情况
客户端实现:
[root@server200 ~]# hostnamectl hostname client.example.com
[root@server200 ~]# hostnamectl
Static hostname: client.example.com
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: e8d565d4402e40f8a4c2c2c1a5095e13
Boot ID: e704d94917ae477fa3108444d35e03fd
Virtualization: vmware
Operating System: Red Hat Enterprise Linux 9.3 (Plow)
CPE OS Name: cpe:/o:redhat:enterprise_linux:9::baseos
Kernel: Linux 5.14.0-362.8.1.el9_3.x86_64
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware20,1
Firmware Version: VMW201.00V.21805430.B64.2305221830
[root@server200 ~]# vim /etc/chrony.conf
# 添加这一行
server 172.25.254.100 iburst
[root@server100 ~]# systemctl restart chronyd.service
[root@client ~]# timedatectl
Local time: Sun 1984-11-11 11:43:15 CST
Universal time: Sun 1984-11-11 03:43:15 UTC
RTC time: Sun 1984-11-11 03:43:15
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
至此本次实验完成