內網配置NTP時鐘同步

來源:互聯網
上載者:User

標籤:local   oca   成功   c51   systemd   網域名稱   upd   normal   watch   

環境介紹
Node1作為NTP主節點,其他所有節點從node1進行時間同步,
節點 Ip
Node1 192.168.20.101
Node2 192.168.20.102

  1. 所有節點安裝ntp包:

    yum install ntp
  2. 修改node1主節點的/etc/ntp.conf添加如下內容:
restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap

即允許192.168.20.0網段的伺服器從該節點同步時間,其中192.168.20.0可以更改為環境的實際ip網段。
3.注釋掉原有的時間同步源,添加本地時間源,即外部時間伺服器不可用時,以本地時間作為時間服務

#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 iburstserver  127.127.1.0     # local clockfudge   127.127.1.0 stratum 10

4.啟動ntp服務並設定開機自啟動

[[email protected] ~]# systemctl start ntpd[[email protected] ~]# systemctl enable ntpdCreated symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.[[email protected] ~]# systemctl status ntpd● ntpd.service - Network Time Service   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)   Active: active (running) since Wed 2018-10-17 22:39:05 CST; 17s ago Main PID: 2529 (ntpd)   CGroup: /system.slice/ntpd.service           └─2529 /usr/sbin/ntpd -u ntp:ntp -gOct 17 22:39:05 node1 ntpd[2529]: Listen normally on 6 lo ::1 UDP 123Oct 17 22:39:05 node1 systemd[1]: Started Network Time Service.Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 7 eno50332184 fe80::20c:29ff:fe93:4ece UDP 123Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 8 eno16777736 fe80::20c:29ff:fe93:4eba UDP 123Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 9 eno33554960 fe80::20c:29ff:fe93:4ec4 UDP 123Oct 17 22:39:05 node1 ntpd[2529]: Listening on routing socket on fd #26 for interface updatesOct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c016 06 restartOct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPMOct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c011 01 freq_not_setOct 17 22:39:06 node1 ntpd[2529]: 0.0.0.0 c514 04 freq_mode

5.修改其他所有ntp用戶端,即node2的/etc/ntp.conf 。刪除所有ntp源,並添加node1節點的ntp時間源,其中192.168.20.101為node1的ip,可用node1網域名稱代替。

#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 iburstserver 192.168.20.101

6.啟動ntp服務並設定開機自啟動

[[email protected] ~]# systemctl start ntpd [[email protected] ~]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.serviceto /usr/lib/systemd/system/ntpd.service.

7.查看是否同步成功,顯示如下192.168.20.101為node1節點的ip地址,說明同步成功。

[[email protected] ~]# ntpq -p     remote           refid      st t when poll reach   delay   offset  jitter==============================================================================*192.168.20.101  LOCAL(0)        11 u   49   64  377    0.293    0.011   0.253

8.在node2上查看與node1時間伺服器的實際偏差

[[email protected] ~]# ntpdc -c loopinfooffset:               0.000011 sfrequency:            0.002 ppmpoll adjust:          6watchdog timer:       270 s

內網配置NTP時鐘同步

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.