Hadoop 同步集群时间ntp

root 用户操作

1,rpm -qa|grep ntp 查看机器是否安装ntp

2,vi /etc/ntp.conf

  修改:

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.178.0 mask 255.255.255.0 nomodify notrap      

192.168.178.0  代表网段

 注释:

#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 127.0.0.1 # local clock

fudge 127.0.0.1 stratum 10

保存,退出

3,vi /etc/sysconfig/ntpd

新增:

SYNC_HWCLOCK=yes

4,查看ntpd 服务

service status ntpd , 有可能会提醒用systemctl 命令

systemctl status ntpd

开启

systemctl start ntpd, systemctl enable ntpd(重启生效,保存到状态文件)

systemctl stop ntpd,systemctl disable ntpd(重启生效,保存到状态文件)

至此,时间校准的服务器配好

5,其他客户端,需要校准服务器

设置定时任务:crontab -e

0-59/10 * * * * /usr/sbin/ntpdate hella-hadoop.chris.com

hella-hadoop.chris.com 是服务器

每隔10 分钟会校准一次

也可以/usr/sbin/ntpdate hella-hadoop.chris.com直接校准

猜你喜欢

转载自www.cnblogs.com/pickKnow/p/10822483.html