Linux chrony服务器配置

配置目标:

chrony服务部署:两台机器

a: 第一台机器从阿里云同步时间

第二台机器从第一台机器同步时间

b: 第一台服务器使用系统时间作为第二台服务器的时钟源, 第一台服务器层级设置为6

a:

安装chrony,关闭防火墙与selinux


yum -y install chrony
systemctl stop firewalld.service 
setenforce 0

配置


vim /etc/chrony.conf

#将原有的pool注释掉,并添加阿里云的时间服务器
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst

#允许其它客户端连接到此台时钟服务器
allow all

启动并验证是否配置正确


systemctl start chronyd

chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- 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               
===============================================================================
^* 203.107.6.88                  2   6   377    30  +1586us[+2716us] +/-   39ms

第二台机器同样安装chrony,关闭防火墙与selinux

将第二台服务器要同步的时间服务器IP设置为第一台


vim /etc/chrony.conf

#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 192.168.85.128 iburst

启动第二台服务器并验证是否配置正确


systemctl start chronyd

chronyc sources -v

  .-- 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               
===============================================================================
^* 192.168.85.128                3   6     7     2  -3254ns[+2908us] +/-   58m

b:

将第一台服务器所有同步的时钟服务器注释掉,并将本地层级设置为6


vim /etc/chrony.conf

#server ntp.aliyun.com iburs

local stratum 6

重启并验证


systemctl restart chronyd
chronyc tracking

Reference ID    : 7F7F0101 ()
Stratum         : 6     #成功
Ref time (UTC)  : Thu Jan 05 06:05:52 2023
System time     : 0.000000000 seconds slow of NTP time
Last offset     : +0.000000000 seconds
RMS offset      : 0.000000000 seconds
Frequency       : 10.785 ppm slow
Residual freq   : +0.000 ppm
Skew            : 0.000 ppm
Root delay      : 0.000000000 seconds
Root dispersion : 0.000000000 seconds
Update interval : 0.0 seconds
Leap status     : Normal

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值