NTP-Chrony服务配置手册
snow chuai汇总、整理、撰写---2020/1/20
1. Chrony--NTP服务
1.1 安装与配置chrony
# Centos7默认已经安装chrony为ntp服务.如果chronyd不存在则需要进行安装
# 确认chrony是否安装
[root@ntpsrv ~]# yum info chrony | grep ^Repo
Repo : installed # installed为已安装
# 如果未安装chrony,则执行以下命令
[root@ntpsrv ~]# yum install chrony -y
|
1.2 配置chrony服务
[root@ntpsrv ~]# vim /etc/chrony.conf
# 删除第2行-第5行,并改为中国ntp srv
server cn.pool.ntp.org iburst
server 0.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
server 2.cn.pool.ntp.org iburst
......
......
......
......
......
......
# 取消第27行'#'注释符,允许指定网络访问此ntp server
allow 192.168.0.0/16
......
......
......
......
......
......
# 修改第30,取消'#'符.允许ntp服务器未能成功同步时间,也可以为ntp客户端提供服务
local stratum 10
......
......
......
......
......
......
|
1.3 启动chrony服务
1.3.1 启动chrony服务
[root@ntpsrv ~]# systemctl enable --now chronyd
[root@ntpsrv ~]# systemctl is-active chronyd
active
|
1.3.2 重启chrony服务
[root@ntpsrv ~]# systemctl restart chronyd
|
1.3.3 防火墙配置
[root@ntpsrv ~]# firewall-cmd --add-service=ntp --permanent
success
[root@ntpsrv ~]# firewall-cmd --reload
success
|
1.4 验证chrony
[root@ntpsrv ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 122.51.252.99 3 6 17 8 +485us[-1709us] +/- 73ms
^? ntp5.flashdance.cx 2 6 7 10 -513ms[ -513ms] +/- 722ms
^- 139.199.215.251 2 6 17 19 -2265us[-2265us] +/- 35ms
^? 119.28.183.184 2 7 4 16 -1072us[-1072us] +/- 38ms
|
2. NTP Client配置
[root@ntpclient ~]# vim /etc/chrony.conf
# 删除第2行-第5行,并改为本地ntp srv
server 192.168.188.11 iburst
[root@ntpclient ~]# systemctl restart chronyd
[root@ntpclient ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.188.11 3 6 77 50 +124us[ +257us] +/- 636ms
|
如对您有帮助,请随缘打个赏。^-^