Application of time synchronization server (NTP time server) in distributed database system

Time synchronization server (NTP time server) is used in distributed database system
Time synchronization server (NTP time server) is used in distributed database system

Abstract: With the rapid development of the network and the increasing number of devices, many network applications and network security have put forward an urgent need for time synchronization. Therefore, NTP-based time synchronization solutions have become a reasonable choice to solve these problems. This program introduces the principle, working mode and architecture of the NTP protocol in the network time synchronization technology of large-scale production enterprises, and discusses the application of NTP in the enterprise network in combination with the enterprise's MES network structure.
1. Introduction:
With the popularization of the network, many enterprises have built their own campus networks, and the network equipment and servers used are increasing. These devices have their own clocks, and they can be adjusted. However, there is no guarantee that the time of all devices and hosts in the network are synchronized, because these clocks will generate errors of several seconds or even minutes every day. After long-term operation, the time difference will become larger and larger. This kind of deviation does not have much impact in a single machine, but may cause unexpected problems in applications in a network environment. For example, in a distributed computing environment, because the time of each host is inconsistent, the recording time of the same operation on different hosts will be inconsistent, which will cause the service to not be performed normally, and the results of the business transactions of the enterprise are predictable.
2. Overview of time synchronization:
The time information (year, month, day, hour, minute, and second) of the host server or various devices in the network environment is limited to a sufficiently small range based on UTC (Universal Time Coordinated) (such as 1-10ms) , This synchronization process is called time synchronization.
3. The working principle of
NTP : 3.1. Overview of NTP
NTP was first designed and implemented by a professor at the University of Delaware in the United States, and developed from the time protocol, ICMP timestamp messages, and IP timestamp options. NTP is used to synchronize the time of a computer client or server to another server or reference clock source. It uses UTC as the time standard. It is an application layer protocol based on the connectionless IP protocol and UDP protocol. It uses a hierarchical time distribution model. The accuracy that can be achieved depends on the accuracy of the local clock hardware and the delay to the device and process. strict control. When configuring, NTP can use redundant servers and multiple network paths to obtain high accuracy and high reliability of time. Figure 1 is the NTP information in a UDP packet. Among them, LI is the indication of the insertion or deletion of seconds; VN is the version number of the NTP protocol; Mode, Stratum and Precision represent the working mode, clock level and local clock accuracy respectively. Poll is the expected value of the current time interval for sending NTP messages. Root Delay represents the total delay of the main reference source. Root Dispersion represents a normal error relative to the main reference source. Synchronizing Distance and Synchronizing Dispersion are the current round-trip delay and the error range relative to PRS. Reference Timestamp represents the type of current clock reference source and the last update time, and is set up for management purposes. The following three fields represent three timestamps: the time when the sender of the Organic Timestamp last touched the packet, the time when the receiver of Receive Timestamp received the packet, and the time when the receiver of Transmit Timestamp sent the echo reply. Authenticator is a key indicator and encrypted check box.
Database clock synchronization

Figure 1: NTP information in UDP packets
3.2. The working principle of
NTP The most critical reason for the accuracy of the NTP protocol lies in the inaccuracy of the clock delay calculation caused by the randomness of the network delay. Due to the inaccurate delay, it is impossible to rely on the unilateral transmission from the time server to the client to transmit accurate time information. To solve this problem, the two-way information exchange between time server and client and the concept of timestamp are used in the NTP protocol.
3.3. NTP
working modes There are three working modes of NTP
: ⑴Client/Server mode: The client periodically requests time information from the server. The server is used to synchronize the client but cannot be synchronized by the client. The client first sends an NTP packet to the server, which contains the time stamp when the packet leaves the client. When the server receives the packet, it fills in the time stamp when the packet arrives, the source address and destination address of the exchange packet, and Fill in the time stamp when the packet left, and then immediately return the packet to the client. When the client receives the response packet, it fills in the time stamp when the packet returns. With these time parameters, the client can calculate two key parameters: the round-trip delay of packet exchange and the clock offset between the client and the server. The client uses the clock offset to adjust the local clock so that its time is consistent with the server time.
⑵ Active/passive symmetry mode: basically the same as the client/server mode. The only difference is that both parties can synchronize or be synchronized by each other.
⑶ Broadcast mode: there is no synchronized initiator. In each synchronization cycle, the server broadcasts a message packet with its own timestamp to the network, and all target nodes passively receive these messages to adjust their time. Generally used in places where the network delay is very small, or the time accuracy is not high, like in a local area network, the use of broadcast mode can save bandwidth.
3.4. NTP system architecture
NTP uses a hierarchical time distribution model. The network architecture mainly includes the transmission path between the master time server, slave time server, client and each node. The main time server synchronizes with the high-precision time source and provides time services for other nodes. Each client obtains time synchronization from the time server via the main server. Under normal circumstances, nodes (including time servers and clients) only use the most reliable and accurate server and transmission path for synchronization, so the usual synchronization path is a hierarchical structure. Among them, the master time server is located at the root node, and other slave time servers are located on the layer close to the leaf nodes as the synchronization accuracy increases, and the host and server are located at the leaf nodes. NTP divides the transmission path into an active synchronization path and a backup synchronization path, both of which transmit time information packets at the same time, but nodes only use the active synchronization path data for synchronization processing.

Figure 2: An implementation model of
the client/server model In this model, the local clock process: processes the offset obtained by the correction module and adjusts the phase and frequency of the local clock with a special algorithm in NTP. Transmission process: Triggered by different timers corresponding to each remote entity to collect information from the database and send NTP messages to the remote entity. Each message includes the local timestamp when it was sent, the timestamp of the previous reception, and the information used to determine the synchronization network hierarchy and manage the connection. Receiving process: Receive NTP messages and calculate the offset between the remote clock and the local clock. Correction module: Process the offset between each remote entity, and use an algorithm in NTP to select the best one. Local clock process: Process the offset obtained by the correction module and adjust the local clock with a special algorithm in NTP.
4. Application of clock server in enterprise MES system
4.1 Overview of
MES MES (Manufacturing Execution System) factory manufacturing execution management system is the link of enterprise information integration, and the basic technology for implementing enterprise agile manufacturing strategy and realizing agile workshop production . MES deals with the production and sales of products, focusing on ordering, delivery time, cost and customer contact, etc. The requirements for time are harsh.
4.2. For the MES system with
such an important time synchronization framework for the MES system, the importance of network time synchronization is visible. The clock server is a high-tech product that corrects time for the computer servers and network equipment in the MES system. Obtain standard time signals from GPS satellites, and transmit these information through various NTP network interfaces to the equipment that needs time information in the MES system, so that the standard clock source in the network can achieve the time synchronization of the entire system.

Guess you like

Origin blog.csdn.net/weixin_44990608/article/details/108495426