April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Chrony time synch

Alternatively, you can install the new Chrony service that is quicker to synchronize clocks in mobile and virtual systems.

Install the Chrony service:
# yum install -y chrony

Activate the Chrony service at boot:
# systemctl enable chronyd

Start the Chrony service:
# systemctl start chronyd

[root@apache2 ~]# yum install chrony -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.vodien.com
* extras: mirror.vodien.com
* updates: mirror.vodien.com
Package chrony-2.1.1-1.el7.centos.x86_64 already installed and latest version
Nothing to do
[root@apache2 ~]# systemctl start crond.service
[root@apache2 ~]#
[root@apache2 ~]#
[root@apache2 ~]#
[root@apache2 ~]#
[root@apache2 ~]# systemctl status crond.service
? crond.service – Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2016-05-14 20:13:14 SGT; 1h 48min ago
Main PID: 848 (crond)
CGroup: /system.slice/crond.service
??848 /usr/sbin/crond -n

May 14 20:13:14 apache2.rmohan.com systemd[1]: Started Command Scheduler.
May 14 20:13:14 apache2.rmohan.com systemd[1]: Starting Command Scheduler…
May 14 20:13:14 apache2.rmohan.com crond[848]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 57% if used.)
May 14 20:13:14 apache2.rmohan.com crond[848]: (CRON) INFO (running with inotify support)
May 14 22:00:15 apache2.rmohan.com systemd[1]: Started Command Scheduler.
[root@apache2 ~]# systemctl enable crond.service
[root@apache2 ~]# chr
chronyc chronyd chroot chrt
[root@apache2 ~]# chronyd
[root@apache2 ~]# chrony
chronyc chronyd
[root@apache2 ~]# chronyc
chrony version 2.1.1
Copyright (C) 1997-2003, 2007, 2009-2015 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.

chronyc> quit

The Chrony configuration is in the /etc/chrony.conf file:

[root@apache2 ~]# cat /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

# Ignore stratum in source selection.
stratumweight 0

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
makestep 10 3

# Allow NTP client access from local network.
#allow 192.168/16

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# Serve time even if not synchronized to any NTP server.
#local stratum 10

keyfile /etc/chrony.keys

# Specify the key used as password for chronyc.
commandkey 1

# Generate command key if missing.
generatecommandkey

# Disable logging of client accesses.
noclientlog

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

logdir /var/log/chrony
#log measurements statistics tracking
[root@apache2 ~]#

Note: For basic configuration purpose, only the server directives could need a change to point at a different set of master time servers than the defaults specified.

To get information about the main time reference, type:

#log measurements statistics tracking
[root@apache2 ~]# chronyc tracking
Reference ID : 202.156.0.34 (time2.maxonline.com.sg)
Stratum : 2
Ref time (UTC) : Sat May 14 04:01:50 2016
System time : 0.001108132 seconds fast of NTP time
Last offset : +0.002678378 seconds
RMS offset : 0.002678378 seconds
Frequency : 37.078 ppm fast
Residual freq : +0.000 ppm
Skew : 315.347 ppm
Root delay : 0.015427 seconds
Root dispersion : 0.011265 seconds
Update interval : 64.9 seconds
Leap status : Normal
[root@apache2 ~]#

To get equivalent information to the ntpq command, type:
[root@apache2 ~]# chronyc sources -v
210 Number of sources = 4

.– 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
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) –. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- shim.active-apps.net 2 6 37 58 +14ms[ +14ms] +/- 61ms
^- time1.maxonline.com.sg 1 6 77 64 -2046us[-2046us] +/- 3682us
^* time2.maxonline.com.sg 1 6 77 4 -1368us[-6926us] +/- 4931us
^- tor-exit.katzen.me 2 6 77 9 +4244us[+4244us] +/- 49ms

Time synchronization can also be forced with the below chronyc commands.

[root@apache2 ~]# chronyc -a ‘burst 4/4’
200 OK
200 OK
[root@apache2 ~]# chronyc -a makestep
200 OK
200 OK
[root@apache2 ~]#

Chronyc can also be used to view detailed NTP specific information as demonstrated below.
[root@apache2 ~]# chronyc tracking
Reference ID : 202.156.0.34 (time2.maxonline.com.sg)
Stratum : 2
Ref time (UTC) : Sat May 14 04:08:53 2016
System time : 0.000000000 seconds slow of NTP time
Last offset : -0.000051153 seconds
RMS offset : 0.001930560 seconds
Frequency : 2.401 ppm slow
Residual freq : -0.003 ppm
Skew : 2.714 ppm
Root delay : 0.006534 seconds
Root dispersion : 0.000577 seconds
Update interval : 2.1 seconds
Leap status : Normal
[root@apache2 ~]# date
Sat May 14 12:09:54 SGT 2016

We can also view all NTP servers that chronyc is synchronizing with.
[root@apache1 ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ 103.224.117.98 4 6 17 26 -5985us[-6099us] +/- 135ms
^+ frontier.innolan.net 2 6 17 26 +2607us[+2478us] +/- 71ms
^* tor-exit.katzen.me 2 6 17 25 -499us[ -644us] +/- 57ms
^- gandhari.thirdeye.it 2 6 17 25 +3135us[+3135us] +/- 364ms
[root@apache1 ~]# chronyc -a ‘burst 4/4’

Further information on these sources can then be viewed.
[root@centos7 ~]# chronyc sourcestats

[root@apache2 ~]# chronyc sourcestats
210 Number of sources = 4
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
shim.active-apps.net 18 9 689 +1.049 15.882 +2220us 4358us
time1.maxonline.com.sg 12 6 618 +0.582 4.374 +164us 648us
time2.maxonline.com.sg 16 14 624 -0.487 2.781 -185us 563us
tor-exit.katzen.me 12 7 617 -0.846 9.713 +4003us 1389us
[root@apache2 ~]#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>