美文网首页
集群时间同步

集群时间同步

作者: bullion | 来源:发表于2018-09-27 11:31 被阅读0次

    时间服务器

    1)检查ntp是否安装(此处默认已经安装)

    $ rpm -qa | grep ntp

    2)修改ntp配置文件

    $ vi /etc/ntp.conf

        a)授权(192.168.1.0-192.168.1.255)网段上的所有机器可以从这台机器上查询和同步时间

        去掉代码注释 192.168.1.0 改为自己相应的网段

        # restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

        b)集群在局域网中不使用其他互联网上的时间

    注释掉代码

    # 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

        c)当该节点丢失网络链接,依然可以采用本地时间作为时间服务器为集群中其他节点提供时间同步

    在末尾增加

    server 127.127.1.0

    fudge 127.127.1.0 stratum 10

    3)修改/etc/sysconfig/ntpd文件

    末尾增加

    # 让硬件时间与系统时间一起同步

    SYNC_HWCLOCK=yes

    4)重新启动ntpd服务

    $ service ntpd status # 查看状态

    $ service ntpd start # 启动

    5)设置ntpd服务开机启动

    $ chkconfig ntpd on

    其他服务器

    1)配置10分钟与时间服务器同步一次

    $ crontab -e

    */10 * * * * /usr/sbin/ntpdate hadoop102    # hadoop102为时间服务器

    2)测试修改时间查看是否10分钟会进行同步

    # 查看时间

    $ date

    # 修改时间

    $ date -s "2008-08-08 08:08:08"

    # 等待定时任务执行后查看时间是否改变

    相关文章

      网友评论

          本文标题:集群时间同步

          本文链接:https://www.haomeiwen.com/subject/soqeoftx.html