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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

ntp服务器修改,ntp服务器搭建与修改时区

發布時間:2023/12/20 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ntp服务器修改,ntp服务器搭建与修改时区 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

NTP是最長用的也是最基本的服務了,很多加密應用都依賴此服務,比如:open***、puppet、saltstack等都需要首先同步好時間,所以把搭建NTPserver總結下,方便以后自己查詢。

首先下載ntp server源碼包:ntp-4.2.6p5.tar,如附件。

解壓,進入ntp-4.2.6p5目錄開始安裝,命令如下:

./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks

make && make install

安裝完成后直接配置/etc/ntp.conf? 是ntp這個包提供的配置文件,配置如下:

driftfile /var/lib/ntp/drift

#restrict default kod nomodify notrap nopeer noquery

restrict 58.55.127.0 mask 255.255.255.0 nomodify

restrict 221.235.188.0 mask 255.255.255.0 nomodify

restrict default nomodify notrap noquery

restrict -6 default kod 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 -6 ::1

server 0.centos.pool.ntp.org

server 1.centos.pool.ntp.org

server 2.centos.pool.ntp.org

修改配置文件:

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

server 0.pool.ntp.org

#server 0.centos.pool.ntp.org

#server 1.centos.pool.ntp.org

#server 2.centos.pool.ntp.org

配置完成后開啟ntp服務:

[root@box logs]# /etc/init.d/ntpd restart

Shutting down ntpd:??????????????????????????????????????? [FAILED]

Starting ntpd:???????????????????????????????????????????? [? OK? ]

查看服務是否正常運行:

root@box logs]# netstat -lntup |grep ntp

udp??????? 0????? 0 192.168.2.137:123? ?????????0.0.0.0:*?????????????????????????????? 14010/ntpd

udp??????? 0????? 0 58.55.127.137:123?????????? 0.0.0.0:*?????????????????????????????? 14010/ntpd

udp??????? 0????? 0 127.0.0.1:123?????????????? 0.0.0.0:*??????????????????? ???????????14010/ntpd

udp??????? 0????? 0 0.0.0.0:123???????????????? 0.0.0.0:*?????????????????????????????? 14010/ntpd

udp??????? 0????? 0 fe80::2a0:d1ff:feea:bd15:123 :::*??????????????????????????????????? 14010/ntpd

udp? ??????0????? 0 fe80::2a0:d1ff:feea:bd14:123 :::*??????????????????????????????????? 14010/ntpd

udp??????? 0????? 0 ::1:123???????????????????? :::*??????????????????????????????????? 14010/ntpd

udp??????? 0????? 0 :::123????????????????????? :::*??????????????????????????????????? 14010/ntpd

查看NTP狀態是否同步上層NTP服務器成功:

[root@box logs]# ntpstat

synchronised to NTP server (83.137.98.96) at stratum 3

time correct to within 499 ms

polling server every 64 s

看到synchronised to NTP server,說明已經同步成功了,

查看NTP Server時間是否正確:

[root@box logs]# date

Thu Sep? 5 11:03:33 CST 2013

如果顯示如下:

[root@box logs]# ntpstat

unsynchronised

polling server every 16 s

說明未同步成功,請檢查配置是否修改正確。

還可以用這個命令查看;

[root@box logs]# ntpq -p

remote?????????? refid????? st t when poll reach?? delay?? offset? jitter

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

spacys.de?????? 130.133.1.10???? 2 u?? 35?? 64??? 3? 346.738?? -7.946?? 0.536

blueshift.trevo 209.51.161.238?? 2 u?? 56?? 64??? 1? 252.679??? 0.387?? 0.000

jaded.fsck.ca?? 132.163.4.103??? 2 u?? 45?? 64??? 1? 286.477? -37.529?? 0.000

每項含義可以參照:

PS:

每次重啟NTP?服務器之后大約要3-5 分鐘客戶端才能與server 建立正常的通訊

切記每次修改了配置文件后都需要重新啟動服務來使配置生效。

命令行修改時區三步:

[root@localhost ~]# vi /etc/sysconfig/clock

ZONE="Asia/Shanghai"

[root@localhost ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

cp: overwrite `/etc/localtime'? y

[root@localhost ~]# date

Thu Sep? 5 19:33:12 CST 2013

最后crontab中添加:

*/5 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1

Ntpdate –u +ip? 同步時間。

總結

以上是生活随笔為你收集整理的ntp服务器修改,ntp服务器搭建与修改时区的全部內容,希望文章能夠幫你解決所遇到的問題。

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