內網配置NTP時鐘同步
阿新 • • 發佈:2018-10-23
cgroup org node 不可用 域名 con odi sbin eba 環境介紹
Node1作為NTP主節點,其他所有節點從node1進行時間同步,
節點 Ip
Node1 192.168.20.101
Node2 192.168.20.102
Node1作為NTP主節點,其他所有節點從node1進行時間同步,
節點 Ip
Node1 192.168.20.101
Node2 192.168.20.102
-
所有節點安裝ntp包:
yum install ntp
- 修改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 iburst
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
4.啟動ntp服務並設置開機自啟動
[root@node1 ~]# systemctl start ntpd [root@node1 ~]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service. [root@node1 ~]# 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 -g Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 6 lo ::1 UDP 123 Oct 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 123 Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 8 eno16777736 fe80::20c:29ff:fe93:4eba UDP 123 Oct 17 22:39:05 node1 ntpd[2529]: Listen normally on 9 eno33554960 fe80::20c:29ff:fe93:4ec4 UDP 123 Oct 17 22:39:05 node1 ntpd[2529]: Listening on routing socket on fd #26 for interface updates Oct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c016 06 restart Oct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM Oct 17 22:39:05 node1 ntpd[2529]: 0.0.0.0 c011 01 freq_not_set Oct 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 iburst
server 192.168.20.101
6.啟動ntp服務並設置開機自啟動
[root@node2 ~]# systemctl start ntpd [root@node2 ~]# 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地址,說明同步成功。
[root@node2 ~]# 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時間服務器的實際偏差
[root@node2 ~]# ntpdc -c loopinfo
offset: 0.000011 s
frequency: 0.002 ppm
poll adjust: 6
watchdog timer: 270 s
內網配置NTP時鐘同步