Ntp: Difference between revisions

From CLONWiki
Jump to navigation Jump to search
Boiarino (talk | contribs)
No edit summary
Boiarino (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
2. Create file /etc/inet/ntp.conf, or copy from another Solaris machine:
2. Create file /etc/inet/ntp.conf, or copy from another Solaris machine:


  # peer host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
# peer host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
  # server host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
# server host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
  # broadcast host_address [ key # ] [ version # ] [ minpoll interval ]
# broadcast host_address [ key # ] [ version # ] [ minpoll interval ]
  # driftfile filename
# driftfile filename
  # broadcast yes|no
# broadcast yes|no
  # broadcastdelay seconds
# broadcastdelay seconds
  # authenticate yes|no
# authenticate yes|no
  # authdelay seconds
# authdelay seconds
  # keys filename
# keys filename
  # trustedkey # [ # ... ]
# trustedkey # [ # ... ]
  # controlkey #
# controlkey #
  # restrict address [ mask numeric_mask ] [ flag ] [ ... ]
# restrict address [ mask numeric_mask ] [ flag ] [ ... ]
  # statsdir /directory/[ prefix ]
# statsdir /directory/[ prefix ]
  # statistics names
# statistics names
  # filegen name [ file filename ] [ type typename ] [ link|nolink ] [enable|disable ]
# filegen name [ file filename ] [ type typename ] [ link|nolink ] [enable|disable ]
  # enabled/disabled
# enabled/disabled
  # link/nolink
# link/nolink
  # keyno  type  key
# keyno  type  key
  #
#
  ####################
####################
  #
#
  # JLAB time servers
# JLAB time servers
  server ntp1.jlab.org  version 3  prefer  # stratum 2, Ver 3
server ntp1.jlab.org  version 3  prefer  # stratum 2, Ver 3
  server ntp2.jlab.org  version 3          # stratum 2, Ver 3
server ntp2.jlab.org  version 3          # stratum 2, Ver 3
  #
#
  #
#
  driftfile /etc/inet/ntp.drift
driftfile /etc/inet/ntp.drift


3. Start the ntp daemon:
3. Start the ntp daemon:


  svcadm enable network/ntp
svcadm enable network/ntp


4. Check if it is running:
4. Check if it is running:


  svcs | grep ntp
svcs | grep ntp
     online        16:29:30 svc:/network/ntp:default
     online        16:29:30 svc:/network/ntp:default


5. Make query to make sure everything is Ok:
5. Make query to make sure everything is Ok:


  ntpq -p
ntpq -p
         remote          refid      st t when poll reach  delay  offset    disp
         remote          refid      st t when poll reach  delay  offset    disp
     ==============================================================================
     ==============================================================================
     *ns1.jlab.org    time.nist.gov    2 u  27  64  77    0.46  -1.440  387.54
     *ns1.jlab.org    time.nist.gov    2 u  27  64  77    0.46  -1.440  387.54
     +ccs1.jlab.org  time.nist.gov    2 u  27  64  77    0.43    1.798  386.89
     +ccs1.jlab.org  time.nist.gov    2 u  27  64  77    0.43    1.798  386.89
'''NOTE: for Solaris 10 update 6 from CD's on clon05 it did not worked, have to start xntpd manuall !!!'''




'''Linux'''
'''Linux'''
You can use ''/usr/bin/system-config-date'' if available, in that case check ''/etc/ntp.conf'' file to see if everything is correct (see below). To do it manually:


1. Login as 'root'
1. Login as 'root'
Line 61: Line 62:
2. Modify file /etc/ntp.conf commenting out lines
2. Modify file /etc/ntp.conf commenting out lines


  ##server 0.pool.ntp.org
##server 0.pool.ntp.org
  ##server 1.pool.ntp.org
##server 1.pool.ntp.org
  ##server 2.pool.ntp.org
##server 2.pool.ntp.org


and adding lines
and adding lines


  server ntp1.jlab.org
server ntp1.jlab.org
  server ntp2.jlab.org
server ntp2.jlab.org


or copy file from another Linux machine.
or copy file from another Linux machine.
You can use ''/usr/bin/system-config-date'' if available, in that case skip step 3 below. To do it manually:


3. Start daemon:
3. Start daemon:


  /etc/init.d/ntpd start
/etc/init.d/ntpd start
     Starting ntpd:                                            [  OK  ]
     Starting ntpd:                                            [  OK  ]


4. Check if it is running:
4. Check if it is running:


  /etc/init.d/ntpd status
/etc/init.d/ntpd status
     ntpd (pid 15598) is running...
     ntpd (pid 15598) is running...


5. Make query to make sure everything is Ok:
5. Make query to make sure everything is Ok:


  ntpq -p
ntpq -p
         remote          refid      st t when poll reach  delay  offset  jitter
         remote          refid      st t when poll reach  delay  offset  jitter
     ==============================================================================
     ==============================================================================
Line 92: Line 95:
6. To start service at next boot do following:
6. To start service at next boot do following:


  ###chkconfig --add ntpd (normally linux has it already)
###chkconfig --add ntpd (normally linux has it already)
  chkconfig --level 3 ntpd on
chkconfig --level 3 ntpd on
  chkconfig --level 4 ntpd on
chkconfig --level 4 ntpd on
  chkconfig --level 5 ntpd on
chkconfig --level 5 ntpd on
  chkconfig --list ntpd
chkconfig --list ntpd
     ntpd            0:off  1:off  2:off  3:on  4:on  5:on    6:off
     ntpd            0:off  1:off  2:off  3:on  4:on  5:on    6:off


If 'chkconfig' tool does not exist, make symbolic links manually, for example:
If 'chkconfig' tool does not exist, make symbolic links manually, for example:


  /etc/rc0.d/K74ntpd -> ../init.d/ntpd
/etc/rc0.d/K74ntpd -> ../init.d/ntpd
  /etc/rc1.d/K74ntpd -> ../init.d/ntpd
/etc/rc1.d/K74ntpd -> ../init.d/ntpd
  /etc/rc2.d/K74ntpd -> ../init.d/ntpd
/etc/rc2.d/K74ntpd -> ../init.d/ntpd
  /etc/rc3.d/K74ntpd -> ../init.d/ntpd
/etc/rc3.d/K74ntpd -> ../init.d/ntpd
  /etc/rc3.d/S58ntpd -> ../init.d/ntpd
/etc/rc3.d/S58ntpd -> ../init.d/ntpd
  /etc/rc4.d/K74ntpd -> ../init.d/ntpd
/etc/rc4.d/K74ntpd -> ../init.d/ntpd
  /etc/rc4.d/S58ntpd -> ../init.d/ntpd
/etc/rc4.d/S58ntpd -> ../init.d/ntpd
  /etc/rc5.d/K74ntpd -> ../init.d/ntpd
/etc/rc5.d/K74ntpd -> ../init.d/ntpd
  /etc/rc5.d/S58ntpd -> ../init.d/ntpd
/etc/rc5.d/S58ntpd -> ../init.d/ntpd
  /etc/rc6.d/K74ntpd -> ../init.d/ntpd
/etc/rc6.d/K74ntpd -> ../init.d/ntpd


NOTES:
NOTES:


  /etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.
/etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.
  Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.
Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.
  Run ``date MMDDhhmm'' to set the current system date/time.
Run ``date MMDDhhmm'' to set the current system date/time.
  Type ``/sbin/hwclock --systohc [--utc]'' to set the hardware clock.
Type ``/sbin/hwclock --systohc [--utc]'' to set the hardware clock.
 
'''Daylight protocol'''
 
To obtain information about when time will be switched use following example:
 
zdump -v America/New_York | grep 2007
 
It must produces similar to following:
 
America/New_York  Tue Mar  6 16:55:25 2007 UTC = Tue Mar  6 11:55:25 2007 EST isdst=0
America/New_York  Sun Mar 11 06:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 EST isdst=0
America/New_York  Sun Mar 11 07:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 EDT isdst=1
America/New_York  Sun Nov  4 05:59:59 2007 UTC = Sun Nov  4 01:59:59 2007 EDT isdst=1
America/New_York  Sun Nov  4 06:00:00 2007 UTC = Sun Nov  4 01:00:00 2007 EST isdst=0
 
Make sure dates are correct (V SOOTVETSTVII S POSLEDNIM RESHENIEM KPSS).

Latest revision as of 17:23, 14 November 2008

NTP is Network Time Protocol. It exists on both Solaris and Linux but is not started by default so it must be started using following procedure:

Solaris

1. login as 'root'

2. Create file /etc/inet/ntp.conf, or copy from another Solaris machine:

# peer host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
# server host_address [ key # ] [ version # ] [ minpoll interval ] [prefer]
# broadcast host_address [ key # ] [ version # ] [ minpoll interval ]
# driftfile filename
# broadcast yes|no
# broadcastdelay seconds
# authenticate yes|no
# authdelay seconds
# keys filename
# trustedkey # [ # ... ]
# controlkey #
# restrict address [ mask numeric_mask ] [ flag ] [ ... ]
# statsdir /directory/[ prefix ]
# statistics names
# filegen name [ file filename ] [ type typename ] [ link|nolink ] [enable|disable ]
# enabled/disabled
# link/nolink
# keyno  type  key
#
####################
#
# JLAB time servers
server ntp1.jlab.org  version 3  prefer  # stratum 2, Ver 3
server ntp2.jlab.org  version 3          # stratum 2, Ver 3
#
#
driftfile /etc/inet/ntp.drift

3. Start the ntp daemon:

svcadm enable network/ntp

4. Check if it is running:

svcs | grep ntp
   online         16:29:30 svc:/network/ntp:default

5. Make query to make sure everything is Ok:

ntpq -p
        remote           refid      st t when poll reach   delay   offset    disp
   ==============================================================================
   *ns1.jlab.org    time.nist.gov    2 u   27   64   77     0.46   -1.440  387.54
   +ccs1.jlab.org   time.nist.gov    2 u   27   64   77     0.43    1.798  386.89

NOTE: for Solaris 10 update 6 from CD's on clon05 it did not worked, have to start xntpd manuall !!!


Linux

1. Login as 'root'

2. Modify file /etc/ntp.conf commenting out lines

##server 0.pool.ntp.org
##server 1.pool.ntp.org
##server 2.pool.ntp.org

and adding lines

server ntp1.jlab.org
server ntp2.jlab.org

or copy file from another Linux machine.

You can use /usr/bin/system-config-date if available, in that case skip step 3 below. To do it manually:

3. Start daemon:

/etc/init.d/ntpd start
   Starting ntpd:                                             [  OK  ]

4. Check if it is running:

/etc/init.d/ntpd status
   ntpd (pid 15598) is running...

5. Make query to make sure everything is Ok:

ntpq -p
        remote           refid      st t when poll reach   delay   offset  jitter
   ==============================================================================
   ns1.jlab.org    192.43.244.18    2 u   57   64    7    0.245  35139.8   1.521
   ccs1.jlab.org   192.43.244.18    2 u   50   64    7    0.522  35138.7   1.351

6. To start service at next boot do following:

###chkconfig --add ntpd (normally linux has it already)
chkconfig --level 3 ntpd on
chkconfig --level 4 ntpd on
chkconfig --level 5 ntpd on
chkconfig --list ntpd
   ntpd            0:off   1:off   2:off   3:on   4:on   5:on    6:off

If 'chkconfig' tool does not exist, make symbolic links manually, for example:

/etc/rc0.d/K74ntpd -> ../init.d/ntpd
/etc/rc1.d/K74ntpd -> ../init.d/ntpd
/etc/rc2.d/K74ntpd -> ../init.d/ntpd
/etc/rc3.d/K74ntpd -> ../init.d/ntpd
/etc/rc3.d/S58ntpd -> ../init.d/ntpd
/etc/rc4.d/K74ntpd -> ../init.d/ntpd
/etc/rc4.d/S58ntpd -> ../init.d/ntpd
/etc/rc5.d/K74ntpd -> ../init.d/ntpd
/etc/rc5.d/S58ntpd -> ../init.d/ntpd
/etc/rc6.d/K74ntpd -> ../init.d/ntpd

NOTES:

/etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.
Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.
Run ``date MMDDhhmm to set the current system date/time.
Type ``/sbin/hwclock --systohc [--utc] to set the hardware clock.

Daylight protocol

To obtain information about when time will be switched use following example:

zdump -v America/New_York | grep 2007

It must produces similar to following:

America/New_York  Tue Mar  6 16:55:25 2007 UTC = Tue Mar  6 11:55:25 2007 EST isdst=0 
America/New_York  Sun Mar 11 06:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 EST isdst=0
America/New_York  Sun Mar 11 07:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 EDT isdst=1
America/New_York  Sun Nov  4 05:59:59 2007 UTC = Sun Nov  4 01:59:59 2007 EDT isdst=1
America/New_York  Sun Nov  4 06:00:00 2007 UTC = Sun Nov  4 01:00:00 2007 EST isdst=0

Make sure dates are correct (V SOOTVETSTVII S POSLEDNIM RESHENIEM KPSS).