集群时间同步

时间同步的方式:
  1. 找一个机器,作为时间服务器。
  2. 所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。

配置时间服务器
  1. 使用root用户查询是否已经安装ntp
[root@hadoop102 桌面]# rpm -qa|grep ntp
ntp-4.2.6p5-10.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-10.el6.centos.x86_64
  1. 修改ntp配置文件
    vi /etc/ntp.conf
    修改1(授权192.168.1.0-192.168.1.255网段上的
    所有机器可以从这台机器上查询和同步时间)
#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
  1. 修改/etc/sysconfig/ntpd 文件
    让硬件时间与系统时间一起同步
    [root@hadoop102 桌面]# vim /etc/sysconfig/ntpd
    增加内容如下(让硬件时间与系统时间一起同步)
    SYNC_HWCLOCK=yes
  2. 重新启动ntpd服务
    [root@hadoop102 桌面]# service ntpd restart
  3. 设置ntpd服务开机启动
    chkconfig ntpd on

配置其他服务器
  1. 在其他机器配置10分钟与时间服务器同步一次
    [root@hadoop103 桌面]# crontab -e
    编写定时任务如下:
    */10 * * * * /usr/sbin/ntpdate hadoop102
  2. 修改任意机器时间
    date -s "2017-9-11 11:11:11"
  3. 十分钟后查看机器是否与时间服务器同步
    [root@hadoop103 桌面]# date
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值