How to configure NTP Service in Linux system
Editor to share with you how the Linux system to configure NTP services, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
Introduction to NTP: NTP is a protocol used to synchronize computer time, it enables the computer to synchronize its server or clock sources (such as quartz clock, GPS, etc.), it can provide high-precision time correction (the difference between LAN and standard is less than 1 millisecond, WAN dozens of milliseconds), and can be encrypted to confirm the way to prevent malicious protocol attacks.
(1) confirm the installation of ntp 1) confirm whether ntp [command] rpm-qa is installed | grep ntp
If there is only ntpdate but no ntp, you need to delete the original ntpdate. Such as:
Ntpdate-4.2.6p5-22.el7_0.x86_64
Fontpackages-filesystem-1.44-8.el7.noarch
Python-ntplib-0.3.2-1.el7.noarch
2) delete the installed ntp [command] yum-y remove ntpdate-4.2.6p5-22.el7.x86_64
3) reinstall ntp [command] yum-y install ntp
(2) configure ntp service 1) modify the / etc/ntp.conf [command] vi / etc/ntp.conf of all nodes
[content]
Restrict 192.168.6.3 nomodify notrap nopeer noquery / / current node IP address
Restrict 192.168.6.2 mask 255.255.255.0 nomodify notrap / / the gateway (Gateway) and subnet mask (Genmask) of the network segment where the cluster is located.
2) Select a primary node and modify its / etc/ntp.conf [command] vi / etc/ntp.conf
[content] add the following section to the server section and comment out server 0 ~ n
Server 127.127.1.0
Fudge 127.127.1.0 stratum 10
3) in addition to the primary node, continue to modify / etc/ntp.conf [command] vi / etc/ntp.conf
[content] add the following statement to the server section to point the server to the master node.
Server 192.168.6.3
Fudge 192.168.6.3 stratum 10
= before modification =
= modified =
Node 1 (192.168.6.3):
Node 2 (192.168.6.4):
Node 3 (192.168.6.5):
(3) start ntp service and view status 1) start ntp service [Command] service ntpd start
2) check whether the ntp server is connected to the upper ntp [command] ntpstat
When viewing the ntp status, you may see something like the following
① unsynchronised time server re-starting polling server every 8 s
② unsynchronised polling server every 8 s
This is normal, and after the ntp server is configured, you need to wait 5-10 minutes to synchronize with the standard time configured in / etc/ntp.conf.
After a while, use the ntpstat command to check the status again, and the normal result will be as follows:
3) check the status of ntp server and upper ntp [command] ntpq-p
Remote: the ip or hostname of the native and upper ntp. "+" indicates priority, and "*" indicates secondary priority.
Refid: refer to the upper layer ntp host address
St:stratum class
When: how many seconds ago have you synchronized the time
Poll: how many seconds after the next update
Reach: the number of updates that have been requested from the upper ntp server
Delay: network delay
Offset: time compensation
Jitter: the difference between system time and bios time
4) View the status of the ntpd process
[command] watch "ntpq-p"
[terminate] press Ctrl+C to stop viewing the process.
The characters in the first column indicate the quality of the source. An asterisk (*) indicates that the source is the current reference.
Remote: lists the IP address or host name of the source.
When: indicates the elapsed time (in seconds) since the polling source.
Poll: indicates the polling interval. This value increases accordingly according to the accuracy of the local clock.
Reach: is an octal number indicating the accessibility of the source. A value of 377 indicates that the source has answered the first eight consecutive polls.
Offset: is the time difference (milliseconds) between the source clock and the local clock.
(4) set boot [command] chkconfig ntpd on
These are all the contents of the article "how to configure NTP Services in Linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!