Linux CentOS7 搭建ntp時間同步服務器

前提條件:ntp服務器須要與集羣在同一網段內,也就是同一VMent中,而且關閉防火牆!! 關閉selinux
1.which ntpd(查看是否安裝ntp)
which chronyd(查看是否安裝chrony)
2.修改ntp配置文件
vim /etc/ntp.conf
有這樣幾行
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 iburst (這一行是固定地,做用是:使用當前主機做爲時間同步的服務器)
fudge 127.127.1.0 stratum 8(這一行表示當前服務器在整個互聯網時間同步服務器層級中處於第八層,數字越小層級越高)
而後還有這樣兩行
# Hosts on local network are less restricted. (這行表示限制網段的意思)
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap(這行是限制網段的格式)
添加一行,其中的ip爲你的主機ip網段,nomodify表示不容許你修改此網段:
restrict 192.168.66.0 mask 255.255.255.0 nomodify
保存退出
重啓ntp systemctl restart ntpd
3.配置網卡ip
vim /etc/sysconfig/network-scripts/ifcfg-ens33
添加兩行
IPADDR=192.168.xxx.xxx (本身向設置的ip地址。可是不可在dhcp服務器自動分配的ip範圍內)
PREFIX=24(子網掩碼)
修改一行
PROXY_METHOD="none" 或者="static"
若是是克隆的,把UUID那一行刪除
保存退出
4.重啓網卡
systemctl restart network
5.測試
用同一網段的虛擬機測試輸入
ntpdate 192.168.124.117(服務端ip)linux

相關文章
相關標籤/搜索