CentOS NTP 时间同步的配置与验证

我们使用阿里云的 ntp 时间服务器即可不需要自己搭建。
配置如下

yum install -y ntp  #安装客户端

vim /etc/ntp.conf

阿里云 ntp 地址打开确认
https://www.alibabacloud.com/help/zh/elastic-compute-service/latest/alibaba-cloud-ntp-server
其他的 ntp 配置时间服务器注释掉,

# server 0.centos.pool.ntp.org iburst
# xxxxxxxxxxxxxxxxxxx

添加内容如下

server ntp1.aliyun.com

启动客户端
centos 7

systemctl enable ntpd.service
systemctl start ntpd

centos6

service ntpd start

查看运行结果

watch ntpq -p

2022-12-21T06:29:39.png

补充说明:配置文件已写入不表示主机已经同步。应观察选中的时间源、同步状态和偏差,并记录虚拟机可能同时受到宿主机时间影响。