现有集群:
hadoop2 | hadoop3 | hadoop4 | |
---|---|---|---|
HDFS | NameNode DataNode | DataNode | SecondaryNameNode DataNode |
YARN | NodeManager | ResourceManager NodeManager | NodeManager |
IP | 192.168.197.120 | 192.168.197.130 | 192.168.197.140 |
选择某个主机作为标准时间(这里选择NameNode 节点主机)
【hadoop2】上操作:
1.安装ntp
1.查询ntp是否存在
rpm -qa|grep ntp
2.安装ntp
yum -y install ntp
看到 Complete! 安装完成
3.再次查询,可以看到下载了ntp
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
ntp-4.2.6p5-29.el7.centos.2.x86_64
2.修改 /etc/ntp.conf文件
vi /etc/ntp.conf
# 修改1(设置本地网络上的主机不受限制。)
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap为
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# 修改2(设置为不采用公共的服务器)
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 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
# 添加3(添加默认的一个内部时钟数据,使用它为局域网用户提供服务。)
server 127.127.1.0
fudge 127.127.1.0 stratum 10
3.修改/etc/sysconfig/ntpd
vim /etc/sysconfig/ntpd
-----------------------
# 增加内容如下(让硬件时间与系统时间一起同步)
SYNC_HWCLOCK=yes
4.重新启动ntpd
service ntpd status
service ntpd start
chkconfig ntpd on
另外的两台机器上的时间同步到hadoop2的时间
1.下载ntp
2.编辑定时任务 crontab -e
编辑当前用户定时任务文件,定时10min
crontab -e
----------------
*/10 * * * * /usr/sbin/ntpdate hadoop2
查看定时任务
crontab -l
----------------
*/10 * * * * /usr/sbin/ntpdate hadoop2
You have new mail in /var/spool/mail/root
cat /etc/crontab
在/etc/crontab文件中可以查看定时任务代码机制,从左往右 每个*依次代表 分 时 日 月 星期
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed