X

How To Install NTPD On CentOS 7

NTP (Network Time Protocol) is a protocol which allows computers to synchronize time.  NTPd is a daemon that maintains the system time in synchronization with other NTP servers. This prevents drift which is the slow inconsistency of time on computers internal clocks. Keeping system time accurate is particularly important for system logs, replication, and applications.

Install NTPD

First you will want to install ntp, this is found in the default repostory

yum -y install ntp

CentOS 7 ships with chronyd as a default package, so you will want to disable that as well

Stop the service:

systemctl stop chronyd.service

Disable the service:

systemctl disable chronyd.service

Both chronyd and ntpd be used at the same time.

Configure NTP

You will then want to locate the closest timeservers to you you can find them here In this case we are going to leave the default servers that ship with the rpm

server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

Adding or removing servers would be done in /etc/ntp.conf

Enable And Start NTP

You will then want to start the ntpd service

systemctl start ntpd

And make sure the service will start on reboot

systemctl enable ntpd

You will also want to allow ntp in the firewall

firewall-cmd --add-service=ntp --permanent

Then reload the firewall

firewall-cmd --reload

You can then verify it has is working correctly

# systemctl status ntpd
● ntpd.service - Network Time Service
 Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
 Active: active (running) since Mon 2017-07-31 13:27:12 EDT; 5min ago
 Main PID: 810 (ntpd)
 CGroup: /system.slice/ntpd.service
 └─810 /usr/sbin/ntpd -u ntp:ntp -g

You are looking for the ‘active (running)’ statement. That is it for installing ntpd.

Performing A Manual NTP Sync

How to perform a manual update of the system clock with ntp

First stop the service to free up the port (123) to be used for the manual update:

systemctl stop ntpd

Run the update:

# ntpd -gq
ntpd: time slew +0.009586s

-g is to update the time no matter how much of a offset.
-q is to exit immediately after setting the time.

Regard ntpd service:

systemctl start ntpd

That is all that is required for a manual sync.

LinuxAdmin.io
0 0 votes
Article Rating
LinuxAdmin.io:
Related Post