Home  >  Article  >  Operation and Maintenance  >  Detailed explanation of how to synchronize and set the NTP server time in Linux

Detailed explanation of how to synchronize and set the NTP server time in Linux

黄舟
黄舟Original
2017-07-24 15:00:223942browse

This article mainly introduces the relevant information of linux ntp server time synchronization settings. Friends who need it can refer to

linux ntp server time synchronization settings

Time The need for synchronization exists in many places. For example, if you install cm and cdh, you need ntp time synchronization, otherwise a red warning will appear

The main thing here is to set up a server as the main server and let other machines synchronize the time of this machine, and it is configured The local time is not synchronized with the internet time, because many times the server cannot connect to the Internet

First we set up 2 machines here, the main machine is 192.168.5.102, and the other one is 192.168.5.103

First set up the main machine

Edit the /etc/ntp.conf file

Add


## in it #

restrict 127.0.0.1   # 开启内部递归网络接口 lo 
restrict 192.168.5.0 mask 255.255.255.0 nomodify #在内部子网里面的客户端可以 进行网络校时,但不能修改NTP服务器的时间参数

Since the configuration is local time, you also need to configure an NTP server that uses the system clock as the time source. You need to add the following records to the /etc/ntp.conf file:



server 127.127.1.0 
fudge 127.127.1.0 stratun 10

In the above record:


The specified IP address is a "pseudo" IP address, which determines the local system as the time source.


The specified IP address 127.127.1.1 tells NTP to use the internal clock as the time source.


"fudge" defines the level of this clock. If there is no such record, the node is a first-level server. It is a good idea to redefine the level to 10, so that when the client queries the server, it will know that the server is not a reliable time source.


This time synchronization method should only be used locally When the network cannot use an external time source, use


and then start the NTP service



service ntpd start

Set to start automatically at boot



chkconfig ntpd on

Then configure the client. On the 192.168.5.103 host, edit the /etc/crontab file to set this node to synchronize with the main server every minute. Time

is set as follows:


* * * * * root /usr/sbin/ntpdate 192.168.5.102;/sbin/hwclock -w

The above is the detailed content of Detailed explanation of how to synchronize and set the NTP server time in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn