美文网首页
集群时间同步

集群时间同步

作者: Map_Reduce | 来源:发表于2019-07-21 14:39 被阅读0次

时间同步的方式:

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

配置时间同步具体实操:

  1. 时间服务器配置(必须root用户)

(1)检查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

(2)修改ntp配置文件

[root@hadoop102桌面]# vim /etc/ntp.conf

修改内容如下

a)修改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 mask255.255.255.0 nomodify notrap

b)修改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.orgiburst

        #server 1.centos.pool.ntp.orgiburst

        #server 2.centos.pool.ntp.orgiburst

        #server 3.centos.pool.ntp.orgiburst

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

server 127.127.1.0

fudge 127.127.1.0 stratum 10

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

[root@hadoop102桌面]# vim

/etc/sysconfig/ntpd

增加内容如下(让硬件时间与系统时间一起同步)

SYNC_HWCLOCK=yes

(4)重新启动ntpd服务

[root@hadoop102桌面]# service ntpd status

ntpd 已停

root@hadoop102桌面]# service ntpd start

正在启动 ntpd:        [确定]

(5)设置ntpd服务开机启动

[root@hadoop102桌面]#

chkconfig ntpd on
  1. 其他机器配置(必须root用户)

(1)在其他机器配置10分钟与时间服务器同步一次

[root@hadoop103桌面]# crontab -e

编写定时任务如下:

*/10 * * * * /usr/sbin/ntpdate hadoop102

(2)修改任意机器时间

[root@hadoop103桌面]#

date -s "2017-9-11 11:11:11"

(3)十分钟后查看机器是否与时间服务器同步

[root@hadoop103桌面]#

date

说明:测试的时候可以将10分钟调整为1分钟,节省时间。

扩展

ntp 时间同步
ntpd服务 中的d 是daemn的意思(后台运行,守护进程)。
有两种功能:
①作为时间源供其他机器同步时间
②能够去上游的网络时间同步ntpd服务所在的节点的时间。

ntpd和ntpdate的区别:

  • ntpd去同步时间的时候是缓慢的逐渐逼近上游服务器的时间。
  • ntpdate同步时间的时候是一下子就跳跃到目标服务器的时间。
    注意事项:
    ntpdate使用的时候,必须保证ntpd服务是关着的。

相关文章

  • CentOS 7.x系统优化指南

    集群时间同步: 参考链接:Linux Chrony 设置服务器集群同步时间[https://www.linuxpr...

  • 集群时间同步

    相当重要的 ,必须要做的服务器运行久了时间会差异,所以需要时间同步第一步: 修改相关配置文件 一、先开启ntpd...

  • 集群时间同步

    时间服务器 1)检查ntp是否安装(此处默认已经安装) $ rpm -qa | grep ntp 2)修改ntp配...

  • 集群时间同步

    时间同步的方式: 配置时间同步具体实操: 时间服务器配置(必须root用户) (1)检查ntp是否安装 (2)修改...

  • 集群时间同步

    步骤 1. 检查ntp(网络时间协议)是否安装。 ps -e | grep ntp如果出现一下内容表明一斤安装: ...

  • kafka命令行的管理使用

    启动kafka集群 首先要启动好kafka集群1、集群时间同步2、启动zookeeper集群3、启动kafka集群...

  • linux 集群时间同步

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

  • hadoop集群时间同步

    同步方式 选择一个机器,作为时间服务器(这里选择hadoop01),所有的机器与这台集群时间进行定时的同步,比如,...

  • 配置集群时间同步

    配置集群时间同步: 1.时间服务器配置(必须root用户) 检查ntp是否安装 2.修改ntp配置文件 [root...

  • linux集群时间同步

    设计目标一:master 局域网内的时间服务器,其他节点和master节点通信进行时间同步node1 只...

网友评论

      本文标题:集群时间同步

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