设置时间同步

Linux系统自带ntp软件包,或者使用rpm命令安装此包。

172.16.19.149(本机)作为ntp服务器,172.16.19.0网段的都可以与149进行时钟同步。

若通过以下方法还是配置失败,请参考文档《NTP时间服务器配置.doc》

1.  修改/etc/ntp.conf文件,将默认的限制注释掉

#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery

允许客户端同步时间

restrict 127.0.0.1
restrict -6 ::1
restrict 10.6.23.0 mask 255.255.255.0 nomodify


2. 将本机作为时钟源
server  127.127.1.0

fudge  127.127.1.0 stratum 10

127.127.1.0 代表本主机

 

3.  完了重启ntp服务,执行命令 ntpq -p

service ntpd start

watch ntpq –p

看到LOCAL的一行,就是已经把自己配成自己的时钟源,当然也可以做为别人的时钟源。

要等待几分钟,待前面加上*或+号后 就是已经同步成功了

 

4. 服务器和客户端防火墙放开(或直接关闭防火墙)

iptables -I INPUT -p udp --sport 123 -j ACCEPT
iptables -I OUTPUT -p udp --dport 123 -j ACCEPT
service iptables save

 

5. 在客户端验证

        ntpdate –d 172.16.19.149   //5分钟后会完成时间同步

6. 在每一台datanode上执行crontab –e ,添加以下内容:

   */15 * * * * /usr/sbin/ntpdate 192.168.0.149

其含义:每15分钟更新一次时间,使其与master上的时间一致。

posted @ 2019-02-12 15:00  学&无止境  阅读(523)  评论(0编辑  收藏  举报