NTP時間伺服器搭建部署

2022-07-03 07:45:12 字數 1653 閱讀 3328

一.ntp介紹

ntp(network time protocol,網路時間協議)是用來使網路中的各個計算機時間同步的一種協議。它的用途是把計算機的時鐘同步到世界協調時utc,其精度在區域網內可達0.1ms,在網際網路上絕大多數的地方其精度可以達到1-50ms。

ntp伺服器就是利用ntp協議提供時間同步服務的

二.ntp伺服器安裝

1.檢視本機系統版本

cat /etc/redhat-release

2.檢視本機ntp軟體包

rpm -qa ntp

三.ntp伺服器配置

1.備份ntp伺服器配置檔案

cp /etc/ntp.conf /etc/ntp.conf.bak

ll /etc/ntp.conf*

2.精簡優化配置檔案

egrep -v "^$|#" /etc/ntp.conf.bak >/etc/ntp.conf

3.編輯配置檔案

配置檔案文字:

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

允許內網其他機器同步時間

定義使用的上游 ntp伺服器,將原來的注釋

server ntp1.aliyun.com

server time1.aliyun.com

允許上層時間伺服器主動修改本機時間

restrict time1.aliyun.com nomodify notrap noquery

restrict ntp1.aliyun.com nomodify notrap noquery

外部時間伺服器不可用時,以本地時間作為時間服務

server 127.127.1.0

fudge 127.127.1.0 stratum 10

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

四.啟動ntp伺服器

centos6: /etc/init.d/ntpd start centos7: systemctl start ntpd

ntpq -p 顯示節點列表

五.客戶端時間同步測試

ntpdate 10.0.0.111(ntp伺服器)

ntp時間伺服器搭建

我在學習過程中經常遇到伺服器時間不一致導致很多故障,經過了很多次麻煩的經歷之後決定寫出來,以便於自己以後需要再來拿出來用,也希望可以幫到需要的人 yum install y ntp ntpdate備份配置檔案 cp etc ntp.conf etc ntp.conf.bak將注釋掉的去掉,新建配置文...

Ntp時間伺服器搭建

1 服務端配置 yum y install ntp cp etc ntp.conf etc ntp.conf.bak egrep v etc ntp.conf.bak etc ntp.conf vim etc ntp.conf driftfile var lib ntp drift restrict...

Linux部署ntp時間伺服器

yum y install ntpvim etc ntp.conf restrict 172.16.1.61 nomodify notrap nopeer noquery 當前節點ip位址 restrict 172.16.1.1 mask 255.255.255.0 nomodify notrap ...