Linux OS Service 'ntpd' (文档 ID 551704.1)

Linux OS Service ‘ntpd‘ (文档 ID 551704.1)

APPLIES TO:

Linux OS - Version Oracle Linux 4.4 to Oracle Linux 6.5 with Unbreakable Enterprise Kernel [3.8.13] [Release OL4U4 to OL6U5]
Linux x86
Linux x86-64
Linux Kernel - Version: 4.4 to 6.5
***Checked for relevance on 11-July-2014***

PURPOSE

This is a reference document to describe Linux operating system service ‘ntpd‘ with respect to its use, scope, nature and applicability.

SCOPE

This document is useful for Linux operating system administrators for the specific Linux OS service ‘ntpd‘

DETAILS

Service Name

ntpd

Description

This service executes the Network Time Protocol (NTP) daemon ntpd.  The purpose is to synchronize the time of the local computer to a NTP server or other reference time source such as a radio or satellite receiver or modem.  The NTP time protocol provides accuracies typically within a millisecond on LANs and up to a few tens of milliseconds on WANs relative to Coordinated Universal Time (UTC) via a Global Positioning Service (GPS) receiver. The Linux NTP package is a complete implementation of the Network Time Protocol (NTP)  version  4,  but also  retains  compatibility with prior versions 1, 2, and 3.

The NTP system uses two main roles for participating computers: server or client.  Time servers supply time to one or more NTP clients.  NTP clients use the reference time from one or more NTP servers to determine the local time.  This scheme allows an NTP client to reject bogus time from an NTP server; to compensate for network-induced delays; and to determine which NTP server has the best time.  An NTP client may also server as an NTP server for other machines.

The  ntpd  program operates by exchanging messages with one or more configured servers at designated poll intervals.  The program requires several exchanges from the majority of  chosen  servers  so  the  signal  processing  and mitigation algorithms can accumulate and groom the data before setting the local clock.

Usually each country provides an official time reference.  In the USA, the National Institute of Standards  (NIST) provides this service.  The national time reference is called a tier 1 server.  NTP servers who use this source for their reference time are called tier 2servers.  NTP servers who connect to tier 2 servers are known as tier 3 servers, and so on.  NTP clients who use their own atomic clocks are also called tier 1 servers.  NTP clients must connect to an NTP server to synchronize their clocks.  Some ISPs provide NTP server access to their clients, but publicly-accessible servers at pool.ntp.org are also available.  Higher-tier NTP servers are usually no less accurate than their lower-tier counterparts, which can get overburdened.  Many companies implement their own NTP server by connecting to external NTP servers, reducing the load on these external servers.

Most machines have  a real-time chip (RTC) to maintain the time during periods when the power is off.  When the machine is booted, the calendar chip is used to initialize the operating system time; the ntpdate(1) program can also be used to set the local time from a reference NTP server..  After the machine has synchronized to an NTP server, the operating system corrects its notion of time gracefully.  Under ordinary condition, ntpd adjusts the O/S clock in small steps so that the timescale is effectively monotonic, without discontinuities.  Once the clock has been set, its accuracy is continuously checked and adjustments for any drift are stored into a local file and are thus saved across reboots.  Usually at system shutdown the O/S updates this RTC clock chip with the current time, thus closing the cycle.

The Linux NTP service is quite configurable.  Comprehensive on-line documentation is supplied in both ntpd(1) manual pages and/usr/share/doc/ntp-<version> documentation.

Note: this service is needed even for NTP clients.  The server/client role is distinguished by its configuration.

The RPM package containing this service:

ntp

Nature

Daemon service

Service Control

This service is handled by init.d script /etc/init.d/ntp. Its usage  is as follows:

# /sbin/service ntpd
usage: /etc/init.d/ntpd {start|stop|restart|condrestart|status}
#

Start the service as follows:

# /sbin/service ntpd start
ntpd: Synchronizing with time server:                      [  OK  ]
Starting ntpd:                                             [  OK  ]
#

Stop the service as follows:

# /sbin/service ntpd stop
Shutting down ntpd:                                        [  OK  ]
#

Check if the serivce is started or stopped:

# /sbin/service ntpd status
ntpd is stopped
#

If the service is started, then restart it; otherwise do nothing.  Typically used only by the RPM install scripts.

# /sbin/service ntpd condrestart
Shutting down ntpd:                                        [  OK  ]
Starting ntpd:                                             [  OK  ]
#

Determine which system  run levels the service is active:

# /sbin/chkconfig --list ntpd
ntpd            0:off   1:off   2:off   3:on    4:off   5:on    6:off
#

Configuration

Ordinarily, ntpd reads the ntp.conf configuration file at startup time in order to determine the synchronization sources and operating modes.  It is also possible to specify a working, although limited, configuration entirely on the command line, obviating the need for a configuration file.

Usually, the configuration file is installed in the /etc directory, but could be installed elsewhere (see the -c conffile command line option). The file format is similar to other Unix configuration files - comments begin with a # character and extend to the end of the line; blank lines are ignored.

The default ntp.conf file like this:

restrict default nomodify notrap noquery

restrict 127.0.0.1

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

server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift
broadcastdelay  0.008

keys            /etc/ntp/keys

In addition, ntpd daemon can be run with various options. In order to add command line options to the ntpd service (/etc/init.d/ntpd), one has to edit /etc/sysconfig/ntpd file and add the desired option to the OPTIONS variable, and restart the service via ‘service ntpd restart‘.

For example, the -x argument is mandatory for RAC configurations and the /etc/sysconfig/ntpd file looks as:

# Drop root to id ‘ntp:ntp‘ by default.
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

# Set to ‘yes‘ to sync hw clock after successful ntpdate
SYNC_HWCLOCK=no

# Additional options for ntpdate
NTPDATE_OPTIONS=""

You can check the settings from that /etc/sysconfig/ntpd file but it will not be reliable if the ntpd process is started manually for some reason. To check the arguments you can use command line:

# ps -o args -p `cat /var/run/ntpd.pid`
COMMAND
ntpd -x -u ntp:ntp -p /var/run/ntpd.pid
#

Files:

/etc/ntp/ntp.conf  - the default name of the configuration file
/var/lib/ntp/drift  - the default name of the drift file
/etc/ntp/keys      - the default name of the key file

/etc/sysconfig/ntpd  - setting command line options for ntpd daemon

Recommendation

There should be at least three ntp servers configured, preferably four or five.  See the NTP "faq"  for additional information. The main reason is that in case of failure of one or more servers there can still greater than 50% consensus of the correct time.

See Also

See the man page ntpd(1)
      See the man page ntpdate(1)
      http://www.ntp.org/

Notes

None

Linux OS Service 'ntpd' (文档 ID 551704.1)

时间: 2024-10-24 15:15:03

Linux OS Service 'ntpd' (文档 ID 551704.1)的相关文章

Customer Introduction to ORA-7445 Errors (文档 ID 211909.1)

In this Document   Purpose   Scope   Details   References Applies to: Oracle Database - Enterprise Edition - Version 7.0.16.0 to 11.2.0.2 [Release 7.0 to 11.2] Information in this document applies to any platform. Add ***Checked for relevance on 14-M

PRVF-4664 PRVF-4657: Found inconsistent name resolution entries for SCAN name (文档 ID 887471.1) &nbsp;

In this Document Applies to: Oracle Server - Enterprise Edition - Version 11.2.0.1 to 11.2.0.3 [Release 11.2]Information  in this document applies to any platform. Purpose runInstaller (OUI) reports INS-20802 while running Oracle Cluster Verification

How to Analyze Problems Related to Internal Errors (ORA-600) and Core Dumps (ORA-7445) using My Oracle Support (文档 ID 260459.1)

Oracle Database - Enterprise Edition - Version 8.1.7.4 and later Information in this document applies to any platform. **Checked for relevance 06-Apr-2010 **Checked for relevance 17-Apr-2013 *** Checked for relevance on 16-Nov-2011 *** Purpose 1.1 Ab

Procwatcher: Script to Monitor and Examine Oracle DB and Clusterware Processes (文档 ID 459694.1)

Applies to: Oracle Database - Enterprise Edition - Version 10.2.0.2 to 12.1.0.1 [Release 10.2 to 12.1] Linux x86 HP-UX PA-RISC (64-bit) IBM AIX on POWER Systems (64-bit) Oracle Solaris on SPARC (64-bit) HP-UX Itanium Linux x86-64 Oracle Server Enterp

Troubleshooting &#39;library cache: mutex X&#39; waits. (文档 ID 1357946.1)

In this Document   Purpose   Troubleshooting Steps   What is a 'library cache: mutex X' wait?   What causes 'library cache: mutex X' wait?   How to diagnose the cause.   How to Examine the Diagnostics.   Potential Solutions   References APPLIES TO: O

Master Note for Diagnosing ORA-7445 and Related Core Dumps (文档 ID 1092855.1)

In this Document   Details   Actions   Concepts/Definitions   Diagnosing (starting point isNote 7445.1)   Additional Resources   Community:Incident (600-7445) Analysis and Other Diagnostics   References Applies to: Oracle Database - Enterprise Editio

TECH: Getting a Stack Trace from a CORE file on Unix (文档 ID 1812.1)

修改时间:2013-4-8类型:BULLETIN Introduction ~~~~~~~~~~~~ This short article aims to explain how to get a stack trace from a core dump produced by any of the Oracle products on Unix platforms. By following the steps below you can provide Oracle Support with

How to Create an OCM Response file to Apply a Patch (文档 ID 966023.1)

How to Create an OCM Response file to Apply a Patch in Silent Mode - opatch silent (文档 ID 966023.1) APPLIES TO: Oracle Universal Installer - Version 10.2.0.1 to 11.2.0.4 [Release 10.2 to 11.2]Oracle Database - Enterprise Edition - Version 10.2.0.1 to

How to Send an Email Using UTL_SMTP with Authenticated Mail Server. (文档 ID 885522.1)

APPLIES TO: PL/SQL - Version 9.2.0.1 to 12.1.0.1 [Release 9.2 to 12.1]Information in this document applies to any platform.***Checked for relevance on 07-Apr-2014*** GOAL The UTL_SMTP package is designed for sending electronic mails (emails) over Sim