999久久免费精品国产_日韩秘 无码一区二区三区_国产福利在线观看不卡视频_久热精品视频综合在线观看_午夜黄色亚洲av_成人青草亚洲国产_三级国产短视频在线观看_大西瓜pro亚洲福利在线观看_日本黄色一级片视频_欧美人与动牲高清

時(shí)頻百科

當(dāng)前位置:首頁>時(shí)頻百科

Debian12配置NTP時(shí)間同步

時(shí)間:2023-07-21   訪問量:3079

查看/修正 時(shí)區(qū)

查看系統(tǒng)時(shí)區(qū):timedatectl

如果時(shí)區(qū)不是Asia/Shanghai需要修改時(shí)區(qū)為東八區(qū)

timedatectl set-timezone "Asia/Shanghai"

查看本地時(shí)間

如果本地時(shí)間與NTP服務(wù)器時(shí)間誤差太大(1000s以上),需要先手動(dòng)校正本地系統(tǒng)時(shí)間,手動(dòng)校正可以使用ntpdate命令強(qiáng)制修正本地時(shí)間

ntpdate NTPServerIP后面跟NTP服務(wù)器的IP地址

root@debian:/home/test# ntpdate -d ntp.ntsc.ac.cn
ntpdig: querying 114.118.7.163 (ntp.ntsc.ac.cn)
ntpdig: querying 114.118.7.161 (ntp.ntsc.ac.cn)
org t1: e86314a0.b6c0a000 rec t2: e8646973.584fce78
xmt t3: e8646973.58e812a7 dst t4: e86314a1.c05f7000
org t1: 1689818656.713877 rec t2: 1689905907.344968
xmt t3: 1689905907.347291 dst t4: 1689818657.751456
rec-org t21: 87250.631091  xmt-dst t34: 87249.595835
2023-07-21 10:18:27.347291 (+0800) +87250.113463 +/- 0.517644 ntp.ntsc.ac.cn 114.118.7.161 s1 no-leap
CLOCK: time stepped by 87250.113463
CLOCK: time changed from 2023-07-20 to 2023-07-21
root@debian:/home/test# date
2023年 07月 21日 星期五 10:18:44 CST

如果沒有ntpdate命令,可以使用date -s "YYYY-MM-DD HH:MM:SS"手動(dòng)修改本地時(shí)間

root@debian:/home/test# date -s "2023-7-20 10:00:00"
2023年 07月 20日 星期四 10:00:00 CST

配置NTP自動(dòng)校時(shí)

編輯/etc/ntpsec/ntp.conf配置NTP服務(wù)器地址,將默認(rèn)的pool配置注釋掉(前面加#號代表注釋),添加新的配置,下面是ntp.conf文件的所有配置

root@debian:/home/test# cat /etc/ntpsec/ntp.conf 
# /etc/ntpsec/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
 
driftfile /var/lib/ntpsec/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
 
# To enable Network Time Security support as a server, obtain a certificate
# (e.g. with Let's Encrypt), configure the paths below, and uncomment:
# nts cert CERT_FILE
# nts key KEY_FILE
# nts enable
 
# You must create /var/log/ntpsec (owned by ntpsec:ntpsec) to enable logging.
#statsdir /var/log/ntpsec/
#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable
 
# This should be maxclock 7, but the pool entries count towards maxclock.
tos maxclock 11
 
# Comment this out if you have a refclock and want it to be able to discipline
# the clock by itself (e.g. if the system is not connected to the network).
tos minclock 4 minsane 3
 
# Specify one or more NTP servers.
 
# Public NTP servers supporting Network Time Security:
# server time.cloudflare.com nts
server 192.168.6.200                 #添加NTP服務(wù)器地址
 
 
# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <https://www.pool.ntp.org/join.html>
#pool 0.debian.pool.ntp.org iburst    #注釋
#pool 1.debian.pool.ntp.org iburst    #注釋
#pool 2.debian.pool.ntp.org iburst    #注釋
#pool 3.debian.pool.ntp.org iburst    #注釋
 
 
# Access control configuration; see /usr/share/doc/ntpsec-doc/html/accopt.html
# for details.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
 
# By default, exchange time with everybody, but don't allow configuration.
restrict default kod nomodify nopeer noquery limited
 
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1


修改完成后保存,如下圖所示

重啟ntpd服務(wù)

service ntpd restart

查看同步狀態(tài)

ntpq -pn

等待系統(tǒng)識別并選擇后,在IP前面會(huì)標(biāo)*/+如下圖所示

服務(wù)器主機(jī)名前符號的含義

  -  意味著本地NTP服務(wù)不太喜歡此服務(wù)器

  +  表示本地 NTP 服務(wù)喜歡此服務(wù)器

  x     標(biāo)記錯(cuò)誤的主機(jī)

  *     指示當(dāng)前收藏夾

ntpd服務(wù)加入開機(jī)啟動(dòng)

chkconfig --level 2345 ntpd on

到這里,所有配置已完成。

上一篇:Ubuntu16.04配置NTP時(shí)間同步

下一篇:Linux系統(tǒng)配置微調(diào)模式校時(shí)

售前咨詢客服

售前咨詢
QQ客服1
QQ客服2
返回頂部