Linux automatically synchronized network time, and create a local Ntp server.

NTP (Network Time Protocol)
action: each time the host network synchronization, errors in the LAN <0.1ms
architecture: C / S
experimental environment: There are two Centos network, wherein the service end 134, 135 to the client end. 134 synchronized network time server synchronization 134 other time.
1, view system information 134, time and time zone
CAT / etc / RedHat-Release
DATE
timedatectl | grep "Time Zone"
Linux automatically synchronized network time, and create a local Ntp server.
then you can see 134 time zone for Shanghai, and network time are not synchronized
2, view system information 135, time and time zone
CAT / etc / RedHat-Release
DATE
timedatectl | grep "time zone"
Linux automatically synchronized network time, and create a local Ntp server.
then you can see the 135 zone in Shanghai, and network time are not synchronized
3, automatic synchronization Ali cloud time server 134 written plan task settings server server and time synchronization to the local hardware time.

          • /usr/sbin/ntpdate -u ntp1.aliyun.com &>/dev/null
          • /usr/sbin/hwclock -w &>/dev/null

<br/>
4, this time to see the time server 134, and network time synchronization has
Linux automatically synchronized network time, and create a local Ntp server.
5 mounted ntp service server 134, the source need yum. (Configuration yum source https://blog.51cto.com/14015577/2414577 )
yum the install NTP -Y
Linux automatically synchronized network time, and create a local Ntp server.
. 6, the configuration server 134
the NTP profile describes
/etc/ntp.conf
content:
(. 1), the restrict: specify which authorized host can be used time synchronization ntp
format: restrict IP address subnet mask parameters mask
parameters: ignore: Close ntp server
nomodify: Specifies that the client can perform time synchronization, but can not modify the server time
example:
the restrict 192.168.6.123
the restrict 192.168. mask 255.255.255.0 6.0
the restrict 0.0.0.0 mask 0 0 0 0 nomodify
(2), server: Specifies the time to get an external time server from which
examples:
server 0.centos.pool.ntp.org iBurst
server 1.centos.pool. iBurst ntp.org
Server 2.centos.pool.ntp.org iBurst
Server 3.centos.pool.ntp.org iBurst

At this point 134 configuration is as follows:
Server 127.127.1.0
the restrict 127.0.0.1
the restrict 192.168.0.0 mask 255.255.255.0
start ntp service and view the status
systemctl restart ntpd
systemctl Status ntpd
ntpstat
Linux automatically synchronized network time, and create a local Ntp server.

7, 135 client installation ntpdate service
yum -y install ntpdate
Linux automatically synchronized network time, and create a local Ntp server.
8, the client automatically synchronizes scheduled tasks to write 134 times on 135 servers, time synchronization and the time to the hardware
crontab -l

          • /usr/sbin/ntpdate -u 192.168.70.134 &>/dev/null
          • /usr/sbin/hwclock -w &>/dev/null

Linux automatically synchronized network time, and create a local Ntp server.
At this point, you can see 135 time and network time synchronization. The network server 134 can simply sync. Reduce resource consumption.

Guess you like

Origin blog.51cto.com/14015577/2415257