Linux network clock synchronization (ntp and chrony)

We all know that can be used outside the network clock synchronization server, including when not connected to external networks within the network clock synchronization need, how to proceed?

A stable server within the network selected as the clock source, and then let the other machines are synchronized to the machine.

Note: In fact, almost the ntp service and service chrony nature, can be synchronized with each other between them. However, in order to avoid unnecessary trouble, generally only choose the same server to synchronize the clock in terms of service.

A, ntp service

Installation: yum install ntp

1, the server settings

Modify the configuration file cat /etc/ntp.conf

The following commented clock source external network (preceded by #)

 

 

 

 If this network as the server, then the clock source, is provided as follows

ntp synchronize the local clock

server 127.127.1.0  # local clock         

fudge 127.127.1.0  stratum 10

Demand modified as follows:

restrict 10.0.0.0 mask 255.255.255.0 # 10.0.0.0 allows access to the network server in the server for time synchronization ntp (according to its own network)
the restrict allows a single IP address 10.0.0.16 # ntp access to the server (by ip to)

restrict 192.168.111.0 mask 255.255.255.0 nomodify notrap # allow other machines within the network synchronization time, if you do not add the default constraint allows access to all IP native synchronization service

Other configurations do not make changes, save and exit the configuration file

Restart systemctl restart ntpd

View ntp status systemctl status nptd

Check whether the clock to synchronize: ntpq -p command to view with an asterisk * is synchronized

ntpstat command to check the time synchronization status, this normally takes 5-10 minutes to successfully connect and sync

 

2, the other client configuration:

 

 vim /etc/ntp.conf

Commented at the beginning of the server

Adding server IP (here is the ip IP is the clock source of the upper end of the service) iburst

Systemctl restart ntpd to restart

See ntpq -p synchronization state, it has a value below the front and the asterisk * ip normal

 

 

二、chrony

Now a lot of latest machines are synchronized with the chrony

Installation: yum install chorny

Server:

Configuration: vim /etc/chrony.conf

Comment out the first network clock source, do as follows

server 127.0.0.1 iburst # local clock source
local stratum 10 # allows local synchronization
allow # Allow all connections

Boot: systemctl enable chronyd

Start Service: systemctl start chronyd

View status: systemctl status chronyd

View sync: chronyc sources -v with an asterisk * are successful synchronization

 

Or: timedatectl command, NPT synchronized to yes is the synchronization is complete

 

 The client is then set as the clock source of this server

vim /etc/chrony.conf

server ip (on one side of the service ip) iburst

Coupled with his party

Allow all allow #

 

Save out. 

chronyc sources view the synchronization status, configuration and just show ip ip there in front asterisk * ^ is the symbol of this success is failure


   

 

 

Guess you like

Origin www.cnblogs.com/flyxuxi/p/11811259.html