搭建ntp时间服务器
因为要保证集群内所有节点的时间是一致的,否则集群会不稳定。
在集群内的所有节点上安装ntp服务,同步同一个ntp时间服务器(阿里云ntp时间服务器)。
这样就可以实现集群内所有节点的时间保持一致。
1.首先在所有节点上操作
安装ntp服务,同步阿里云ntp服务器时间
[root@cdh01 ~]# yum -y install ntp
[root@cdh01 ~]# vi /etc/ntp.conf
.....
# 将下面这四行内容注释掉
#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 ntp.aliyun.com
2.然后在所有节点
重启ntp
service ntpd start
systemctl enable ntpd.service
配置好了以后查看验证一下当前同步的时间服务器
随便找一台机查看一下。
注意:需要等5~10分钟才能看到类似下面的结果,显示出来下面这种结果的时候才说明是真正成功了,如果看不到这样的效果,需要等一会再来查看。
[root@cdh01 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*203.107.6.88 100.107.25.114 2 u 40 128 377 36.058 -7.906 1.142
[root@cdh01 ~]# ntpstat
synchronised to NTP server (203.107.6.88) at stratum 3
time correct to within 42 ms
polling server every 128 s