CentOS7部署Chrony
chrony时间同步服务
1.yum安装(所有节点)
[root@localhost ~]# yum -y install chrony
2.服务端配置
[root@localhost ~]# cat > /etc/chrony.conf << EOF server ntp.aliyun.com iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync allow 10.0.0.0/24 local stratum 10 keyfile /etc/chrony.keys leapsectz right/UTC logdir /var/log/chrony EOF
[root@localhost ~]# systemctl restart chronyd && systemctl enable chronyd
客户端配置
[root@localhost ~]# cat > /etc/chrony.conf << EOF pool 192.168.0.37 iburst #(ip为服务端ip) driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync keyfile /etc/chrony.keys leapsectz right/UTC logdir /var/log/chrony EOF
[root@localhost ~]# systemctl start chronyd && systemctl enable chronyd
3.chronyc使用
客户端验证
[root@k8s-master02 kubernetes]# 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
===============================================================================
^* k8s-master01 3 6 377 30 -187us[ -79us] +/- 17ms #(k8s-master01为服务端ip)
查看 ntp-server 是否在线
[root@k8s-master01 ~]# chronyc activity -v 200 OK 1 sources online 0 sources offline 0 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address
查看 ntp 详细信息
[root@k8s-master01 ~]# chronyc tracking -v Reference ID : CB6B0658 (203.107.6.88) Stratum : 3 Ref time (UTC) : Tue Nov 01 02:46:32 2022 System time : 0.000321720 seconds fast of NTP time Last offset : +0.000434528 seconds RMS offset : 0.001262305 seconds Frequency : 10.066 ppm fast Residual freq : +0.138 ppm Skew : 4.369 ppm Root delay : 0.026981421 seconds Root dispersion : 0.003280478 seconds Update interval : 130.3 seconds Leap status : Normal