Friday, September 20, 2013

Time Synchronization, Timed NTPD, Set Clock

date - time

Time synchronization:timed, ntpd, setclock
ntp is considered superior to timed.


NTP:
ntpd is a daemon that runs to keep your time up to date/time. For this you must configure ntp.conf so it will know where to get the date/time.
ntpdate is a command that will use ntp.conf to do an update now as opposed to waiting for ntpd to do it.
Translation: You want ntpd, you need to configure ntp.conf. You CAN use ntpdate to do manual updates.

should put this line to /etc/ntp.conf:
server timeserver.domain.com
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
...
...


Date change:
1. stopsrc -s xntpd
2. ntpdate <ntp server>                      <--ntpdate command will decline if xntpd is running
   4 Oct 14:20:07 ntpdate[491628]: step time server 200.200.10.100 offset -32.293912 sec
<<3. smit date>>
4. vi /etc/rc.tcpip
5. uncomment this line: start /usr/sbin/xntpd "$src_running"
6. startsrc -s xntpd

---------------------

Configuring NTP:

ON SERVER:
1. lssrc -ls xntpd                          <--Sys peer should show a valid server or 127.127.1.0.

If the server is "insane":
2. vi /etc/ntp.conf:
   Add:
      server 127.127.1.0
      Double check that "broadcast client" is commented out.

      stopsrc -s xntpd
      startsrc -s xntpd
     If it is a DB server, use the -x flag to prevent the clock from changing in a negative direction.
     Enter the following:startsrc -s xntpd -a "-x"

3. lssrc -ls xntpd                           <--check if the server is synched. It can take up 12 minutes


ON CLIENT:
1. ntpdate -d ip.address.of.server           <--verify there is a suitable server for synch
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.

If you get the message, "no server suitable for synchronization found", verify xntpd is running on the server (see above) and that no firewalls are blocking port 123.

2. vi /etc/ntp.conf                          <--specify your xntp server in /etc/ntp.conf, enter:
(Comment out the "broadcastclient" line and add server ip.address.of.server prefer.)
Leave the driftfile and tracefile at their defaults.

3. startsrc -s xntpd                          <--start the xntpd daemon:
(Use the -x flag if it is appropriate for your environment.)

4. vi /etc/rc.tcpip                          <--uncomment xntpd from /etc/rc.tcpip so it will start on a reboot.
Uncomment the following line:
      start /usr/sbin/xntpd "$src_running"
      If using the -x flag, add "-x" to the end of the line. You must include the quotes around the -x.

5. lssrc -ls xntpd            <--verify that the client is synched.
Sys peer should display the IP address or name of your xntp server. This process may take up to 12 minutes.
---------------------

FOR NTP problem:
# ntpq -p
No association ID's returned

It can be checked with this as well:
# ntpq -p <severname>

# tail /etc/ntp.conf
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
server timeserver.domain.com prefer
server timeserver2.domain.com

# ping timeserver.domain.com
0821-062 ping: host name timeserver.domain.com NOT FOUND

# tail /etc/netsvc.conf

hosts=local

# nslookup timeserver.domain.com
Server:  ns.domain.com
Address:  10.20.10.10

Name:    timeserver.domain.com
Address:  10.20.10.11

# vi /etc/netsvc.conf
-> hosts=local,bind4

# refresh -s xntpd

# ntpq -p
     remote           refid      st t when poll reach   delay   offset    disp
==============================================================================
sys_pmm-1        timeserver2     2 u   24   64    1    13.75    1.279 15875.0
timeserver2 .    hopf.           1 u   23   64    3    16.85   -5.670 7875.17

------------------

Time Zone variable:

DST: Daylight Saving Time (this means that we have to change our clock at spring/autumn)

If your time zone is set to use Daylight Saving Time, then Time Zone variable will show 2 different entries:
"grep TZ /etc/environment" or "echo $TZ"

TZ=NFT-1DFT-2,M3.5.0,M10.5.0        <--DST is used
TZ=CUT                              <--DST is not used

(We could say if the time zone variable ends in DT (or in our case DFT), DST is enabled.)

In smit chtz_user 2 terms are used for setting timezones:

Standard Time: time usually used from end of October until end of March
Daylight Saving Time: this is the time usually used from end of March until end of October

if you see this:
NFT-1DFT-2,M3.5.0,M10.5.0

NFT             <--name of Standard Time (Oct. -> March)
-1              <--difference between standard time and UTC (or CUT) (it means between Oct. and March our time is behind 1 hour from UTC)
DFT             <--name of Daylight Saving Time (March -> Oct.)
-2              <--difference between DST and UTC (or CUT) (it means between March and Oct our time is behind 2 hour from UTC)

Start Daylight Saving Time:
M3              <--month 3 (March)
              <--5. occurence on that month
0               <--sunday

Stop Daylight Saving Time:
M10             <--month 10 (October)
5               <--5. occurence on that month
0               <--sunday

-----

TZ change:
smitty chtz_user (smitty chtz_date) or chtz
(here you can see timezone list: ls -l /usr/share/lib/zoneinfo)

for example:
chtz EST5EDT    <--it will change timezone to EST5EDT

Environment variables are examined when a command starts running. The environment of a process is not changed by altering the /etc/environment file. Any processes that were started prior to the change to the /etc/environment file must be restarted if the change is to take effect for those processes. If the TZ variable is changed, the cron daemon must be restarted, because this variable is used to determine the current local time.

No comments:

Post a Comment