preface

Distributed computing is to solve the problem of single computing power, but it introduces new problems such as service scheduling and state synchronization.

Cluster Clock

For example, when we calculate the unique ID of the cluster through the Snowflake algorithm, if the time of different servers is inconsistent, it is likely to lead to id conflict. In addition, troubleshooting exceptions may occur. Services on downstream links are processed before those on upstream links are invoked, which makes troubleshooting more difficult.

Classification of centralized clock problems

All the machines in the cluster communicate with external networks properly

In this case, all machines synchronize time with the time server periodically to ensure that the time of all servers in the cluster is consistent

ntpdate -u ntp.api.bz
Copy the code

The cluster has machines and external network blocks

Solution Based on scenario 1, a machine in a cluster that can communicate with an external network serves as the time server in the cluster, and other servers synchronize time with this server

Procedure 1. Set a machine as the time synchronization server

Restrict Default ignore Add restrict 172.17.0.0 mask 255.255.255.0 nomodify Notrap # Restrict 172.17.0.0 mask 255.255.255.0 nomodify Notrap # Restrict 172.17.0.0 is your LAN network segment server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 3. Restart the system and configure the NTPD service to take effect. Service NTPD restart chkconfig NTPD onCopy the code

2. Handle situation 1.