centos7.x上使用chrony做时间同步
centos7中默认安装的是chrony,若未安装需先安装
yum -y install chrony
加入开机自启
systemctl enable chronyd.service
启动chrony
systemctl restart chronyd.service
关闭SElinux和防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
配置chrony.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 时间服务器的ip iburst
查看时间同步源:
chronyc sources -v
查看时间同步源状态:
chronyc sourcestats -v
设置硬件时间
硬件时间默认为UTC:
timedatectl set-local-rtc 1
启用NTP时间同步:
timedatectl set-ntp yes
校准时间服务器:
chronyc tracking