配置ntp服务器

在安装CM的时候,如果没有配置ntp服务器,会提示警告,所以我们需要在集群中配置ntp服务器。主要思路就是master节点作为ntp服务器与外界对时中心同步时间,随后对所有slave节点提供时间同步服务。所有slave节点以master节点为基础同步时间。

  1. 在所有节点上安装ntp软件。查看ntp是否已经安装:rpm –qa | grep ntp。没有安装的话。使用命令安装ntp:yum install ntp。
  2. 在所有节点配置开机启动ntp服务。执行开机启动的命令:chkconfig ntpd on。查看是否配置成功,使用命令:chkconfig --list ntpd。其中2-5为on状态就代表成功。
  3. 在所有节点先同步一下时间服务器,使用命令:ntpdate -u s2m.time.edu.cn。同时看看时间服务器是否能够连接,一定要找每一次都能成功执行ntpdate -u命令的,有些ntp服务器不稳定,绝对不能要。时间服务器地址参考:国内常用NTP服务器地址及IP
  4. 在master节点修改ntp服务器的配置文件/etc/ntp.conf,将文件中的所有内容先注释,在最后追加如下内容:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default nomodify notrap
server ntp.sjtu.edu.cn prefer
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
  1. 在master节点重启ntp服务,先查看ntp服务器状态,service ntpd status。然后再决定是重启还是启动,命令为:service ntpd start/restart/stop/status。使用命令查看ntp服务状态:ntpstat,出现下面的信息代表成功,如果出现异常请等待几分钟,一般等待5-10分钟才能同步,我的等了几个小时,才成功。
    _ synchronised to NTP server () at stratum 2
    time correct to within 74 ms
    polling server every 128 s
    _
  2. 修改所有slave节点配置文件/etc/ntp.conf,内容如下:
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
server bigdata1
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

ntp客户端的server应该配置为ntp服务器的ip或者域名,再手动同步ntp服务器的时间:ntpdate -u bigdata1。这里可能出现同步失败的情况,请不要着急,一般是本地的ntp服务器还没有正常启动,一般需要等待5-10分钟才可以正常同步。启动ntp客户端的ntp服务:service ntpd start。因为是连接内网,这次启动等待的时间会比master节点快一些,但是也需要耐心等待一会儿。

参考:Linux的NTP配置总结

转载于:https://my.oschina.net/cjun/blog/778156

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值