RHEL7: How to set up the NTP service【转载】

Presentation

NTP (Network Time Protocol) is a protocol to keep servers time synchronized: one or several master servers provide time to client servers that can themselves provide time to other client servers (notion of stratus).

This tutorial deals with client side configuration, even though server configuration is not entirely different.

Two main packages are used in RHEL 7 to set up the client side:

  • ntp: this is the classic package, already existing in RHEL 6, RHEL 5, etc.
  • chrony: this is a new solution better suited for portable PC or servers with network connection problems (time synchronization is quicker). chrony is the default package in RHEL 7.

Prerequisites

Before anything else, you need to assign the correct time zone.
To get the current configuration, type:

To get the list of all the available time zones, type:

Finally, to set a specific time zone (here America/Los_Angeles), type:

Then, to check your new configuration, type:

The NTP Package

Install the NTP package:

Activate the NTP service at boot:

Start the NTP service:

The NTP configuration is in the /etc/ntp.conf file:

Note: For basic configuration purpose, only the server directives could need a change to point at a different set of master time servers than the defaults specified.

To get some information about the time synchronization process, type:

Alternatively, to get a basic report, type:

To quickly synchronize a server, type:

The Chrony Package

Alternatively, you can install the new Chrony service that is quicker to synchronize clocks in mobile and virtual systems.

Install the Chrony service:

Activate the Chrony service at boot:

Start the Chrony service:

The Chrony configuration is in the /etc/chrony.conf file:

Note: For basic configuration purpose, only the server directives could need a change to point at a different set of master time servers than the defaults specified.

To get information about the main time reference, type:

To get equivalent information to the ntpq command, type:

To quickly synchronize a server, type:

Note: You don’t need to stop the Chrony service to synchronize the server.

Additional Resources

You can read these Red Hat articles about leap seconds management, how to resolve leap second issues or the differences between NTP and PTP.
The xmodulo website provides a tutorial on How to set up NTP server in CentOS.
Documentation about NTP is available at the NTP Documentation Archive website.

Beyond the exam objectives, virtualization can trigger problems (see this thread) and it is useful to know How to avoid VM clock drift.

You can also be interested in converting a Raspberry PI into a stratum 1 NTP server.

来源: RHEL7: How to set up the NTP service. – CertDepot

发表评论

电子邮件地址不会被公开。 必填项已用*标注