Several Hbase nodes in a recent cluster cannot be connected. In the end, it is found that the system time is not synchronized between clusters. (The Hbase timestamp determines that the time between nodes must be synchronized.) Decide to use NTP to solve the problem of system time synchronization between clusters.

Install the NTP

 yum install -y ntp
Copy the code

NTP Server Configuration

Time synchronization between clusters also uses the server /client mode. One node serves as the NTP server, and the other nodes serve as clients to synchronize time with the NTP server. You need to select one NTP server as the NTP server and modify the NTP configuration file.

vim /etc/ntp.conf
Copy the code

Under RESTRICT, add a sentence to restrict the type of server access.

# Permit all access over the loopback interface. This could # be tightened as well, But to do so would effect some of # the administrative functions. Restrict 127.0.0.1 RESTRICt-6 ::1 Restrict 10.1.13.0 Mask 255.255.255.0 nomodifyCopy the code

Enter Restrict 10.1.13.0 Mask 255.255.255.0 nomodify. According to the subnet mask, the CLIENT IP addresses that access the NTP server must range from 10.1.13.1 to 10.1.13.254. Nomodify indicates that the client cannot change the server time parameter, but the client can perform network time correction through the server.

The value of RESTRICT is RESTRICT IP address mask Specifies the parameters of the subnet mask

The IP address can also be default, which means all IP addresses

The parameters are as follows:

  • Ignore: Closes all NTP online services

  • Nomodify: The client cannot change the server time parameter, but the client can perform network time correction through the server.

  • Notrust: Unless the client is authenticated, the source of the client is regarded as an untrusted subnet

  • Noquery: does not provide time query on the client: The client cannot run commands such as NTPQ and NTPC to query the NTP server

  • Notrap: trap is not provided remote login: mode 6 control message trap service is denied for the matched host. Trap service is a subsystem of the NTPDQ control message protocol for remote event loggers.

  • Nopeer: Used to prevent the host from attempting to peer with the server and to allow the fraudulent server to control the clock

  • Kod: Send koD packets in case of access violations.

Restrict-6 Specifies the permission of the IPV6 address.

Then comment out the original server content and add the following two sentences

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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.ntp.org iburstServer 127.127.1.0 fudge 127.127.1.0 stratum 10Copy the code

Server Specifies the NTP server from which the time is synchronized.

Configure the NTP client

Configure the client to synchronize time with the NTP server. For example, if the IP address of the NTP server is 10.1.13.111, you only need to add it to Server 10.1.13.111

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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.ntp.org iburst
server 10.1.13.111
Copy the code

Start the service

If the NTP service is configured, you only need to start the NTP service on the server and client

service ntpd start
chkconfig ntpd on
Copy the code

The NTP service occupies UDP port 123. If the service fails to be started, check whether the port is occupied

netstat -nulp | grep 123 
Copy the code

Ensure that UDP port 123 of the protection wall is open

If the automatic NTP service synchronization is not enabled, you can enable only the NTP server. You can run the crontab -e command on the client to enable the ntpdate synchronization of scheduled tasks.

Crontab -e * */1 * * * /usr/sbin/ntpDate 10.1.18.221 >/dev/null 2>&1Copy the code

However, this method is not recommended. It is better to start the NTP service automatically