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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

centos配置ntp时间同步_Linux CentOS配置ntpd时间同步

發布時間:2023/12/15 linux 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos配置ntp时间同步_Linux CentOS配置ntpd时间同步 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

腳本在CentOS7上測試OK。可以直接使用。

yum -y install ntp ntpdatecp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimentpdate ntp.sjtu.edu.cnhwclock -wsed -i.bak '2,$d' /etc/ntp.confcat << EOF >> /etc/ntp.confdriftfile /var/lib/ntp/driftrestrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict -6 ::1server 0.centos.pool.ntp.orgserver 1.centos.pool.ntp.orgserver 2.centos.pool.ntp.orgserver time.asia.apple.com burst iburstserver ntp.nasa.gov burst iburstserver ntp.sjtu.edu.cn burst iburstserver clock.via.net burst iburstincludefile /etc/ntp/crypto/pwkeys /etc/ntp/keysEOFsystemctl start ntpd.servicesystemctl enable ntpd.servicentpq -pntpstat

下面是我操作的大致過程,供參考:

node2 root@node2:~# bash -x ntpd.sh

+ yum -y install ntp ntpdate

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.cqu.edu.cn

* extras: mirrors.cqu.edu.cn

* updates: mirrors.bfsu.edu.cn

base | 3.6 kB 00:00:00

docker-ce-stable | 3.5 kB 00:00:00

extras | 2.9 kB 00:00:00

updates | 2.9 kB 00:00:00

Package ntp-4.2.6p5-29.el7.centos.2.x86_64 already installed and latest version

Package ntpdate-4.2.6p5-29.el7.centos.2.x86_64 already installed and latest version

Nothing to do

+ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

+ ntpdate ntp.sjtu.edu.cn

30 Oct 16:54:09 ntpdate[23958]: the NTP socket is in use, exiting

+ hwclock -w

+ sed -i.bak '2,$d' /etc/ntp.conf

+ cat

+ systemctl start ntpd.service

+ systemctl enable ntpd.service

+ ntpq -p

remote refid st t when poll reach delay offset jitter

==============================================================================

ntp1.ams1.nl.le 130.133.1.10 2 u 40 64 3 278.831 -30.265 20.725

139.199.215.251 100.122.36.4 2 u 39 64 3 46.198 8.272 1.160

undefined.hostn 127.67.113.92 2 u 38 64 3 413.253 -88.696 52.447

*hkhkg1-ntp-002. .GPSs. 1 u 35 64 3 62.384 8.753 6.082

clock.via.net .INIT. 16 u - 64 0 0.000 0.000 0.000

+ ntpstat

synchronised to NTP server (17.253.84.253) at stratum 2

time correct to within 983 ms

polling server every 64 s

node2 root@node2:~# ntpstat

synchronised to NTP server (17.253.84.253) at stratum 2

time correct to within 983 ms

polling server every 64 s

如何確認工作OK?

node2 root@node2:~# netstat -ln|grep 123

udp 0 0 10.42.1.0:123 0.0.0.0:*

udp 0 0 172.17.0.1:123 0.0.0.0:*

udp 0 0 192.168.122.1:123 0.0.0.0:*

udp 0 0 10.211.55.6:123 0.0.0.0:*

udp 0 0 127.0.0.1:123 0.0.0.0:*

udp 0 0 0.0.0.0:123 0.0.0.0:*

udp6 0 0 fe80::69dc:5159:1d4:123 :::*

udp6 0 0 fe80::2ce8:d4ff:fe8:123 :::*

udp6 0 0 fdb2:2c26:f4e4:0:7a:123 :::*

udp6 0 0 fe80::ecee:eeff:fee:123 :::*

udp6 0 0 fe80::ecee:eeff:fee:123 :::*

udp6 0 0 fe80::ecee:eeff:fee:123 :::*

udp6 0 0 fe80::ecee:eeff:fee:123 :::*

udp6 0 0 ::1:123 :::*

udp6 0 0 :::123 :::*

node2 root@node2:~# ntpstat

synchronised to NTP server (17.253.84.253) at stratum 2

time correct to within 985 ms

polling server every 64 s

#該指令可列出NTP

服務器是否與上層聯機。由上述輸出結果可知,時間校正約

為985ms且每隔64秒會主動更新時間

OK

當然要更改時間源的自己可以檢索下。

總結

以上是生活随笔為你收集整理的centos配置ntp时间同步_Linux CentOS配置ntpd时间同步的全部內容,希望文章能夠幫你解決所遇到的問題。

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