Time synchronization in a cluster can cause big data applications to run into confusion, causing unpredictable problems, such as HBase, which hangs when time differences are too large, so in a big data cluster, the NTP service should serve as a basic service, as shown below in the CentOS 7.2 Procedures for configuring NTP services on Clusters
First check if the NTP package is installed in the system: rpm-q NTP I'm just the underlying server operating system, so there's no NTP service installed
Then, execute the command to install NTP online: yum -y install NTP
After the installation succeeds, execute rpm-q NTP again to see the corresponding package:
At this point, you can use the command to see if NTP is set to on boot state:
Systemctl is-enabled ntpd
You can see that the default is disable disable boot boot
Now performed: chkconfig ntpd on or systemctl enable NTPD set to boot from boot
After the setting is successful, the NTP service does not start immediately, but starts after the next reboot, so now manually start NTP:
After launch, execute: netstat-an | grep 123 can see that the 123 port of the NTP service is already in use:
Execution: ps -ef | grep ntpd can see that the NTP process has also started
By default, NTP is updated from an extranet time server, and is used in the cluster as long as all server time in the cluster is consistent, so one server is configured as a time server, the other server is the client of this time server, and time data is obtained from the time server. Thus avoiding networking and higher availability
1, the first is the time server configuration:
Ip:192.168.0.157 of the time server
Execute vim/etc/ntp.conf Open the NTP configuration file, find the location of the server specified time servers, comment out these strips, and add the following 2 lines of fixed configuration:
127.127. 1.0 127.127. 1.0 Ten
Then append a line below the two lines specified by restrict: restrict 192.168. 1.1 Mask 255.255. 252.0 nomodify notrap
This configuration according to their own gateway and network segment configuration, as long as can ensure that the LAN host communication can be, For example, here the subnet mask is 255.255.252.0 network segment configuration 192.168.0.0 can also, but the scope of communication is not quite the same, in short, this configuration is authorized local area network can synchronize time from the host range
Once configured, save and exit, execute systemctl restart Ntpd.service restart NTP service
2, then the configuration of the other server, here is equivalent to the configuration of the client:
Also perform some of the above commands for NTP installation, startup, self-boot configuration, State view and other operations, the configuration file remains:/etc/ntp.conf, open for the following configuration:
Also note The default server server, adding a row to specify the time server location: Server 192.168. 0.157 Because the above time server address is 192.168.0.157
Once configured, save and restart the NTP service
All clients are configured above, and after startup, the cluster will automatically synchronize the service periodically so that the cluster time is consistent.
In addition, if you want to manually synchronize the time of a machine, you can execute the following command in turn:
systemctl Stop ntpd 192.168. 0.157 # Manually perform synchronization systemctl start ntpd # Continue to start the service
When synchronizing, you will see that the following results indicate a successful synchronization:
Linux cluster configuration NTP time synchronization service