CentOS 7 配置时间服务器 chrony

开放 NTP 客户端访问

修改 /etc/chrony.conf 文件,配置如下:

# Allow NTP client access from local network.
allow 172.25/16

...

# Serve time even if not synchronized to any NTP server.
local stratum 10

重启 chronyd

修改完配置文件后,重新启动时间服务器

systemctl restart chronyd
systemctl enable chronyd

设置防火墙

开放 NTP 协议的 123 端口

可参考 CentOS 7.2 防火墙配置

firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload

客户端测试

编辑 /etc/chrony.conf 文件,根据实际环境修改或删除以下的关键行

server ntp_server iburst

使用主机名或者 IP 地址代替上文中的 ntp_server 服务器,重启 chronyd 服务

systemctl restart chronyd
systemctl enable chronyd

使用 chronyc sources -v 命令测试 NTP 服务器

[root@foundation3 ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.25.254.250               10   6    17     9  -5574ns[  -24us] +/-  216us

看到 * 符号就代表客户端已经正常与时间服务器进行时间同步

转载于:https://my.oschina.net/91devel/blog/2878266

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值