centos 7 时间同步使用的是chrony工具标签:set,14,centos,77,chrony,同步,martin,root From: https://blog.51cto.com/u_64214/6088788
1、检测chrony包是否安装
[root@martin ~]# rpm -qa|grep chrony
2、安装chrony
[root@martin ~]# yum install chrony -y
3、启动chrony并查看其状态
[root@martin ~]# systemctl start chronyd
[root@martin ~]# systemctl status chronyd
4、查看系统时间
[root@martin ~]# timedatectl
Local time: Mon 2018-05-14 09:55:13 CST
Universal time: Mon 2018-05-14 01:55:13 UTC
RTC time: Mon 2018-05-14 01:55:14
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
timedatectl status 显示当前时间信息
set-time 设定当前时间
set-timezone 设定当前时区(Asia/Shanghai)
set-local-rtc 设定bios时间
5、设置亚洲时区
timedatectl set-timezone Asia/Shanghai
6、启用NTP同步
timedatectl set-ntp yes
7、同步时间
[root@martin ~]# chronyc makestep
200 OK
8、查看时间同步的信息来源
[root@localhost ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ 119.79-161-57.customer.l> 2 6 77 34 -10ms[ -10ms] +/- 210ms
^+ makaki.miuku.net 2 6 77 34 -8951us[-8951us] +/- 210ms
^+ cn.ntp.faelix.net 2 6 77 35 -8692us[-8692us] +/- 111ms
^* ntp7.flashdance.cx 2 6 77 36 +40ms[ +13ms] +/- 188ms
9、Chrony的配置文件在/etc/chrony.conf
server ntp1.aliyun.com
server time1.aliyun.com