Raspberry Pi 时间同步及windows 安装 ntp服务器的方法

参考链接

http://www.ronnutter.com/raspberry-pi-ntp-client-setup/

http://www.cnblogs.com/mybook/archive/2012/11/06/2757597.html

一.

Option 1 – sudo raspi-config, select change_timezone

Option 2 – sudo dpkg-reconfigure tzdata, Select the right country/timezone

使用上述方法可以设置时区

二.

pi@raspberrypi:~$ date
Sun Feb 24 14:38:41 CST 2013

使用上述方法查看当前时间

三.

pi@raspberrypi:~$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*192.168.1.20 LOCAL(0) 13 u 8 64 3 0.304 1.632 1.407

使用上述方法查看当前ntp连接状态

四.

/etc/ntp.conf

文件中设置了ntp服务器的地址

# 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:
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst

局域网添加IP地址

五.

windows安装ntp-4.2.8p8-win32-setup.exe https://www.meinbergglobal.com/english/sw/ntp.htm

六.

局域网使用LOCAL时间设置方法如下

aaa

七.

Edit NTP Configuration

# restrict default noquery nopeer nomodify notrap
restrict default limited kod nomodify notrap nopeer noquery
# restrict -6 default noquery nopeer nomodify notrap
restrict -6 default limited kod nomodify notrap nopeer noquery

后重启ntp

符:

NTP:ntpq -p参数解释

remote:NTP主机的IP或者是主机名(ntp.conf文件中配置的server和peer主机)
如果有『 * 』代表目前正在作用当中的上层 NTP
如果是『 + 』代表也有连上线,而且可作为下一个提供时间更新的候选者。

refid:参考的上一层 NTP 主机的地址
st:st的值表示的是远程主机的层级(NTP采用分层同步方式,一般第n+1级与第n级时钟源进行同步。NTP最多支持16层同步,即0-15层。多于16层将无法同步。
如果远程主机是当前主机的NTP Server的话,一般情况下本级主机的层级是st+1)。
t:The type of the peer (local, unicast, multicast or broadcast) when the last packet was received
l local (such as a GPS clock)
u unicast (this is the common type) (单播,即NTP client向NTP server发送NTP请求,NTP server回复的模式)
m multicast (多播,可跨子网。)
b broadcast (广播,不可跨子网。NTP server定时向广播地址发送NTP包,NTP client通过广播地址获取NTP包,同步本地时钟)
– netaddr (usually 0) when:自上次时钟同步以来经过了多少秒(当when=poll时,进行一次时钟同步,同时when被清零,从头开始计时。通过when可以知道上一次同步时间
(当前时间- when)和下一次同步时间(当前时间+poll-when))
pool:时钟同步间隔(ntp服务刚启动时,缺省的最小同步间隔是64(minpoll=6)秒,然后依次增加,128, 256, ……, 1024。缺省的最大值是1024(maxpoll=10)秒。
这两个值分别可以通过minpoll和maxpoll参数修改。)
reach:八进制数,表示最近8次时钟同步包接收情况(1表示接收成功,0表示接收失败。每接收一个包左移一位。对于一个运行较长时间的NTP client而言,
这个值应该是377->11,111,111,即最近8次包接收均成功;否则表示有丢包情况发生)
NTP刚启动后Reach变化:

如果最近的一次包接受失败:

delay:表示NTP client从发出NTP请求到接收到NTP服务器回复所经过的时间(毫秒)。
offset:即NTP client的本地时间与NTP服务器时间的差异。也就是NTP client需要调整的时间差异。
disp:表示两次时钟同步之间的offset的差值。
Jitter:Linux 系统时间与 BIOS 硬件时间的差异时间(毫秒)。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注