激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - 服務器知識 - NTP時間服務器配置以及錯誤的總結

NTP時間服務器配置以及錯誤的總結

2019-05-22 21:53bug--maker服務器之家 服務器知識

NTP 全稱是 Network Time Protocol ,也就是互聯網時間協議,說到時間,就談談時間的一些概念吧; 時區 按照常識來說,一天被劃分 24 小時,近似球體的地球是 360 度,所以使用經緯度為坐標,將全球劃分為24個時區,每個時區是 15 度; 東八區 格林

NTP全稱是Network Time Protocol,也就是互聯網時間協議,說到時間,就談談時間的一些概念吧;

  • 時區
  • 按照常識來說,一天被劃分24小時,近似球體的地球是360度,所以使用經緯度為坐標,將全球劃分為24個時區,每個時區是15度;
  • 東八區
  • 格林尼治時間為世界標準時間,又因為,東半球(格林尼治以東)的時間比較早,中國的經度在120E,是位于第八個時區,這里的中國表示北京或者上海,因為橫跨的時區不止一個;
  • UTC
  • Coordinated Universal Time表示協調通用時間,根據原子振蕩周期所計算的物理時鐘,這種計算方式對于時間的計算誤差時很小的;
  • GMT
  • Greenwich Mean Time表示的是格林尼治時間,是根據地球的自轉周期計算的標準時間,由于各種不穩定因素的影響,計時不是很理想;
  • 軟件時鐘
  • 表示的是LInux[這里指提Linux]操作系統從1970/01/01開始計算的秒數;
  • 硬件時鐘
  • 主機硬件上面的時鐘,主要是BIOS內部時間的記錄了;

  • 時間校對的幾個步驟

    • 1.server端啟動daemon;
    • 2.Clientserver發送校對時間的報文;
    • 3.NTP server返回當前的標準時間給Client;
    • 4.Client根據返回的時間校對自己當前的系統時間;
  • 關于NTP服務相關的配置文件
/etc/ntp.conf
 //表示NTP服務的主要配置文件,也是為一個的配置文件
/usr/share/zoneinfo/
 //表示對應的各個時區的文件
/etc/sysconfig/clock 
 //表示用于設置時鐘和是否使用UTC的配置文件
/etc/localtime
 //用于復制/usr/share/zoneinfo/里面對應的,/etc/sysconfig/clock里面設定的時區文件,作為當前系統使用的本地時間配置文件;
  • 關于時間的幾個命令
/bin/date 
    //Linux軟件時鐘的修改和查看
/sbin/hwclock
 //用于硬件時鐘的修改和顯示,如果修改了軟件時鐘需要使用這個方式同步到硬件時鐘上面;
/usr/sbin/ntpd
 //NTP服務的主要程序,配置文件為/etc/ntp.conf
/usr/sbin/ntpdate 
 //用于實現Client時間的校正
  • 關于/etc/ntp.conf配置文件
利用restrict來實現權限控制
restrict [IP] [mask] [netmask_IP] [patameter]
patameter支持的參數:
    igonre:拒絕所有類型的`NTP`連接
    nomodify:Client不能夠使用命令ntpc以及ntpdq來修改修改服務器的時間參數,但是可以進行網絡校時;
    noquery:表示不提供NTP網絡校時;
    notrap:表示不提供遠程事件登陸的功能;
    notrust:表示不接受沒有認證的Clent;
    如果沒有任何參數,表示不接受任何的限制;
server [IP or hostname] [prefer]
    用于設置上層提供NTP服務的服務器;
    prefer:表示優先使用
driftfile [可以被ntpd寫入的進程或者文件]
    NTP Server計算時間是通過本機的時鐘振蕩來記錄的,這個時間和上層Time Server的時鐘振蕩頻率不一定是一致的,需要將這個振蕩差異記錄下來;
  • NTP服務的規劃

    rhel7.2作為提供時間同步服務的主機172.25.23.250
    rhel6.5作為某個集群中的節點,進行時間同步,這里選擇server21.com

  • 需要注意的幾點:

    • 1.自己配置的NTP是需要設置上層服務器來進行時間同步的,172.25.23.250主機通過另一塊網卡可以上網,使用的上層主機是cn.ntp.org.cn ;
    • 2.NTP服務器和上層NTP服務的時間不能夠相差太多;
    • 3.對于防火墻的設置,一定需要允許123/UDP端口;
    • 4.防火墻還需要放行時間同步請求的網段;
  • 首先安裝ntp服務的軟件包,這里使用Yum配置安裝
[root@my Desktop]# yum install ntp -y 
[root@my Desktop]# rpm -q ntp
ntp-4.2.6p5-22.el7.x86_64
  • 然后根據上面的提示修改配置文件/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
restrict  cn.ntp.org.cn

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 172.25.23.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 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
#
server cn.ntp.org.cn prefer

#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

# Enable public key cryptography.
#crypto

includefile /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
  • 然后啟動或者重新啟動服務
[root@my Desktop]# !systemc
systemctl start ntpd
  • 確保端口已經啟動
    NTP時間服務器配置以及錯誤的總結
  • 使用命令ntpstat查看NTP服務器的狀態
[root@my Desktop]# ntpstat 
synchronised to NTP server (202.108.6.95) at stratum 3 
   time correct to within 106 ms
   polling server every 64 s
  • 或者使用ntpq -p來查看NTP服務器時間同步的過程
[root@my Desktop]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*xk-6-95-a8.bta. 10.69.2.34       2 u   35   64  377   28.381  -30.163  17.439
  • 解釋上述幾個子段的作用
    • remote :表示NTP主機的IP或者是主機名,最左邊的
      • *:表示目前正在作用當中的上層NTP服務器;
      • +:表示已經連接成功,并且可以作為下一個提供時間更新的候選者;
    • refid:表示參考的上一層NTP主機的地址;
    • st:表示的含義是startnum,一般范圍是從0-->15;
    • when:表示幾秒前做過時間同步化更新操作;
    • poll:表示下一次更新在幾秒鐘之后;
    • reach:表示已經向上一層服務器要求更新的次數;
    • delay: 表示數據在傳輸過程中延遲的時間;
    • offset:表示時間補償的結果;
    • jitter:Linux系統時間和BIOS硬件時間的差異;
  • Client僅僅需要使用簡單的命令就可以完成時間和NTP的同步操作
[root@server20 ~]# ntpdate 172.25.23.250
10 Mar 15:49:08 ntpdate[13911]: adjust time server 172.25.23.250 offset -0.049370 sec

NTP時間服務器配置以及錯誤的總結

  • 關于NTP服務器配置過程中出現額的幾個錯誤,以及解決額的辦法
  • 和上層NTP服務器不能夠正常通信;
[root@server21 ~]# ntpstat -p
unsynchronised
  time server re-starting
   polling server every 8 s
  • 上面這個錯誤出現的原因是沒有設置上層服務器,導致和上述NTP服務器的同步沒有辦法完成,或者是因為上層服務器設置錯誤;
  • 解決,這里使用的上層服務器是cn.ntp.org.cn, 可以使用聯網主機測試和上層時間同步服務器的連接是否正常
[root@my Desktop]# ntpdate cn.ntp.org.cn 
10 Mar 15:55:08 ntpdate[8952]: adjust time server 202.112.29.82 offset -0.003693 sec
  • 出現的錯誤
[root@server20 ~]# ntpdate 172.25.23.250
 9 Mar 10:46:17 ntpdate[1129]: no server suitable for synchronization found
  • 對于上述出現的錯誤,使用-d選項來查看相信的出錯信息
[root@server20 ~]# ntpdate -d 172.25.23.21
10 Mar 15:56:52 ntpdate[13913]: ntpdate 4.2.6p5@1.2349-o Mon Jul 15 09:22:50 UTC 2013 (1)
Looking for host 172.25.23.21 and service ntp
host found : server21.com
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
172.25.23.21: Server dropped: no data
server 172.25.23.21, port 123
stratum 0, precision 0, leap 00, trust 000
refid [172.25.23.21], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time:    00000000.00000000  Mon, Jan  1 1900  8:05:57.000
originate timestamp: 00000000.00000000  Mon, Jan  1 1900  8:05:57.000
transmit timestamp:  de4e0e47.784f2a34  Sat, Mar 10 2018 15:56:55.469
filter delay:  0.00000  0.00000  0.00000  0.00000 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.000000 0.000000 0.000000 0.000000
         0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000

10 Mar 15:56:56 ntpdate[13913]: no server suitable for synchronization found
  • 上面出現的原因是server droped,也就是說服務器丟棄了數據,可能存在的原因
    • 1.NTP服務器啟動不正常,也就是NTP服務器啟動過程中存在錯誤,使用tail -f /var/log/messages查看并且確定錯誤的詳細信息;
      • 上面存在的原因可能有兩個:1.selinux設置不正常,使用命令setence 0;
      • 還有可能是因為iptables沒有添加防火墻例外,也就是對于123/UDP的請求被拒絕;
  • 對于上面的錯誤還有可能遇到一種情況
[root@server20 ~]# ntpdate -d 172.25.23.21
10 Mar 15:56:52 ntpdate[13913]: ntpdate 4.2.6p5@1.2349-o Mon Jul 15 09:22:50 UTC 2013 (1)
Looking for host 172.25.23.21 and service ntp
host found : server21.com
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
transmit(172.25.23.21)
172.25.23.21: Server dropped: start toohigh
server 172.25.23.21, port 123
stratum 16, precision 0, leap 00, trust 000
refid [172.25.23.21], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time:    00000000.00000000  Mon, Jan  1 1900  8:05:57.000
originate timestamp: 00000000.00000000  Mon, Jan  1 1900  8:05:57.000
transmit timestamp:  de4e0e47.784f2a34  Sat, Mar 10 2018 15:56:55.469
filter delay:  0.00000  0.00000  0.00000  0.00000 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.000000 0.000000 0.000000 0.000000
         0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000

10 Mar 15:56:56 ntpdate[13913]: no server suitable for synchronization found
  • 對于上面正常的startnum的范圍是[0--->15],出現上面情況的原因是因為NTP服務器無法和上層NTP服務器通信,導致Client的連接不正常;
  • 可以參考第一種錯誤類型進行配置;
  • 這個是正常時間同步過程中的調式信息
[root@server21 ~]# ntpdate -d 172.25.23.250
10 Mar 16:13:18 ntpdate[1508]: ntpdate 4.2.6p5@1.2349-o Mon Jul 15 09:22:50 UTC 2013 (1)
Looking for host 172.25.23.250 and service ntp
host found : 172.25.23.250
transmit(172.25.23.250)
receive(172.25.23.250)
transmit(172.25.23.250)
receive(172.25.23.250)
transmit(172.25.23.250)
receive(172.25.23.250)
transmit(172.25.23.250)
receive(172.25.23.250)
server 172.25.23.250, port 123
stratum 4, precision -24, leap 00, trust 000
refid [172.25.23.250], delay 0.02571, dispersion 0.00000
transmitted 4, in filter 4
reference time:    de4e1219.b90d7820  Sat, Mar 10 2018 16:13:13.722
originate timestamp: de4e121e.fa8ae002  Sat, Mar 10 2018 16:13:18.978
transmit timestamp:  de4e121e.ea321e17  Sat, Mar 10 2018 16:13:18.914
filter delay:  0.02580  0.02571  0.02571  0.02571 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.063770 0.063791 0.063784 0.063784
         0.000000 0.000000 0.000000 0.000000
delay 0.02571, dispersion 0.00000
offset 0.063791

10 Mar 16:13:18 ntpdate[1508]: adjust time server 172.25.23.250 offset 0.063791 sec
  • 補充關于date命令的使用
[root@server21 ~]# date MMDDHHMMYYYY
MM:表示月
DD:表示天
HH:表示小時
MM:表示分鐘
YYYY:表示年
  • 上面這個命令主要用來查看(不使用任何選項)和修改時間;
  • hwclock 關于硬件時間
-r :表示用于讀取硬件時間
-w:表示將軟件時間寫入為硬件時間

NTP時間服務器配置以及錯誤的總結

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲尻逼视频 | 国产黄色录像片 | 奇米影视亚洲精品一区 | 成人一区二区三区在线 | 国产伦久视频免费观看视频 | 91视频官网| 欧产日产国产精品99 | 福利国产视频 | 精品一区二区三区欧美 | 成人在线视频精品 | 欧美大胆xxxx肉体摄影 | 亚洲成人午夜精品 | 久久精品国产亚洲7777 | 一级黄色免费电影 | 九九热视频在线 | 成人福利在线看 | 午夜小视频免费观看 | 成人在线观看网 | 国产一区二区精品在线观看 | 韩国精品一区二区三区四区五区 | 国产人成精品综合欧美成人 | 九九福利视频 | 国产精品久久久久永久免费观看 | 久久久久一区二区三区四区五区 | 毛片小网站 | 欧美成人三级视频 | 国产亚洲精品精 | 国产精品亚洲精品久久 | 免费a级片视频 | xvideos korean | 色中色在线播放 | 国产一级毛片高清视频 | 一级电影免费看 | 18一20岁一级毛片 | 免费国产精品视频 | 内地av在线 | 日本在线视频二区 | 一级视频片 | 天天碰天天操 | 狠狠干夜夜草 | 国产精品一二三区在线观看 |