Friday, August 16, 2013

Configure NTP clients under AIX and RHEL to syncronize with NTP server

This tutorial explains how to configure NTP on client with a NTP server. In all below examples we have two NTP servers ntp01 and ntp02. Here one as a primary and other one is secondary if primary fails secondary will take it up.
Step 1 : Verify that you have a server suitable for synchronization by using below command
# ntpdate -d ip.address.of.server ( Both for AIX and Linux )
Example
[root@webmanual01 ~]# ntpdate -d ntp01.webmanual.com
17 Jan 06:44:16 ntpdate[31056]: ntpdate 4.2.2p1@1.1570-o Wed Sep 3 14:28:30 UTC 2008 (1)
Looking for host ntp01.webmanual.com and service ntp
host found :ntp01.webmanual.com
transmit(10.88.36.2)
receive(10.88.36.2)
transmit(10.88.36.2)
receive(10.88.36.2)
transmit(10.88.36.2)
receive(10.88.36.2)
transmit(10.88.36.2)
receive(10.88.36.2)
transmit(10.88.36.2)
server 10.88.36.2, port 123
stratum 3, precision -17, leap 00, trust 000
refid [10.88.36.2], delay 0.02718, dispersion 0.00005
transmitted 4, in filter 4
reference time: d2bfeb7d.3713f077 Tue, Jan 17 2012 6:43:41.215
originate timestamp: d2bfeba1.0dc1b541 Tue, Jan 17 2012 6:44:17.053
transmit timestamp: d2bfeba1.055a2941 Tue, Jan 17 2012 6:44:17.020
filter delay: 0.02785 0.02718 0.02722 0.02733
0.00000 0.00000 0.00000 0.00000
filter offset: 0.032242 0.031947 0.031990 0.031962
0.000000 0.000000 0.000000 0.000000
delay 0.02718, dispersion 0.00005
offset 0.031947 17 Jan 06:44:17 ntpdate[31056]: adjust time server 10.88.36.2 offset 0.031947 sec
The offset must be less than 1000 seconds for xntpd to synch. If the offset is greater than 1000 seconds, change the time manually on the client and run the ntpdate -d again.
Step 2: Specify your xntp servers in /etc/ntp.conf . Comment out the “broadcastclient” line (if applicable )and add server ip.address/name of NTP server
# vi /etc/ntp.conf
Example for Linux
[root@web-manual01 ~]# cat /etc/ntp.conf
server ntp01.webmanual.com
server ntp02.webmanual.com
driftfile /var/lib/ntp/drift
authenticate yes
Example for AIX
#broadcastclient
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
server ntp01.webmanual.com
server ntp02.webmanual.com
Leave the driftfile and tracefile at their defaults.
Step 3 : Start the xntpd/nfsd daemon:
# startsrc -s xntpd (AIX )
# service ntpd start (Linux)
Step 4: Making ntpd to start on reboot
AIX : Uncomment xntpd from /etc/rc.tcpip so it will start on a reboot.
# vi /etc/rc.tcpip
Uncomment the following line
start /usr/sbin/xntpd “$src_running”
Linux : Run the command ” chkconfig ntpd on” so it will start on a reboot.
Step 5 :Verify that the client is synched.
AIX Steps:
# lssrc -ls xntpd
Example
lssrc -ls xntpd
Program name: /usr/sbin/xntpd
Version: 3
Leap indicator: 00 (No leap second today.)
Sys peer: ntp01.webmanual.com
Sys stratum: 5
Sys precision: -17
Debug/Tracing: DISABLED
Root distance: 0.029816
Root dispersion: 0.043655
Reference ID: 10.160.14.46
Reference time: d2bff453.c0f33000 Tue, Jan 17 2012 7:21:23.753
Broadcast delay: 0.003906 (sec)
Auth delay: 0.000122 (sec)
System flags: pll monitor filegen
System uptime: 707799 (sec)
Clock stability: 0.000107 (sec)
Clock frequency: 0.000000 (sec)
Peer: ntp01.webmanual.com
flags: (configured)(sys peer)
stratum: 4, version: 3
our mode: client, his mode: server
Peer: ntp01.webmanual.com
flags: (configured)(sys peer)
stratum: 4, version: 3
our mode: client, his mode: server
Subsystem Group PID Status
xntpd tcpip 13162 active
NOTE: Sys peer should display the IP address or name of your xntp server. This process may take up to 15 minutes.
Linux Steps
The ntpq utility program (both for Linux and AIX )is used to monitor NTP daemon ntpd operations and determine performance and -p Print a list of the peers known to the server as well as a summary of their state
ntpq -p
Example (Linux)
[root@webmanual01 sysconfig]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp01.webmanual.com 169.254.0.1 3 u 70 128 377 2.043 -0.053 1.619
+ntp02.webmanual.com 169.254.0.1 3 u 52 128 377 1.934 -0.294 1.908