Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Linux system with ntp system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to configure the ntp system on the Linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The data generation and processing system is a cluster of computing devices. Computing devices use unified and synchronous standard time to record the timing of various events, such as E-MAIL information, file creation and access time, database processing time and so on. The data or operations such as control, calculation, processing and application between different computing devices in big data system are sequential. If the computer time is not synchronized, these applications or operations may not be carried out normally.

(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

(5) some reference excerpts from other blogs = / etc/ntp.conf configuration content =

# 1. First deal with the issue of permissions, including the release of upper-layer servers and open LAN users: restrict default kod nomodify notrap nopeer noquery restrict-6 default kod nomodify notrap nopeer noquery restrict 220.130.158.71 restrict 59.124.196.83 restrict 59.124.196.84 restrict 127.0.0.1 restrict-6: 1 restrict 192.168.100.0 mask 255.255.255.0 nomodify # 2. To set the host source, please comment out the original [0 | 1 | 2] .centos.pool.ntp.org: server 220.130.158.71 prefer server 59.124.196.83 server 59.124.196.84 # 3. The default internal clock data is used to serve LAN users when there is no external NTP server: # server 127.127.1.0 # local clock # fudge 127.127.1.0 stratum 10 # 4. Preset time difference analysis files and temporarily unused keys, etc., do not need to change it: driftfile / var/lib/ntp/drift keys / etc/ntp/keys

= restrict option format = restrict [client IP] mask [IP mask] [parameter]

"client IP" and "IP mask" specify which range of computers in the network to control. If the default keyword is used, all computers are controlled. The parameters specify specific restrictions. Common parameters are as follows:

◆ ignore: refuse to connect to the NTP server

◆ nomodiy: the client cannot change the time parameter of the server, but the client can calibrate the time on the network through the server.

◆ noquery: no client time query is provided

◆ notrap: does not provide trap remote login function, trap service is a remote time logging service.

◆ notrust: unless the client is authenticated, the client source is considered an untrusted subnet.

◆ nopeer: provides time services, but not as peers.

◆ kod: sends Kiss-Of-Death messages to insecure visitors.

= server option format = server host [key n] [version n] [prefer] [mode n] [minpoll n] [maxpoll n] [iburst]

Where host is the IP address or domain name of the upper-layer NTP server, and the following parameters are explained as follows:

◆ key: indicates that all messages sent to the server contain authentication information encrypted by the secret key. N is a 32-bit integer indicating the key number.

◆ version: indicates the version number used for messages sent to the upper server. N defaults to 3, which can be 1 or 2.

◆ prefer: if you have more than one server option, the server with this parameter is limited.

◆ mode: specifies the value of the Datagram mode field.

◆ minpoll: specifies that the minimum time interval between querying the server and the server is 2 to the power of n, n defaults to 6, and the range is 4-14.

◆ maxpoll: specifies that the maximum time interval between querying the server and the server is 2 to the power of n, n defaults to 10, and the range is 4-14.

◆ iburst: when the initial synchronization request is made, the burst mode is used to send 8 messages in succession with an interval of 2 seconds.

= View gateway method = [Command 1] route-n

[command 2] ip route show

[command 3] netstat-r

= hierarchy (stratum) = stratum is set according to the hierarchy of the upper server (+ 1).

For hosts that provide network time service provider, the stratum setting should be as accurate as possible.

Time service provider, as a local area network, usually sets stratum to 10.

The server at layer 0 uses physical devices such as atomic clock and GPS clock, and stratum 1 is directly connected to stratum 0.

The future stratum is connected to the upper layer stratum through the network, and the server at the same layer can also interact.

Ntpd is service server for the lower client and client for the upper server.

Ntpd decides whether to provide clock services for other servers or synchronize clocks from other servers based on the parameters of the configuration file. All the configurations are in the / etc/ntp.conf file.

= pay attention to firewall shielding ntp port = the default port of ntp server is 123. if the firewall is on, errors may occur in some operations, so remember to turn off the firewall.

= synchronize hardware clock = ntp service, only system time is synchronized by default.

If you want ntp to synchronize hardware time at the same time, you can set the / etc/sysconfig/ntpd file

In the / etc/sysconfig/ntpd file, add [SYNC_HWCLOCK=yes] so that the hardware time is synchronized with the system time.

Allow BIOS to synchronize with system time, or through the hwclock-w command.

Big data system is a time-sensitive computing processing system. Time synchronization is the basic guarantee for big data to be handled correctly and the technical support for big data to play a role.

In the era of big data, big data communication in the whole processing computing system was carried out through the network.

The same is true of time synchronization. Big data's Internet is used to transmit standard time information to achieve time synchronization in big data's system.

This is the end of the article on "how to configure the ntp system in Linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report