linux time synchronizes the installation and configuration of the ntp service

  • 2020-05-10 23:24:24
  • OfStack

1. To install ntp service, to use time synchronization, both the server and the client need to use the following command to install NTP software package


[root@5201351 ~]# yum install ntp -y

2. If you are only a client, the configuration can be as simple as editing the /etc/ ntp.conf file and commenting out the default default of the following four lines

In addition, we can add the IP address or domain name of our time synchronization server, where the prefer option indicates that we prefer to use this time synchronization server


#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst // Among them iburst  : when 1 A fortune NTP Send to the server when it is unavailable 1 Serial and send out the package for testing. 
server 192.168.0.2
server 192.168.0.1 prefer
logfile /var/log/ntpd.log // Adding log information is not a required option 

3. Then restart the ntpd.service service to synchronize the time to the superior NTP server

======== ===NTP for server configuration > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

4. Of course, at work, and perhaps more often, we have to configure our own server to be the NTP time synchronization server so that other clients can synchronize

5. In the same way, step 1 also needs to install NTP service. As the NTP server, we need to add those IP which can synchronize the time


restrict 192.168.0.3 // In the default restrict 127.0.0.1 Plus this 1 Article can be 
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap // You can also add in this format 

6. Finally, restart the ntpd.service service to enable the specified network host and network segment to take two steps.

#########################################################

A description of some of the other options in profile 1 is as follows:


restrict default kod nomodify notrap nopeer noquery // Refused to  IPv4  The user , The default is none kod
restrict -6 default kod nomodify notrap nopeer noquery // Refused to  IPv6  The user 
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap // Releases the specified segment 

#########################################################

Finally, the author adds 1 more about time in linux > > > > > > > >

1. Time in linux is divided into system time and hardware time. System time can be viewed by date command

The hardware time is viewed using either the hwclock or hwclock-r commands

2. System setting time: date-s "2016-01-15 15:58:00"

Hardware setting time: hwclock --set --date "2016-01-15 15:58:00"

3. System time -- > Synchronization to - > Hardware time: hwclock-w

4, hardware time -- > Synchronization to - > System time: hwclock-s


Related articles: