安裝
#檢查rpm包
rpm -qa | grep ntp
#從https://pkgs.org/download/ntp 下載rpm包
ntp-4.2.6p5-28.el7.centos.x86_64.rpm
ntpdate-4.2.6p5-28.el7.centos.x86_64.rpm
libopts-5.18.12-alt2.x86_64.rpm
#server安裝
rpm -ivh ntp-4.2.6p5-28.el7.centos.x86_64.rpm ntpdate-4.2.6p5-28.el7.centos.x86_64.rpm libopts-5.18.12-alt2.x86_64.rpm
#slave安裝
rpm -ivh ntpdate-4.2.6p5-28.el7.centos.x86_64.rpm
配置
- 配置/etc/ntp.conf
配置下游服務器可使用該服務的IP網段(192.168.0.0-192.168.0.255)
restrict 127.0.0.1
restrict 192.168.0.0 mask 255.255.255.0 nomodify
配置上游NTP服務器IP地址
server cn.pool.ntp.org
#外部時間服務器不可用時,以本地時間做爲時間服務
server 127.127.1.0 #local clock
fudge 127.127.1.0 stratum 3
啓動
server:
systemctl start ntpd
slave:
ntpdate 192.168.0.2(server_ip)