Activities

February 2011
M T W T F S S
« Jan   Mar »
 123456
78910111213
14151617181920
21222324252627
28  

NTP : ntpd dead but subsys locked

I’m going to setup a Intenet Time server using NTP. I uses yum method to install.

#yum install ntp*
# chkconfig ntpd on
#service ntpd start
After a while I can see that ntp has not been working and it’s dead. It’s throwing me an error “ntpd dead but subsys locked”
[root@rc-090 ~]# netstat -nlp | grep “ntpd”
I’d done several re-installs and attempts like removing pid file , setting drift file path etc. Nothing I can’t see useful from it and stuck at this point. Google led me it’s kind of error with kernel settings towards the ntpd service.

Solution
[root@ip-182 ~]# vi /etc/sysconfig/ntpd and comment the following line
#OPTIONS=”-u ntp:ntp -p /var/run/ntpd.pid” and restart the ntpd daemon.
[root@rc-090 ~]# service ntpd start
Starting ntpd: [ OK ]
[root@rc-090 ~]# service ntpd status
ntpd (pid 14637) is running…
[root@rc-090 ~]#

It’s works now !!!!!

a. How to setup the Time server
a. install ntpd using yum method
b. Add the two line in to the “/etc/ntp.conf” file.

restrict 122.166.40.0 mask 255.255.255.0 nomodify notrap

server
c. restart ntp service #service ntpd restart

How to verify my time server is running
a. From the server execute # service ntpd status or netstat -nlp | grep “ntp”

  Eg: [root@ip-18-5-5-8 ~]#<strong> netstat -nlp | grep "ntpd"</strong>
udp        0      0 182.50.154.87:123           0.0.0.0:*                             7903/ntpd
udp        0      0 127.0.0.1:123               0.0.0.0:*                               7903/ntpd
udp        0      0 0.0.0.0:123                 0.0.0.0:*                                7903/ntpd
udp        0      0 fe80::218:51ff:fe64:123     :::*                                  7903/ntpd
udp        0      0 ::1:123                     :::*                                        7903/ntpd
udp        0      0 :::123                      :::*                                        7903/ntpd

NTP is using UDP packet

c. How can I verify if a client is connected to this time server

After login to the client machine
For linux,
execute the command from the terminal
To verify the connectivity, execute ntpq -p timeserver.com
[root@web-test1 ~]# ntpq -p timeserver.com’s ip or name
remote refid st t when poll reach delay offset jitter
==============================================================================
*ns.bio.keio.ac. 133.100.9.2 2 u 235 64 377 84.027 173299. 4.472
+203.126.176.162 210.193.3.81 3 u 194 64 377 4.023 173309. 10.889
+202.147.35.153 198.123.30.132 2 u 235 64 377 35.010 173283. 8.077
LOCAL(0) .LOCL. 10 l 204 64 377 0.000 0.000 0.001
ip-182-50-154-8 .STEP. 16 u – 1024 0 0.000 0.000 0.000
[root@web-test1] ntpdate -u < server ip>

[root@web-test1 ~]# date
Mon Feb 14 12:14:56 IST 2011
[root@web-test1 ~]#

/usr/sbin/ntpdate -u 192.168.0.1

14 Feb 12:17:57 ntpdate[5464]: step time server 192.168.0.1 offset 173.316001 sec
[root@web-test1 ~]# date
Mon Feb 14 12:17:59 IST 2011
[root@web-test1 ~]#
I’ve set a cron to update the time on every 10 hours

[root@web-test1 ~]# crontab -l
00 */10 * * * /usr/sbin/ntpdate -u 192.168.0.1 >/dev/null 2>&1

In Windows,
Through GUI,
a. Go to control panel and click on ” Date and Time icon”
b. Choose the “Internet time zone and check the box “automatically synchronized with the time server” and type your either of time server ip or dns name. That’s it.

Follow the screen,

From the windows command line,

d. How do I change the Time zone Linux

a. Identify the Time Zone you wish to use
[root@rc-090 ~]# ls -la /usr/share/zoneinfo/
total 588
drwxr-xr-x 21 root root 4096 Aug 7 2010 .
drwxr-xr-x 255 root root 12288 Feb 3 09:23 ..
drwxr-xr-x 2 root root 4096 Aug 7 2010 Africa
b. Identify the current time zone and backup the file
#

date

#

php -r 'phpinfo();' | grep "timezone"

#

mv /etc/localtime /tmp/localtime

c. Set the timezone you wish to use (I’m using here Asia/Culcutta)
# ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
# date

f. Limiting Time server access to specified network/IP

My above setup will allow anybody to use my NTP server. I wish to limit this access certain knows ips and I uses firewall for this purpose. Expecting that you have already firewall running on the server.
Add this rule at the run time and save the firewall.
#/sbin/iptables -I INPUT -s my_public_ip -p udp –dport 123 -m state –state NEW -j ACCEPT
#service iptables save

4 comments to NTP : ntpd dead but subsys locked

  • Graeme

    Excellent, I had removed the pid after this “ntpd dead but pid file exists” si just did rm /var/run/ntpd.pid and oh surprise, subsys locked! But I returned the sysconf file, uncommented that part, after starting and then stopping the service.

    You have great stuff here 🙂

  • Jack Vo

    Dear sir,

    From the tips above, please tell me the meaning of IP Address below :

    restrict 122.166.40.0 mask 255.255.255.0 nomodify notrap

    This is the default IP on server or your NTP server to syncrhonize time.

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>