chrony服务部署

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

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

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

安装与配置

yum install chrony -y

systemctl enable chronyd 开机自启

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

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).

#pool 2.centos.pool.ntp.org iburst

# Use public servers from the pool.ntp.org project.

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

#pool 2.centos.pool.ntp.org iburst

server ntp.aliyun.com iburst

#server 127.0.0.0

# Record the rate at which the system clock gains/losses time.

driftfile /var/lib/chrony/drift

#Allow the system clock to be stepped in the first three updates

# if its offset is larger than 1 second.

makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).

rtcsync

# Enable hardware timestamping on all interfaces that support it.

#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust

# the system clock.

#minsources 2

# Allow NTP client access from local network.

allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.

#local stratum 10

# Specify file containing keys for NTP authentication.

keyfile /etc/chrony.keys

# Get TAI-UTC offset and leap seconds from the system tz database.

leapsectz right/UTC

# Specify directory for log files.

logdir /var/log/chrony

修改加标记的两处

第一处从阿里获取时间

第二处允许192.168.0.0 这个网段的客户端能从这台机器获取时间

重启服务

systemctl restart chronyd

查看时间源

# chronyc sources

MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================

^* 203.107.6.88 2 6 37 40 +31us[+1230us] +/- 21ms

#chronyc tracking

Reference ID : CB6B0658 (203.107.6.88)

Stratum : 3

Ref time (UTC) : Tue Jan 03 13:38:17 2023

System time : 0.000830133 seconds fast of NTP time

Last offset : +0.002169966 seconds

RMS offset : 0.001328697 seconds

Frequency : 37.967 ppm slow

Residual freq : +22.720 ppm

Skew : 13.312 ppm

Root delay : 0.042371813 seconds

Root dispersion : 0.002498093 seconds

Update interval : 64.4 seconds

Leap status : Normal

第二台操作

从第一台获取时间

server 192.168.157.129 iburst

重启服务

systemctl restart chronyd

查看时间源

# chronyc sources

MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================

^* 192.168.157.129 3 6 17 8 -5662ns[-2696us] +/- 20ms

# chronyc tracking

Reference ID : C0A89D81 (192.168.157.129)

Stratum : 4

Ref time (UTC) : Tue Jan 03 13:50:09 2023

System time : 0.000002460 seconds fast of NTP time

Last offset : -0.002690160 seconds

RMS offset : 0.002690160 seconds

Frequency : 39.172 ppm slow

Residual freq : -581.093 ppm

Skew : 0.031 ppm

Root delay : 0.037401177 seconds

Root dispersion : 0.018172879 seconds

Update interval : 2.0 seconds

Leap status : Normal

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

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).

#pool 2.centos.pool.ntp.org iburst

#server ntp.aliyun.com iburst

server 127.0.0.0

# Record the rate at which the system clock gains/losses time.

driftfile /var/lib/chrony/drift

#Allow the system clock to be stepped in the first three updates

# if its offset is larger than 1 second.

makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).

rtcsync

# Enable hardware timestamping on all interfaces that support it.

#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust

# the system clock.

#minsources 2

# Allow NTP client access from local network.

allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.

local stratum 6

# Specify file containing keys for NTP authentication.

keyfile /etc/chrony.keys

# Get TAI-UTC offset and leap seconds from the system tz database.

leapsectz right/UTC

# Specify directory for log files.

logdir /var/log/chrony

标记两处

第一处从一个不存在的地址获取时间

第二处将服务器层级设置为6

查看时间源

# chronyc sources

MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================

^? 127.0.0.0 0 6 0 - +0ns[ +0ns] +/- 0ns

# chronyc tracking

Reference ID : 7F7F0101 ()

Stratum : 6

Ref time (UTC) : Tue Jan 03 13:54:20 2023

System time : 0.000000000 seconds slow of NTP time

Last offset : +0.000000000 seconds

RMS offset : 0.000000000 seconds

Frequency : 47.577 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

第二台操作

查看

# chronyc sources

MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================

^* 192.168.157.129 6 6 377 40 +4078ns[+4180ns] +/- 229us

# chronyc tracking

Reference ID : C0A89D81 (192.168.157.129)

Stratum : 7

Ref time (UTC) : Tue Jan 03 13:58:46 2023

System time : 0.000000094 seconds fast of NTP time

Last offset : -0.000199769 seconds

RMS offset : 0.000370841 seconds

Frequency : 47.829 ppm slow

Residual freq : -0.135 ppm

Skew : 2.294 ppm

Root delay : 0.000379982 seconds

Root dispersion : 0.000188542 seconds

Update interval : 65.1 seconds

Leap status : Normal

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值