日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

NTP 服务的配置和使用

發布時間:2024/3/13 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NTP 服务的配置和使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

NTP 服務可以用來當做客戶端所在服務器的時間,也可以作為服務端當做時間校準的服務。

安裝 NTP

$ yum -y install ntp # 開機自啟 $ systemctl enable ntpd # 先同步一下時間,此處使用的是阿里云的 NTP 校準服務 $ ntpdate -u time1.aliyun.com

配置 NTP

??配置文件目錄:/etc/ntp.conf
??

# For more information about this file, see the man pages # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict ::1# Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). # 修改內容 --- 上級時間服務器,阿里云的時間服務 server time1.aliyun.com server time2.aliyun.com server time3.aliyun.com server time4.aliyun.com server time5.aliyun.com server time6.aliyun.com server time7.aliyun.com#broadcast 192.168.1.255 autokey # broadcast server #broadcastclient # broadcast client #broadcast 224.0.1.1 autokey # multicast server #multicastclient 224.0.1.1 # multicast client #manycastserver 239.255.254.254 # manycast server #manycastclient 239.255.254.254 autokey # manycast client# 修改內容 --- 允許上層時間服務器主動修改本機時間 #restrict time1.aliyun.com nomodify notrap noquery #restrict time2.aliyun.com nomodify notrap noquery #restrict time3.aliyun.com nomodify notrap noquery# 修改內容 --- 只有在上級時鐘源失效時,NTP 才會使用127.127.1.0的本地時鐘,將local時間作為ntp服務器時間提供給ntp客戶端。NTP把本地主機的時鐘也看作外部時鐘源來處理,分配的地址是127.127.1.0 server 127.127.1.0 # 修改內容 --- 設置本地時鐘源的層次為 5,這樣如果NTP服務從本地時鐘源獲取時間的話,NTP對外宣布的時間層次為 6 fudge 127.127.1.0 stratum 5# Enable public key cryptography. #cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating # with symmetric key cryptography. keys /etc/ntp/keys# Specify the key identifiers which are trusted. #trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility. #requestkey 8# Specify the key identifier to use with the ntpq utility. #controlkey 8# Enable writing of statistics records. #statistics clockstats cryptostats loopstats peerstats# Disable the monitoring facility to prevent amplification attacks using ntpdc # monlist command when default restrict does not include the noquery flag. See # CVE-2013-5211 for more details. # Note: Monitoring will not be disabled with the limited restriction flag. disable monitor

??配置完畢之后重啟 NTP 服務

$ systemctl restart ntpd# 查看上級連通狀態 $ ntpq -p

屬性作用
remote本機和上層 NTP 的 ip 或主機名;+ 表示可用,- 表示不可用,* 表示推薦。
refidremote 的上一層 NTP 主機地址;
stStratum(階層);表示經過 n = 2 次 NTP 同步到當前服務器。
t類型;u 表示單播(unicast)。其它值包括本地(local)、多播(multicast)、廣播(broadcast)。
when自從上次和服務器交互后經過的時間(以秒數計)。
poll和服務器的輪詢間隔,以秒數計。
reach表示和服務器交互是否有任何錯誤的八進制數;每成功連接一次它的值就會增加,值 337 表示 100% 成功(即十進制的255)。
delay從本地機發送同步要求到 NTP 服務器的往返時間。
offset當前服務器通過 NTP 時鐘同步與所同步時間源的時間偏移量,單位為毫秒,offset 越接近于 0,主機和 NTP 服務器的時間越接近。
jitter統計了在特定個連續的連接數里 offset 的分布情況。簡單地說這個數值的絕對值越小,主機的時間就越精確。
# 查看時間同步狀態 $ ntpstat synchronised to NTP server (203.107.6.88) at stratum 3time correct to within 50 mspolling server every 1024 s

??這里 NTP 服務配置已經完畢,它既是客戶端也是服務端,如果要當服務端可以開放 123 端口,其他服務器上安裝 NTP 服務并把上級時間服務器的配置項更改到本服務器的 IP/域名/主機名 即可。

總結

以上是生活随笔為你收集整理的NTP 服务的配置和使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。