CDH服务器意外关闭以后,在重启CDH的几台服务器时,出现了时钟偏差问题。
问题图片
发现问题后,去搜索了相关的文章,原因是服务器重启后,NTP服务没有自动开启,所以导致了时钟偏差
查看当前NTP服务状态
ntpstat
一般正常返回
unsynchronised
time server re-starting
polling server every 8 s
我执行后
[root@xxxx ~]# ntpstat
Unable to talk to NTP daemon. Is it running?
[root@xxxx ~]# ntpq -p
ntpq: read: Connection refused
这明显是NTP服务有问题,我想会不会是异常关闭导致NTP服务G了,把NTP进程杀掉,在重新起一次应该就好,就查看了一下进程
查看NTP进程
[root@xxxx ~]# ps -ef |grep ntp
root 58919 58834 0 15:29 pts/0 00:00:00 grep --color=auto ntp
[root@xxxx ~]# ps -ef |grep ntp
root 59630 58834 0 15:32 pts/0 00:00:00 grep --color=auto ntp
当我想杀掉这个进程的时候,发现他的进程号一直在变化。
这个情况之前遇到过,是因为这个进程是当前输入的命令
ps -ef |grep ntp
中也含有 ntp,也就是这个进程每次输入这个命令,都会是一个新的进程,id自然不一样,这个命令执行完成后,会自然结束。
如果需要排除当前输入的这个命令的进程,可以在后面加上 |grep -v grep
ps -ef |grep ntp |grep -v grep
这样就不会查到这行命令的进程了
[root@xxxx ~]# ps -ef |grep ntp |grep -v grep
[root@xxxx ~]# ps -ef |grep ntp |grep -v grep
现在进程没了,来启动NTP服务
启动NTP服务
启动NTP服务
systemctl start ntpd
查看NTP状态
systemctl status ntpd
设置开机启动
systemctl enable ntpd
验证NTP
ntpq -p
执行这句的时候 reach:八进制数值
正常值有“0,1,3,7,17,37,77,177,377”,对应二进制值有“0,1,11,111,1111,11111,111111,1111111,11111111”。
ok,NTP服务起来了,看看CDH7180
CDH上还是有时钟偏差报错
现在查看ntp已经是正常了,但是cdh仍然报错:服务器报错主机的 NTP 服务未同步至任何远程服务器。这是因为ntp服务返回结果给Cloudera manager的后台,所以可能是CDH集群本身没有接收到时间同步服务器的结果,因为cdh服务重启以后,ntp服务宕机了。
应该是先重启ntp服务,再启动cdh。
所以重启一下agent就可以了。
重启agent
systemctl restart cloudera-scm-agent -- 重启agent
service cloudera-scm-agent status -- 查看agent状态
重启agent以后,启一下cdh组件
ok,CDH运行正常,时钟偏差问题解决。