1、安装时间同步工具
dnf install chrony # redhat8
yum install chrony # redhat7
2、启动服务并设置开机启动
systemctl start chronyd
systemctl enable chronyd
3、配置时间同步地址
将原有的地址注释掉
redhat 8注释掉:
pool 2.pool.ntp.org iburst
redhat7注释掉以下行:
#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
server cn.ntp.org.cn iburst
重启服务
systemctl restart chronyd
4、同步时间
[root@localhost ~]# chronyc sources -v
210 Number of sources = 2
.-- 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
===============================================================================
^- 203.107.6.88 2 10 377 964 -6620us[-7301us] +/- 28ms
^* 120.25.115.20 2 10 377 358 -666us[-1416us] +/- 10ms
查看状态
[root@localhost ~]# timedatectl
Local time: 四 2022-04-28 15:57:49 CST
Universal time: 四 2022-04-28 07:57:49 UTC
RTC time: 四 2022-04-28 07:57:49
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a