Table of contents
2.chrony installation and configuration
2.1 chrony installation and configuration
VERY IMPORTANT: Before configuring, check that the firewall and selinux are turned off
3. Configure chrony as the time server of other hosts
3.1 Modify the chrony configuration file
1. Introduction to chrony
chrony
is an open source
software that follows the network time protocol (
ntp ), allowing the computer system time to be consistent with the time server time,
chrony
It can also serve as a time server for other hosts.
ntp
(network time protocol): port
123 of
udp
. Only one of chrony and ntp can exist in a computer.
2.chrony installation and configuration
2.1 chrony installation and configuration
VERY IMPORTANT: Before configuring, check that the firewall and selinux are turned off
yum install -y chrony
vim /etc/chrony.conf
[root@localhost ~]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp.aliyun.com iburst (编写的网络时间服务器)
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# timedatectl status
Local time: Thu 2023-07-27 10:03:39 CST
Universal time: Thu 2023-07-27 02:03:39 UTC
RTC time: Thu 2023-07-27 02:03:39
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes (两个为yes即可)
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
3. Configure chrony as the time server of other hosts
3.1 Modify the chrony configuration file
在提供chrony时间服务器主机的chrony配置文件中修改以下地方
服务端
1.# Allow NTP client access from local network.
allow 192.168.27.0/24(开启指定ntp客户端)
2.# Serve time even if not synchronized to a time source.
local stratum 10
3.systemctl restart chronyd
客户端
1.下载安装chrony服务
2.编写chrony配置文件
vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.27.120 iburst (ip是提供时间服务器的ip)
3.systemctl enable chronyd
systemctl start chronyd
检查是否同步成功
timedatectl status
4. chronyc command
View ntp servicesResults view^* : It means that the time synchronization is normal, and the synchronized time source is available^- : represents an acceptable source^? : The source of the time synchronization is unreachableCheck if ntp serveices is onlineView ntp details
[root@localhost ~]# chronyc activity -v
200 OK
[root@localhost ~]# chronyc tracking -v