2015-07-05 32 views
2

讓我們假設我們有一些連接到本地網絡的系統並沒有連接到互聯網。什麼纔是確保每個時鐘同步的最佳方式?它們不需要與UTC時間同步,但足以彼此同步。如何同步本地網絡中的時鐘?

我曾在一個系統中設置NTP服務器想使用NTP的。但是我需要提醒一下,與需求相比,這是否會更麻煩。也建議嘗試使用TCP套接字手動計算往返時間和服務器時間?

回答

0

即使使用其中一臺機器的無紀律的本地時鐘,也可以使小型本地網絡彼此同步的解決方案可以在簡單的NTP對等網絡中完成,一個設置以本地時鐘作爲備份,如果所有實時源失敗。

多服務器/對等ntp網絡的一個例子。注意每個ntp沒有列出相同的服務器。這是爲了更好地使用對等同步。所以對等同步可以匹配不同的時間結果。

1a 1b  1c 1d  1e 1f  outside 
. \/...... \/...... \/.............. 
    2a ---p--- 2b ---p--- 2c  inside 
    /|\  /|\  /|\ 
/| \ /| \ /| \ 
3a 3b 3c 3e 3f 3g 3h 3i 3j 

Key: 1 = stratum-1, 2 = stratum-2, 3 = stratum-3, p = peer 
#Diagram + more info: http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm 

NTP服務器A(myntp.server.a)

# Undisciplined Local Clock. This is a fake driver intended for backup 
# and when no outside source of synchronized time is available. 
server 127.127.1.0 
fudge 127.127.1.0 stratum 10 

server 0.pool.ntp.org iburst 
server 1.pool.ntp.org iburst 
peer myntp.server.b 
peer myntp.server.c 

NTP服務器B(myntp.server.b)

server 2.pool.ntp.org iburst 
server 3.pool.ntp.org iburst 
peer myntp.server.a 
peer myntp.server.c 

如果一臺服務器(例如myntp.server.a)運行一個本地時鐘,一切都會同步到 - 不管怎麼說 - 但至少網絡上的時鐘將保持在一起 - 更多信息請參見: http://compgroups.net/comp.protocols.time.ntp/undisciplined-local-clocks/1874258#sthash.xnGpZubJ.dpuf

的更多信息:http://doc.ntp.org/4.1.1/confopt.htm