zoukankan      html  css  js  c++  java
  • CDH NTP服务安装

    1.安装ntp服务端

    [root@kafka1 ~]# yum install ntp  -y
    

    2.修改配置

    cat /etc/ntp.conf 
    driftfile /var/lib/ntp/drift
    restrict default nomodify notrap nopeer noquery
    
    restrict 127.0.0.1 
    restrict ::1 
    
    restrict 10.23.215.0 mask 255.255.255.0 nomodify
    
    server  127.127.1.0
    
    fudge 127.127.1.0 stratum 10
    
    
    includefile /etc/ntp/crypto/pw
    keys /etc/ntp/keys

    3.启动服务

    systemctl start ntpd
    

    4.查看服务

    [root@kafka1 ~]# systemctl status ntpd
    ● ntpd.service - Network Time Service
       Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
       Active: active (running) since Fri 2020-06-12 20:55:06 CST; 54s ago
      Process: 26124 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
     Main PID: 26125 (ntpd)
       CGroup: /system.slice/ntpd.service
               └─26125 /usr/sbin/ntpd -u ntp:ntp -g
    
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listen and drop on 1 v6wildcard :: UDP 123
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listen normally on 2 lo 127.0.0.1 UDP 123
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listen normally on 3 ens160 10.23.215.101 UDP 123
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listen normally on 4 lo ::1 UDP 123
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listen normally on 5 ens160 fe80::250:56ff:febe:26fb UDP 123
    Jun 12 20:55:06 kafka1 ntpd[26125]: Listening on routing socket on fd #22 for interface updates
    Jun 12 20:55:06 kafka1 ntpd[26125]: 0.0.0.0 c016 06 restart
    Jun 12 20:55:06 kafka1 ntpd[26125]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
    Jun 12 20:55:06 kafka1 ntpd[26125]: 0.0.0.0 c011 01 freq_not_set
    Jun 12 20:55:07 kafka1 ntpd[26125]: 0.0.0.0 c514 04 freq_mode
    [root@kafka1 ~]# ntpq -np
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *127.127.1.0     .LOCL.          10 l   26   64    3    0.000    0.000   0.000
    [root@kafka1 ~]# timedatectl 
          Local time: Fri 2020-06-12 20:57:00 CST
      Universal time: Fri 2020-06-12 12:57:00 UTC
            RTC time: Fri 2020-06-12 12:57:00
           Time zone: Asia/Shanghai (CST, +0800)
         NTP enabled: no
    NTP synchronized: yes
     RTC in local TZ: no
          DST active: n/a
    [root@kafka1 ~]# timedatectl  set-ntp  yes
    [root@kafka1 ~]# timedatectl 
          Local time: Fri 2020-06-12 20:57:47 CST
      Universal time: Fri 2020-06-12 12:57:47 UTC
            RTC time: Fri 2020-06-12 12:57:48
           Time zone: Asia/Shanghai (CST, +0800)
         NTP enabled: yes
    NTP synchronized: yes
     RTC in local TZ: no
          DST active: n/a
    [root@kafka1 ~]# ntpstat
    synchronised to local net (127.127.1.0) at stratum 11
       time correct to within 3948 ms
       polling server every 64 s
    [root@kafka1 ~]# ntpq -np
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *127.127.1.0     .LOCL.          10 l   26   64    3    0.000    0.000   0.000

    客户端安装

    [root@kafka2 ~]# yum install ntp -y
    

     修改配置

    [root@kafka2 ~]# cat /etc/ntp.conf 
    
    driftfile /var/lib/ntp/drift
    restrict default nomodify notrap nopeer noquery
    
    restrict 127.0.0.1
    restrict ::1
    restrict 10.23.215.0 mask 255.255.255.0 nomodify
    
    server 10.23.215.101 prefer
    fudge 127.127.1.0 stratum 15
    
    
    includefile /etc/ntp/crypto/pw
    keys /etc/ntp/keys

    启动客户端

    [root@kafka2 ~]# systemctl start ntpd
    
    [root@kafka2 ~]# timedatectl 
          Local time: Fri 2020-06-12 21:06:45 CST
      Universal time: Fri 2020-06-12 13:06:45 UTC
            RTC time: Fri 2020-06-12 13:06:46
           Time zone: Asia/Shanghai (CST, +0800)
         NTP enabled: yes
    NTP synchronized: no
     RTC in local TZ: no
          DST active: n/a
    [root@kafka2 ~]# timedatectl set-ntp yes
    [root@kafka2 ~]# ntpstat 
    synchronised to NTP server (10.23.215.101) at stratum 12
       time correct to within 972 ms
       polling server every 64 s
    [root@kafka2 ~]# ntpq -np
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *10.23.215.101   LOCAL(0)        11 u   29   64   17    0.315  -21.375   0.018

    时间同步正常

      

      

      

      

  • 相关阅读:
    【python】PyQt5 QAction 添加点击事件
    【环境搭建】安装pyQt5 在pycharm报This application failed to start because no Qt platform plugin could be initialized的问题
    【嵌入式】arduino IDE串口监视器可以正常使用但其他软件发送串口指令没有反应的问题
    【操作系统】bat文件 系统找不到文件路径
    十天冲刺:第二天
    十天冲刺:第一天
    项目需求分析NABCD电梯演讲
    项目需求分析与建议-NABCD模型
    团队开发之团队介绍
    会议1.7
  • 原文地址:https://www.cnblogs.com/caonw/p/13110397.html
Copyright © 2011-2022 走看看