This article Original Address: https://sitoi.cn/posts/27560.html
step
- Created in the time synchronization master node
ntp.conf
file - Create a synchronization time from the node
ntp.conf
file - Modify all nodes in the time zone
- Restart the primary node
ntpd
service - All the time synchronization slave nodes and the master node time
- Detecting whether time synchronization
- Restart from the node
ntpd
service
Ntp.conf file is created in the time synchronization master node
Select a piece of equipment when time synchronization master node, run the following command, preparation of documents ntp.conf
sudo vim /etc/ntp.conf
Write the following:
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# restrict 网段 mask 子网掩码
restrict 192.168.1.0 mask 255.255.255.0 # 修改这行
server 127.127.1.0
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
Creating ntp.conf file synchronization from the node at a time
All devices except the master node, run the following command ,, preparation of documents ntp.conf
sudo vim /etc/ntp.conf
Write the following:
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# server 从节点 IP 地址
server 192.168.1.152 # 根据从节点实际 IP 地址修改
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
Modify all nodes in the time zone
In 每一个
the node running the following command to time zone changes to all nodesAsia/Shanghai
timedatectl set-timezone Asia/Shanghai
Restart the primary node ntpd service
In the primary node, run the following command:
systemctl restart ntpd
All the time synchronization slave nodes and the master node time
Run the following commands from the node on each machine:
Wherein: 192.168.1.151 represents the IP address of the master node
ntpdate 192.168.1.151
Detecting whether time synchronization
Each device has detected the same time, run the following command:
$ date
Thu Apr 18 16:50:07 CST 2019
From the restart the ntpd service node
Each node in a run from the command:
systemctl restart ntpd
Ambari cluster time synchronization is successful