[Make it clear, to say it! NTP time synchronization service Comments]

Contents:
(a) the concept of the NTP server
(two) NTP server settings


(A) The concept of the NTP server
(1.1) NTP (Network Time Protocol ) server is a protocol used to synchronize the computer time, which can make the computer do its synchronization server or clock source (such as a quartz clock, GPS, etc.) technology, which can provide high precision time correction (time difference and the standard LAN less than 1 ms, several tens of milliseconds on the WAN), and can be confirmed via the encrypted manner to prevent malicious protocol attack. NTP time server hierarchically spread, all in accordance with the distance from the external server included in a Stratum different (layer) UTC source.
(1.2) NTP provides precise time, we must first have an accurate source of time, this time should be the international standard time UTC. NTP access to UTC time source can be atomic clocks, observatory, satellite, and is also available on the Internet. So there is an accurate and reliable time source. Time spread by grade NTP server. According to the distance from the outer UTC all assigned to different servers of a Stratum (layer). Stratum-1 at the top, external access to UTC, and Stratum-2 from Stratum-1 acquisition time, Stratum-3 acquisition times from Stratum-2, and so on, but the total number Stratum layer is limited to 15. All of these form a stepped architecture servers logically connected to each other, and Stratum-1 is the time of the server system-wide basis. Typically, the host computer connected with a plurality of time servers, using statistical algorithms filtration time from different servers, to select the best path and the source host to correct the time. In the case of a long time even if the host can not be linked to a time server, NTP services still operate effectively. To prevent vandalism on the event server, NTP uses identification (Authentication) mechanism, information to check whether the server is declared and check the data from the real return path to provide protection against anti-jamming.
(1.3) for example, have a NTP server in our system, then there will be more members of the Taiwan server to be synchronized time. In each host on the motherboard will have a crystal oscillator chip is always in the beating, due to the shock vibration frequency of each chip crystal is not exactly the same, so it is difficult to keep each host time synchronization. At this point we need to ensure the consistency of the NTP server each time the host, for example, is now standard NTP server time is 7:00:00 o'clock, at which point in time is 6:59:00 on A host of points, C host is 7:01:00 hours, then the time will accelerate the beat frequency a host its own crystal oscillator chips to keep up with the NTP server as soon as possible, and C hosts will slow down their own spin-down beat frequency crystal oscillator chips also as soon as possible NTP time server and consistent.
[Make it clear, to say it!  NTP time synchronization service Comments]


(B) set the NTP server
(2.1) has a variety of services in our system of time synchronization, which RHEL 7 system default time synchronization service is chrony, but this service is not easy to use, we use the NTP service. We removed first vms002 host chrony service, and then install the NTP package.
# Yum list chr * --- inquiry chrony service
yum remove chrony.x86_64 -y # --- chrony service will uninstall
# systemctl stop ntpd --- stop ntpd service
# yum remove ntp -y --- NTP before the service uninstall
# /etc/ntp.conf.rpmsave--- will delete rm -rf ntp service remaining files
# yum install ntp -y --- installed NTP services package
[Make it clear, to say it!  NTP time synchronization service Comments]
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.2) and then we edit ntp service profile, wherein the host vms002 / var / lib / ntp / drift document represents the profile of the chip crystal oscillator, and restrict represents "restricted", indicates default "default", nomodify indicates "not allowed to modify", notrap indicates " operation is not allowed trap ", nopeer is not allowed to establish a peer to peer connection, noquery query is not allowed. Then we specify the 192.168.26.0 network host can send a query to the NTP vms002 host, and specify the time the machine reference standard NTP server IP address-based crystal oscillator chip on board 127.127.1.0
# vim /etc/ntp.conf --- edit ntp service profile
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.3) and then we will vms002 host ntp restart the service, and set at startup, because the ntp service is listening on port 123, then we find that the netstat command to query the ntp service has also been in a state of listening.
# Systemctl restart ntpd --- ntp service will restart the
# systemctl enable ntpd --- set at startup
# netstat -tunlp | grep ': 123 ' --- ntp service to see if there are listeners
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.4) Then we host in vms002 set on the current time to adjust to the slow state of about one hour, and then we use the ntpdate command in order to be set according to the time vms001 host on vms002 host sync, then we find time vms002 host has been updated to correct the state of the.
# Date -s "2019-11-12 20:00:00" --- set the system time of the current
# ntpdate 192.168.26.101 --- time and setup time vms001 Time synchronization host's
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.5) Due to the above by the time the way we are ntpdate manually synchronized over time may often produce situations time is not synchronized. So we need to set up a daemon daemon in the system and let it automatically and time synchronization server. At this time we can install the client software ntp (FIG. 2-6) on vms002 host, then open the ntp client software, we entered time synchronization server address 192.168.26.101, and accelerate the initial synchronization check (FIG. 2 -7), wherein if the check is expressed using the local clock source to the crystal oscillation machine's IP address 127.127.1.0 for the time synchronization chip. If we want the client to use the command line to configure, you can set the /etc/chrony.conf configuration file (Figure 2-7-1).
# Yum install system-config-date -y --- ntp client software installed vms002 host
# system-config-date & --- open the graphical interface
# vim /etc/chrony.conf--- client ntp service profiles
[Make it clear, to say it!  NTP time synchronization service Comments]
[Make it clear, to say it!  NTP time synchronization service Comments]
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.6) If we really want to see if the system has been maintained for time synchronization, we can use chronyc command, when we see represented here as "*" when it means the current system time is synchronized a.
# Chronyc sources -v --- query whether the current system time synchronization
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.7)
(2.7.1) we not only use the date command to set the system time, we can also use our timedatectl command to set the system time. We can use the status to view the status of the current system, you can use list-timezones to view the system all the information about the current time zone, using the set-timezone parameter to set the current system time zone.
# Timedatectl --- default and timedatectl status - consistent
# timedatectl status --- view the current system time status
# timedatectl list-timezones --- View all current time zone information system
# timedatectl set-timezone Africa / Dakar --- modification the current time zone is Africa / Dakar
# timedatectl the sET-timeZone Asia / on Shanghai --- modify the current time zone for Asia Shanghai
[Make it clear, to say it!  NTP time synchronization service Comments]
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.7.2) if we want to set the time, you can use the set-time command to set time.
# Timedatectl set-time "2012-12-21 10:00:00 " --- use set-time to set the current system time
[Make it clear, to say it!  NTP time synchronization service Comments]
(2.7.3) if our system is RHEL 6 system, there is no timedatectl command, then how should we modify the time zone information it? We can / usr / share / zoneinfo / Asia / directory in the template files are copied to the current system's / etc / directory localtime time zone, in which case we have / etc / localtime is actually a link to the file (Figure 2-13).
LS # / usr / report this content share / zoneinfo / Asia /
# cp / usr / report this content share / zoneinfo / Asia / on Shanghai / etc / localtime --- copy Shanghai time zone to the / etc / localtime directory
# ls -l / etc / localtime
[Make it clear, to say it!  NTP time synchronization service Comments]
[Make it clear, to say it!  NTP time synchronization service Comments]

------ This concludes the article, thanks for reading ------

Guess you like

Origin blog.51cto.com/13613726/2461838