环境:
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
安装包:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]# yum install chrony
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras:mirrors.163.com
* updates:mirrors.163.com
Package chrony-3.1-2.el7.centos.x86_64 alreadyinstalled and latest version
启动服务:、
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# systemctl restart chronyd
配置
修改时区:
ln -sf /usr/share/zoneinfo/Asia/Shanghai/etc/localtime
[root@localhost ~]# vim /etc/chrony.conf .
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst #阿里云时间服务器
查看是否同步:
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# timedatectl
Localtime: Thu 2018-04-19 08:43:50 CST
Universaltime: Thu 2018-04-19 00:43:50 UTC
RTCtime: Thu 2018-04-19 00:43:50
Timezone: Asia/Shanghai (CST, +0800)
NTPenabled: yes
NTP synchronized: yes
RTC in localTZ: no
DSTactive: n/a