Linux集群 NTP 时间同步

基于CentOS 7

规划

比如有2台机器

IP主机名说明
192.168.103.51cdh51本地NTP服务端
192.168.103.52cdh52本地NTP客户端

安装NTP服务

每台机器都安装ntp

yum -y install ntp

NTP服务端(cdh51)配置

/etc/ntp.conf配置

driftfile /var/lib/ntp/drift

restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1 
restrict ::1

# 添加该行允许某个网段服务器从该服务同步时间
restrict 192.168.103.0 mask 255.255.255.0 nomodify notrap

# 本地NTP服务同外网NTP服务同步时间
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

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor

执行 ntpdate 0.centos.pool.ntp.org ,手动做一次时间同步。再执行systemctl start ntpd

查看同步情况:

# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp1.ams1.nl.le 130.133.1.10     2 u  253  256  377  229.358   -2.606  10.955
+ntp.wdc1.us.lea 130.133.1.10     2 u  459  128  150  331.680  -44.356  17.944
*85.199.214.100  .GPS.            1 u  384   64  140  215.429   10.354  22.668

NTP服务端(cdh51)配置

/etc/ntp.conf配置

driftfile /var/lib/ntp/drift

restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1 
restrict ::1

# 同NTP服务端cdh51同步时间
server cdh51 iburst

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor

执行 ntpdate cdh51 ,手动做一次时间同步。再执行systemctl start ntpd

查看同步情况:

# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*cdh51           85.199.214.100   2 u   52  128  377    0.322   -3.060   0.674

转载于:https://my.oschina.net/shipley/blog/1834098

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值