Operating System - HP-UX
1819504 Members
3087 Online
109603 Solutions
New Discussion юеВ

Want to sync the time difference with NTP server

 
Sachin Jadhav
Advisor

Want to sync the time difference with NTP server

Dear All,

I am having one server shubsas with below details
shubsas # uname -a
HP-UX shubsas B.11.11 U 9000/800 2504392625 unlimited-user license
shubsas # model
9000/800/rp7410
with 9 DB's and BSCS application running on the same.

My server is near about 4 mins i.e. 240 seconds behind the ntp server which is configured for this server

Please find below details for reference
shubsas # date
Mon Feb 23 04:23:27 IST 2009

mhprod:/#date
Mon Feb 23 04:27:17 IST 2009

The NTP server details on the shubsas server is

shubsas # ntpq -p
remote refid st t when poll reach delay offset disp
==============================================================================
mhprod 0.0.0.0 16 - - 64 0 0.00 0.000 16000.0
mhrate 0.0.0.0 16 - - 64 0 0.00 0.000 16000.0

To resolve the same I am planning below things
1.downtime for the server
2.manually change the server time respective
with NTP server's time
3.Checkout the time sync with NTP server
4.Up the apps & DB's and again check for the
time

Please suggest a remedy for above problem. It
will be great help to me.

Thanks in Advance ...



14 REPLIES 14
Bill Hassell
Honored Contributor

Re: Want to sync the time difference with NTP server

Because you are less than 10 mins behind, there is no need for any downtime. You can adjust the time with no loss or gain in seconds per day by using the date -a command. If the current time behind by 240 seconds, use this command:

date -a +240

Then check the time with the NTP server and you should see the time moving forward, about 2 minutes per hour. Once the time is within a few seconds, you can start xntpd. Check syslog.log to see any messages from xntpd. Your apps and databases can remain running.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: Want to sync the time difference with NTP server

Shalom,

NTP issues.

NTP can't resolve a discrepancy greater than an hour. So manual adjustment is required in that case.

Never adjust system time backward with running Oracle databases, that is an automatic crash.

Make sure your NTP servers themselves have access to an outside time server. If you depend on the system clock of an internal server it wont work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Want to sync the time difference with NTP server

Hi:

When you setup your NTP servers, use at least three (3) reliable external sources. The NTP Pool is an ideal way:

http://www.pool.ntp.org/

Regards!

...JRF...
Sachin Jadhav
Advisor

Re: Want to sync the time difference with NTP server

Hi Bill,

I tried with date -a +240 but getting the below output


# date -a +240
shubsas # date -a +240.000
Usage: date [-u] [+format]
date [-u] [mmddhhmm[[cc]yy]]
date [-a [-]sss.fff]


please suggest my server server clock is 4 mins behind than my NTP server

Matti_Kurkela
Honored Contributor

Re: Want to sync the time difference with NTP server

The output of your "date" command indicates Bill's advice had just one slight mistake: to make a correction to positive direction, you should not use a plus sign, but no sign at all.

In other words, the correct syntax is:

date -a 240

MK
MK
rick jones
Honored Contributor

Re: Want to sync the time difference with NTP server

Easier still would be - without the xntpd running - to execute the command:

ntpdate mhprod

to set the server time with a step adjustment. No pestky date command formats to get correct. Then you can restart the xntpd manually if you don't wish to reboot.

Keep in mind it will take a few minutes before the xntpd supplied with HP-UX will sync with one of the time servers.

While you are at it, you should put one of mhprod or mhrate into the NTPDATE_SERVER line in /etc/rc.config.d/netdaemons (I may have some filenames/spelling off a bit). That way the ntpdate command will be executed on startup, and that will make sure the system clock is within the tolerances of the xntpd to be willing to synchronize with the time source(s).

The suggestions to have three or more time sources at each layer/stratum of NTP service is a good one. With only two, there really is no way for ntp to find a "false ticker" - it needs at least three for that.

All of this presumes that both mhprod and mhrate are properly synced to timesources themselves...
there is no rest for the wicked yet the virtuous have no pillows
Bill Hassell
Honored Contributor

Re: Want to sync the time difference with NTP server

> ntpdate mhprod

Rick is correct. This will set the time instantly. However, this sudden change may not be healthy for apps and databases. Thus the suggestion to change the date slowly. However, if you can shutdown the apps and databases for a minute or so, you can use the ntpdate command. This is also the command that will be automatically used when your system reboots.


Bill Hassell, sysadmin
Sachin Jadhav
Advisor

Re: Want to sync the time difference with NTP server

Thanx Bill,

I am scheduling this activity as

1) Will get down All apps and DB's on the
server

2) Then I will check the server time and then I
will sync with ntpdate command

It will be a great help if any more views on the same ...


Thanks to all the HP-UX Guru's.


BUPA IS
Respected Contributor

Re: Want to sync the time difference with NTP server

Hello Sachin ,
The ntpq -p command output above indicates that the ntp servers listed are not reachable. Before you schedule downtime you should make sure that you can ping the servers by name and that port 123 is not blocked or in use by something else.

Also have a look in /etc/ntp.conf
restrict statements must have an ip address number not a name.

You can check the operation of the ntp requests by using
ntpdate -d server1 server2 server3

This will show you the packet and request flow.
By the way you can list more than one server in
/etc/rc.config.d/netdaemons

export NTPDATE_SERVER="server1 server2 server3"
export XNTPD=1
At start up ntpdate will be used to set the time and date after which ntp will start.

ntpdate with the -B option will slew rather than set the clock but this may take some hours (or days) during which xntpd cannot be run.
As has been suggested I would go with the restart (or at least a database and application shutdown ) for a 10 minute gap.

I hope this helps
Mike
Help is out there always!!!!!
Sachin Jadhav
Advisor

Re: Want to sync the time difference with NTP server

Hi HP-UX Guru's,

One more query on the same

I am having 9 running databases with BSCS application on the server, serving with different circles.

If I change the server time manually which is behind 4 mins by command line like "date" rather than NTP commands like "ntpdate" from ntp server after getting down apps & all DB's. Will it affect to other circles/servers ?

Thanks in advance for your valuable suggestions.

Many Thanks,
Sachin


James R. Ferguson
Acclaimed Contributor

Re: Want to sync the time difference with NTP server

Hi (again):

> If I change the server time manually which is behind 4 mins ...

Why would you want to have only one time source? For that matter, why would you make that source some local server?

This is so easy to setup and there are so many reliable time sources:

http://www.pool.ntp.org

Regards!

...JRF...
rick jones
Honored Contributor

Re: Want to sync the time difference with NTP server

Picking NTP servers from the pool is indeed easy for many, but still, easy is in the eye of the beholder - some sysadmins might have to deal with network "security" types who will kick and scream over opening another hole in the corporate firewall(s) for NTP traffic.

Also, there may be cases where the goal isn't so much for the systems to have the "correct" time but to all have the "same" time.

Further, there can be value in having at least one "good" timesource which does not depend on one's ISP to maintain your link to the outside world.
there is no rest for the wicked yet the virtuous have no pillows
James R. Ferguson
Acclaimed Contributor

Re: Want to sync the time difference with NTP server

Hi:

@ RicK: Your points are very well taken (of course). I'm lucky. In my environment the network folks appreciate the value of good timekeeping and gave me what I wanted. That, and/or they didn't want to listen to me :-)

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Want to sync the time difference with NTP server

> Will it affect to other circles/servers ?

This is not an HP-UX question. You must ask the application and database administrators. However, since your servers are not currently synchronized, it might not cause a problem, but I would check first, or be safe and setup all your servers to use NTP, but not set the time until a maintenance window.


Bill Hassell, sysadmin