1. 程式人生 > >Hadoop 同步集群時間ntp

Hadoop 同步集群時間ntp

rontab 1.0 com sys sbin 提醒 註釋 .com 用戶

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直接校準

Hadoop 同步集群時間ntp