Explain in detail how to build NTP Beidou timing server in Linux

Explain how to build an NTP Beidou timing server in
Linux Explain how to build an NTP Beidou timing server in Linux

(1) Why build ntp time server

      因为Hadoop 对集群中各个机器的时间同步要求比较高, 要求各个机器的系统时间不能相差太多, 不然会造成很多问题。比如,最常见的连接超时问题。所以需要配置集群中各个机器和互联网的时间服务器进行时间同步, 但是在实际生产环境中, 集群中大部分服务器是不能连接外网的, 这时候可以在内网搭建一个自己的时间服务器( NTP 服务器),然后让集群的各个机器与这个时间服务器定时的进行时间同步。 

(B) how to build a time server
to the host machine named node01 example
1, first check the machine's time
to enter commands to date.
From the results, we can see that the current time is EST (Eastern Standard Time, New York Time) and we are in China, so we can change the time to CST (Central Standard Time, Shanghai Time).
2. How to modify the time standard?
Just execute the command on all nodes: cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime. In fact, copy the files of Shanghai time to localtime.
Note: The above operations must be performed on all three nodes to ensure that the current time standard of the system is Shanghai time.
OK, then proceed to the clock synchronization configuration.
3. Configure the NTP server.
We choose the first machine (node01) as the NTP server, and other machines will synchronize their time with this machine.
(1) Check whether the NTP service has been installed and
enter the command: rpm -qa | grep ntp.
If it is not installed, enter the command yum install -y ntp to install it.
In fact, two softwares are installed, of which ntpdate-4.2.6p5-1.el6.centos.x86_64 is used to synchronize with a server and
ntp-4.2.6p5-1.el6.centos.x86_64 is used to provide time Synchronous service.
(2) Modify the configuration file ntp.conf and
enter the command: vi /etc/ntp.conf, and then make the following modifications:
1) Enable restrict to limit the network segment of the machine. The specific operations are as follows:
Remove the comment on the restrict 192.168.74.136 mask 255.255.255.0 nomodify notrap line, and change the network segment to the network segment of your own machine. Here is the 74 network segment. Of course, you can also directly enter the IP address of the machine.
2) Comment out the server domain name configuration
#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 The 4 servers
above .ntp.org iburst are the domain names of the time server. There is no need to connect to the Internet here, so comment them out.
3) Add the following two lines to the file to synchronize the time of the local machine and the local hardware.
server 127.127.1.0
fudge 127.127.1.0 stratum 10
default configuration file these two are commented out. The NTP server will use its own time as the time of the NTP server according to the configuration here, that is, synchronize with itself. Taking into account that some LANs cannot access the external network, this configuration item needs to be configured here.
(3) Start the NTP service and
enter the command chkconfig ntpd on
so that every time the machine starts, the NTP service will automatically start.
4. Configure the timing time synchronization of
other machines. In fact, it is not difficult to configure the time server clock synchronization of other machines. You only need to enter the command on the corresponding machine: crontab -e, and then enter 0-59/10 /usr/ in the session sbin/ntpdate node01
The following is a brief explanation of the meaning of this line:
(1) Among them, 0-59/10 means that the clock is synchronized every 10 minutes, and the five segments separated by spaces are the time periods in the crontab syntax format, a total of 5 segments, Among them, * means any time, and the specific meaning of each period of time is as follows:

     (2)其中/usr/sbin/ntpdate node01表示执行的命令,即本机和主机名为node01的机器进行定时的时钟同步。
         (3)在其他节点进行同样的操作,然后过10分钟之后再次查看3台机器的时间,如果3台机器的时间一致就表示实现了时间的定时同步。

Guess you like

Origin blog.51cto.com/14615027/2642542