- Brief introduction
- Principle
- Configuring the NTP server
- To synchronize
Brief introduction
When calculating the time, the most accurate calculation should be the use of "atomic oscillator cycle" calculated by the physical clock (Atomic clock, also known as atomic clock), which is also defined as the standard Time (international Atomic times). And the UTC that we often see is coordinated Universal time (Concord Standard) is the correct time defined by this Atomic Clock. This UTC standard time is based on GMT, the time zone. So the difference between local time and UTC time is the difference between local time and GMT time.
The internal BIOS of the computer host contains an atomic clock, because the atomic clock is mainly used in the calculation chip (crystal) of the atomic oscillator cycle to time, each chip has its own unique oscillation cycle. And the computer is mainly in the BIOS internal time as the main time basis, but this time may be due to the BIOS internal chip itself problem, and lead to the BIOS time and Standard Time (UTC) difference exists, so, in order to avoid the host time due to long-term operation caused by the time deviation, it is necessary The network time Protocol NTP function is synchronized.
Principle
1. The host will of course need to start daemon
2. The Client sends a message with the tuning time to the NTP Server
3. NTP Server will send the current standard time to the Client
4. After the Client receives the time from the Server, it adjusts its own time.
However, there is a time lag and delay of synchronization between client side and server side, and in the daemon part, the server/client and Master/slave architectures are provided to provide the user with the action of network alignment to ensure the calibration times are more accurate.
Installation configuration
- install NTP service
# Yum install-y NTP ntpdate
 
- Configuring the NTP Service
Editing a configuration file/etc/ntp.conf
Ignore: Turn off all NTP online services
Nomodify: Indicates that the client side cannot change the server-side time parameter, but the client side can still synchronize time through the server side
Notrap: Rejecting a special NTPDQ capture message
Noquery: Reject BTODQ/NTPDC Query
Server: Add settings for upper-level hosts or add as NTP servers on the Internet
The annotations in the configuration file are also very clear.
(This figure is just another example)
- add firewall rules and start NTP service
#iptables –A input–p udp–i eth0–s 10.0.7.0/24–dport 123–j ACCEPT
#systemctl start ntpd
- On client operations:
- Download and install NTP
- Synchronizing with Ntpdate
#ntpdate NTP server-side IP
If the synchronization is successful, but the time is not synchronized, it may be a time zone problem, the easy way to modify the time zone is available:
Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime
If "No server suitable for synchronization found" appears, check that the NTP server is properly configured and the firewall settings are correct, etc., if not, try synchronizing the NTP server on the network, such as Ntpdate Time.nist.gov (if the client needs to be able to network)
#date
Show System time
#hwclock
Display System Hardware Time
#hwclock-W
Write system time to system hardware
Timed time synchronization tasks are performed, so we use CRONTAB-E to add timed tasks
* 1/* * * root/usr/sbin/ntpdate 10.0.7.149;hwclock-w
NTP server configuration under Linux