Linux OS Service ' ntpd ' (document ID 551704.1)

Source: Internet
Author: User
Tags local time

Linux OS Service ' ntpd ' (document 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 ol6u 5]
Linux x86
Linux x86-64
Linux kernel-version:4.4 to 6.5
Checked for relevance on 11-july-2014***


PURPOSE

This was a reference document to describe Linux operating system service ' NTPD ' with respect to it use, scope, nature and Applicability.

SCOPE

This document was 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 Radi  O 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 W ANs relative to coordinated Universal time (UTC) via a Global positioning Service (GPS) receiver. The Linux NTP package was a complete implementation of the Network time Protocol (NTP) version 4, but also retains COM Patibility with prior versions 1, 2, and 3.

The NTP system uses the 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 a NTP client to reject bogus time from an NTP server; To compensate for network-induced delays;  and to determine which NTP server have the best time. An NTP client may also server as a NTP server for other machines.

The NTPD program operates is 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 is called Tier 2servers.  NTP servers who connect to Tier 2 servers is known as Tier 3 servers, and so on.  NTP clients who use their own atomic clocks is also called Tier 1 servers.  NTP clients must connect to a NTP server to synchronize their clocks.  Some ISPs provide NTP server access to their clients and publicly-accessible servers at pool.ntp.org is also available.  Higher-tier NTP servers is 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 s Ervers.

Most machines has a real-time chip (RTC) to maintain, the time during periods when the power is off. When the machine was booted, the calendar chip was used to initialize the operating system time;  The Ntpdate (1) program can also is used to set the local time from a reference NTP server:  After the machine had synchronized to a 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, Withou  T discontinuities. Once the clock has been set, it accuracy is continuously checked and adjustments for any drift be stored into a local fi  Le and is 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> Docume Ntation.

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 was 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 and then restart it;  otherwise does 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 a  nd 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 is 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 is run with various options. In order to add command line options to the NTPD service (/ETC/INIT.D/NTPD), one have 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 are 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'll not being reliable if the NTPD process is started M Anually for some reason. To check the arguments 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 is at least three NTP servers configured, preferably four or five. See the NTP "FAQs" For additional information. The main reason is so in case of failure of one or more servers there can still greater than 50% consensus of the Correc T time.

See Also

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

Notes

None


This article is from "Technical achievement dream!" "Blog, be sure to keep this provenance http://dreamsanqin.blog.51cto.com/845412/1665678

Linux OS Service ' ntpd ' (document ID 551704.1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.