参考文档
http://www.ntp.org/rfc.html
http://linux.vbird.org/linux_server/0440ntp.php
查看日期时间及NTP概况
[root@rhel7-0 ~]# timedatectl
Local time: Wed 2014-12-31 12:47:07 EST
Universal time: Wed 2014-12-31 17:47:07 UTC
RTC time: Sun 2015-01-04 08:51:13
Timezone: America/New_York (EST, -0500)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2014-11-02 01:59:59 EDT
Sun 2014-11-02 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2015-03-08 01:59:59 EST
Sun 2015-03-08 03:00:00 EDT
查看和设置时区
[root@rhel7-0 ~]# timedatectl list-timezones [root@rhel7-0 ~]# timedatectl set-timezone Asia/Hong_Kong
修改日期时间
格式”YYYY-MM-DD hh:mm:ss” 可以只改日期或者时间
[root@rhel7-0 ~]# timedatectl set-time "2015-01-04 16:55:00"
开启NTP服务
[root@rhel7-0 ~]# timedatectl set-ntp true
配置chrony
chrony提供NTP时间校正服务。
[root@rhel7-0 ~]# yum install chrony
配置文件在 /etc/chrony.conf
可以按如下方式配置NTP Server.
server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server 3.rhel.pool.ntp.org iburst
修改配置后重启chronyd服务
[root@rhel7-0 ~]# systemctl restart chronyd
可以用chronyc sources -v 查看同步时钟源。
[root@rhel7-0 ~]# chronyc sources -v 210 Number of sources = 3 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || / xxxx = adjusted offset, || Log2(Polling interval) -. | yyyy = measured offset, || \ | zzzz = estimated error. || | | MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? dns.sjtu.edu.cn 0 6 0 10y +0ns[ +0ns] +/- 0ns ^? gus.buptnet.edu.cn 0 6 0 10y +0ns[ +0ns] +/- 0ns ^? dns1.synet.edu.cn 0 6 0 10y +0ns[ +0ns] +/- 0ns