Monday, November 19, 2012

How to synchronize clock between time

In order to synchronize the clock time between servers, you must have one reference server. In our example tlvntp1.tlv.lpnet.com
Then, all your server should refer to it . That's the way to do it:

1) In your file /etc/ntp.conf, you should have the following line:

server tlvntp1.tlv.lpnet.com
My System Administrator did the following shortcut:
echo server tlvntp1.tlv.lpnet.com > /etc/ntp.conf

But be careful with it, since it may delete other synchronization option the file already has.


2) To be synchronized with our IT ntpserver (the one with the good clock time)
service ntpd restart

3) Then ntpq -p
to display what the offset with the synchronized server  (the tlvntp1) 
The offset should reduce after few minutes ....

This apparently means what is the offset between your current server and the referenced ntp server ( here, for ex, rstm02 and rstm18 etc ...)
michaelz@roor-wto128:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+rstm02.lpdomain 64.236.96.53     2 u  162 1024  377    0.320    4.600   0.049
+rstm18.lpdomain 204.9.54.119     2 u  150 1024  377    0.337    5.579   0.063
*rstm09.lpdomain 64.236.96.53     2 u  173 1024  377    0.358    1.196   0.035
 rstm07.lpdomain 172.16.22.71     2 u  551 1024  377    0.777  -42.128   3.369
 rstm06.lpdomain 172.16.22.71     2 u  884 1024  377    2.675  -94.770  96.884


Same, but without host name resolving (-n option)
michaelz@roor-wto128:~$ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+10.16.23.11     64.236.96.53     2 u  168 1024  377    0.320    4.600   0.049
+10.16.22.18     204.9.54.119     2 u  156 1024  377    0.337    5.579   0.063
*10.16.23.21     64.236.96.53     2 u  179 1024  377    0.358    1.196   0.035
 10.16.22.61     172.16.22.71     2 u  557 1024  377    0.777  -42.128   3.369
 10.16.22.71     172.16.22.71     2 u  890 1024  377    2.675  -94.770  96.884


4) Synchronize time between two servers
In order to synchronize the time between two different servers (no need to have an ntp server in between):

ntpdate -u the-second-host-server





To synchronize your Windows with an external NTP server, do the following:
net time \\tlvdc1 /set /y    
where, tlvdc1 is the host  name of yoru NTP server