1. 修改配置文件
yum list chrony
查看相关配置文件路径
rpm -qc chrony
修改配置文件
vim /etc/chrony.conf
修改国内服务器,添加server
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# server 0.centos.pool.ntp.org iburst
server cn.ntp.org.cn iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
重启服务
systemctl restart chronyd.service
2. 通过命令临时同步
前提是chronyd服务未开启。
chronyd -q "server cn.ntp.org.cn iburst"
3. 时间服务器搭建
修改配置文件
vim /etc/chrony.conf
添加如下内容,允许192.168.179网段访问服务器
# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 192.168.179.0/24
重启服务器
systemctl restart chronyd.service
查看端口监听(123/UDP)
netstat -nlup | grep chronyd
防火墙添加端口
firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload
之后客户端连接配置的服务器即可
4. 查看信息
查看源信息
root@localhost ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 58.220.133.132 3 6 377 54 +245us[ +245us] +/- 103ms
^- amy.chl.la 2 6 377 56 +6694us[+6694us] +/- 118ms
^- stratum2-1.ntp.led01.ru.> 2 6 365 51 +23ms[ +23ms] +/- 104ms
^* 120.25.115.20 2 6 377 56 -1019us[-1188us] +/- 4966us
同步时间
chronyc makestep