CentOS7下使用chrony替代ntp时间服务器

1.安装:

           yum install chrony -y

2.启动服务:

           systemctl enable chronyd.service

           systemctl start chronyd.service

3.查看服务状态:

           systemctl status chronyd.service

4.配置chrony:

           vi /etc/chrony

5.添加如下配置并保存:

           server ntp1.aliyun.com iburst
           server ntp2.aliyun.com iburst  
           server ntp3.aliyun.com iburst  
           server ntp4.aliyun.com iburst

6.重启服务:

           systemctl restart chronyd.service

7.开放防火墙

           firewall-cmd --add-service=ntp --permanent

           firewall-cmd --reload

 chronyc sources -v

 ----------------------老

安装ntp服务同步服务器时间

https://www.freesion.com/article/12231086092/

出现如下错误.是因为两台服务器之间时间间隔超过3秒.可以使用ntp同步两台服务器时间

Unable to read ‘format.json’ from http://192.168.0.100:9000/mnt/data2: client time 2020-07-07 00:39:35 +0000 UTC is too apart with server time 2020-07-06 10:52:19.617966442 +0000 UTC

  1. 下载安装ntp服务,用yum直接安装即可
 yum -y install ntp

 

  1. 增加时间服务器的地址,并进行相应的配置
 $ vi /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0 nomodify    #<==允许局域网内所有client连接到这台服务器
server ntp1.aliyun.com    #阿里的时间服务器
#server 0.pool.ntp.org    #外部时间服务器,注释掉
#server 1.pool.ntp.org
#server 2.pool.ntp.org

3. 启动ntp服务,并设置开机自启动
 $ sudo systemctl start ntpd     --启动服务
 $ sudo systemctl enable ntpd    --开机自启动

 

在时间同步的时候,有一点非常重要。就是客户机跟服务器之间的时间差不能太大,如果差距太大,是不会出现第四步那种情况的。
在时间差距太大的时候,可以手动先同步下时间

ntpdate -u <server.ntp>



timedatectl
如果NTP enabled: no 启用NTP服务
timedatectl set-ntp true

原文地址:https://www.cnblogs.com/tonggc1668/p/15787416.html