Linux 集群时间同步实现

现有集群:

hadoop2hadoop3hadoop4
HDFSNameNode DataNodeDataNodeSecondaryNameNode DataNode
YARNNodeManagerResourceManager NodeManagerNodeManager
IP192.168.197.120192.168.197.130192.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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值