centos7安裝ntp服務

2021-09-27 08:47:17 字數 2091 閱讀 4813

安裝ntp服務

//查詢是否安裝了ntp

rpm -qa | grep ntp

yum install -y ntp

修改所有節點的ntp.conf (vi /etc/ntp.conf), 新增以下內容

//當前節點ip位址

restrict 10.0.32.20 nomodify notrap nopeer noquery

//集群所在網段的閘道器(gateway),子網掩碼(genmask)

restrict 10.0.32.1 mask 255.255.255.0 nomodify notrap

ps: 查詢閘道器,掩碼:

cat /etc/sysconfig/network-scripts/ifcfg-eth0

選擇乙個主節點,修改ntp.conf

在server部分新增以下部分,並注釋掉server 0 ~ n

//因為是內網環境所以使用本機時間, 也可使用網路時間

server 127.127.1.0

fudge 127.127.1.0 stratum 10

修改主節點以外的ntp.conf

在server部分新增如下語句,將server指向主節點。

server 《主節點ip> prefer

啟動ntp

systemctl start ntpd

設定開機自啟

chkconfig ntpd on

查詢同步狀態

ntpstat
ntp同步需要5-10分鐘,服務剛啟動時ntpstat顯示unsynchronized…是正常現象

顯示如下內容表示同步成功

synchronised to ntp server (x.x.x.x) at stratum 12

time correct to within 24 ms

polling server every 256 s

server配置示例:

driftfile /var/lib/ntp/drift

restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict ::1

restrict 10.0.32.202 nomodify

restrict 10.0.32.254 mask 255.255.255.0 nomodify notrap

server 127.127.1.0

fudge 127.127.1.0 stratum 10

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor

logfile /var/log/ntp.log

client配置示例:

driftfile /var/lib/ntp/drift

restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict ::1

restrict 10.0.32.203 nomodify notrap nopeer noquery

restrict 10.0.32.254 mask 255.255.255.0 nomodify notrap

server 10.0.32.202 prefer

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor

logfile /var/log/ntp.log

centos 7 安裝NTP服務

1.兩台伺服器 139 server端 140 client端 2.server端 2.1 yum安裝 yum install ntp ntpdate 2.2 編輯配置檔案 vim etc ntp.conf server 0.centos.pool.ntp.org iburst server 1.c...

Centos7安裝NTP伺服器

一 準備伺服器,三颱伺服器 192.168.207.133 server端 192.168.207.137 client端 192.168.207.132 client端 二 安裝server端 2.1 yum安裝 yum install ntp ntpdate 2.2 編輯配置檔案 vim etc...

Centos7 配置NTP服務

一 安裝 安裝 yum y install chrony二 配置 修改配置檔案 vi etc chrony.conf修改 etc chrony.conf 以下內容 server ntp1.aliyun.com server ntp2.aliyun.com server time1.cloud.ten...