Linux配置NTP时间同步

1、安装ntp

yum install -y ntp

2、配置

[root@master ~]# vim /etc/ntp.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 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst

3、启动

启动ntp服务,并开机自启动
[root@master ~]# systemctl start ntpd
[root@master ~]# systemctl enable ntpd

在ntpd服务启动时,先使用ntpdate命令同步时间:

ntpdate -u 1.cn.pool.ntp.org

原因之一:当服务端与客户端之间的时间误差过大时,此时修改时间可能对系统或应用带来不可预知问题,NTP会停止时间同步。若检查NTP启动后时间未同步时,应考虑可能是时间误差过大所致,此时需要先手动进行时间同步。

4、检查

[root@master ~]# date
Tue Nov 17 21:24:24 CST 2020

 

posted @ 2021-06-09 10:37  John_2011  阅读(249)  评论(0编辑  收藏  举报