zoukankan      html  css  js  c++  java
  • Linux 集群时间同步(Ubuntu)

    在配置hadoop集群时,时间同步是必须要做的,否则会出现各种意想不到的问题。

    hadoop102 为 ntp server,hadoop103以及hadoop104 为ntp client(即需要同步时间机器)

    1.全部机器都要安装ntp以及ntpdate

    sudo apt-get install ntp
    sudo apt-get install ntpdate

    2.关闭所有的机器的ntp,每个机器执行命令 一下命令

    sudo service ntp stop 

    查看ntp状态

    sudo service ntp status

    3.修改ntp server即hadoop102的/etc/ntp.conf文件

    sudo vim /etc/ntp.conf

    相关条文解释,参考https://www.cnblogs.com/xwdreamer/p/3448773.html

    # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
      
    driftfile /var/lib/ntp/ntp.drift
    
    # Leap seconds definition provided by tzdata
    leapfile /usr/share/zoneinfo/leap-seconds.list
    
    # Enable this if you want statistics to be logged.
    #statsdir /var/log/ntpstats/
    
    statistics loopstats peerstats clockstats
    filegen loopstats file loopstats type day enable
    filegen peerstats file peerstats type day enable
    filegen clockstats file clockstats type day enable
    
    # Specify one or more NTP servers.
    
    # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
    # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
    # more information.
    pool 0.ubuntu.pool.ntp.org iburst
    pool 1.ubuntu.pool.ntp.org iburst
    pool 2.ubuntu.pool.ntp.org iburst
    pool 3.ubuntu.pool.ntp.org iburst
    
    # Use Ubuntu's ntp server as a fallback.
    pool ntp.ubuntu.com
    
    # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
    # details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
    # might also be helpful.
    #
    # Note that "restrict" applies to both servers and clients, so a configuration
    # that might be intended to block requests from certain clients could also end
    # up blocking replies from your own upstream servers.
    
    # By default, exchange time with everybody, but don't allow configuration.
    restrict -4 default kod notrap nomodify nopeer noquery limited
    restrict -6 default kod notrap nomodify nopeer noquery limited
    
    # Local users may interrogate the ntp server more closely.
    restrict 127.0.0.1
    restrict ::1
    
    # Needed for adding pool entries
    restrict source notrap nomodify noquery
    
    # Clients from this (example!) subnet have unlimited access, but only if
    # cryptographically authenticated.
    #restrict 192.168.123.0 mask 255.255.255.0 notrust
    
    
    # If you want to provide time to your local subnet, change the next line.
    # (Again, the address is an example only.)
    #broadcast 192.168.123.255
    
    # If you want to listen to time broadcasts on your local subnet, de-comment the
    # next lines.  Please do this only if you trust everybody on the network!
    #disable auth
    #broadcastclient

    改为如下后保存:

    # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
      
    driftfile /var/lib/ntp/ntp.drift
    
    # Leap seconds definition provided by tzdata
    leapfile /usr/share/zoneinfo/leap-seconds.list
    
    # Enable this if you want statistics to be logged.
    #statsdir /var/log/ntpstats/
    
    statistics loopstats peerstats clockstats
    filegen loopstats file loopstats type day enable
    filegen peerstats file peerstats type day enable
    filegen clockstats file clockstats type day enable

    # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
    # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
    # more information.
    #pool 0.ubuntu.pool.ntp.org iburst
    #pool 1.ubuntu.pool.ntp.org iburst
    #pool 2.ubuntu.pool.ntp.org iburst
    #pool 3.ubuntu.pool.ntp.org iburst
    
    # Use Ubuntu's ntp server as a fallback.
    #pool ntp.ubuntu.com
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10
    
    
    # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
    # details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
    # might also be helpful.
    #
    # Note that "restrict" applies to both servers and clients, so a configuration
    # that might be intended to block requests from certain clients could also end
    # up blocking replies from your own upstream servers.
    
    # By default, exchange time with everybody, but don't allow configuration.
    restrict -4 default kod notrap nomodify nopeer noquery limited
    restrict -6 default kod notrap nomodify nopeer noquery limited
    
    # Local users may interrogate the ntp server more closely.
    restrict 127.0.0.1
    restrict ::1
    
    # Needed for adding pool entries
    restrict source notrap nomodify noquery
    
    # Clients from this (example!) subnet have unlimited access, but only if
    # cryptographically authenticated.
    restrict 192.168.123.0 mask 255.255.255.0 nomodify notrap
    
    
    # If you want to provide time to your local subnet, change the next line.
    # (Again, the address is an example only.)
    #broadcast 192.168.123.255

    4.对ntp server (hadoop102)执行命令,开启服务

    sudo service ntp start

    5.同步时间(除hadoop102的其他机器都要执行)

    sudo ntpdate hadoop102

    6 在除hadoop102的其他机器,将同步时间的命令放在crontab中(切换到root用户下操作)

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

    每十分钟更新一次

    相关错误:

     no server suitable for synchronization found

    http://www.blogjava.net/spray/archive/2008/07/10/213964.html

    Ubuntu 时间设置

    https://www.cnblogs.com/qiumingcheng/p/12210629.html

  • 相关阅读:
    配置WebLogic的详细步骤
    安装WebLogic的详细步骤
    syswrite 函数
    利用perl 改写awk统计
    第一章 输入和输出基础
    CIO必看:跨国集团采购部报表系统的建设经验分享
    价值5000元的web报表分享
    价值5000元的web报表分享
    分页语句 where 条件列和Order by 列 引导列的问题
    Java中final修饰参数的作用
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/13335686.html
Copyright © 2011-2022 走看看