我试图让一个没有外部互联网访问 (A) 的系统从 LAN 上的另一个系统 (B) 获取时间。
在 A 的 ntp.conf (整个内容在底部)中,我添加了:
server 192.168.2.102
restrict 192.168.2.102
Run Code Online (Sandbox Code Playgroud)
参考B的IP。经过一个小时的阅读手册页,查看在线示例等,据我所知,这应该意味着它将使用该本地服务器,并信任它。
但是,它不起作用。我可以在 中观看两次交换时间wireshark
,并ntpq -p
在 A 节目中运行:
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.2.102 .INIT. 16 u 16 64 0 0.000 0.000 0.000
Run Code Online (Sandbox Code Playgroud)
如果我停ntpd
在 A 上并尝试ntpd -gq
,我可以再次在wireshark中来回观看,但是一两分钟后命令超时并显示“未找到服务器”。
我什至尝试添加到 A 的 conf:
fudge 192.168.2.102 stratum 1
Run Code Online (Sandbox Code Playgroud)
没有任何区别。
如何强制 ntpd 从特定服务器设置时间? 看起来这曾经很容易使用ntpdate
- 它已折旧并且系统中不存在。
这是机器 A 的整个 ntp.conf。这是 Debian wheezy 的库存。我所做的唯一更改是添加涉及 192.168.2.102 的行,并注释掉 …
我正在使用 SNTP 来同步我的基于 Debian 的系统。SNTP 有两种设置时钟的方法:
-s, --settod Set (step) the time with settimeofday().
-j, --adjtime Set (slew) the time with adjtime().
Run Code Online (Sandbox Code Playgroud)
转换方法以小步长调整本地系统时钟,直到检测到的偏移为零。进行回转主要是为了不扰乱对时间倒退产生不良反应的进程。
步进方法立即设置时钟。
关于时间的回转,SNTP 需要多长时间才能完成?
有没有办法轮询系统并给我反馈仍在进行转换?
我正在使用 PC 和树莓派(都运行 Linux)来收集传感器数据,树莓派收集激光扫描数据,PC 收集相机捕获的图像。我必须同步这两台机器的时间。我希望它们之间的时间差可以小于1ms。
我直接用网络连接它们,所以我不能使用一些众所周知的 NTP 服务器。我在树莓派上 ping PC,ping 时间小于0.6ms。我想出了两个想法:
哪个是更好的主意?或者你有什么更好的想法?如何计算两台机器之间的实际时间差?我可以将时差限制为 1 毫秒吗?
我有一个基于“windriver”linux 的 Wimax ASN,每当我登录时,我发现日期和时间是错误的(例如:“2010 年 7 月 15 日”)。
每当我使用date
命令或设置日期和时间时hwclock
,它会在我注销并再次登录后立即返回到旧状态“2010 年 7 月 15 日”,甚至无需重新启动设备。
有没有办法在不使用的情况下永久设置它们NTP
?
我尝试使用 NTP 和 GPS 同步时间。我可以从 cgps -s 命令中获取时间,但是 NTP 没有与之同步。
这是我的 ntp.conf:
tos mindist 1.0
# GPS Serial data reference
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 refid GPS
fudge 127.127.28.0 time1 +0.140 # coarse processing delay offset
# GPS PPS reference
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS
fudge 127.127.22.0 flag3 1 # enable kernel PLL/FLL clock discipline
Run Code Online (Sandbox Code Playgroud)
这是 ntpd 状态:
# ntpq -c peer -c as -c rl
remote refid st t when …
Run Code Online (Sandbox Code Playgroud) 我应该在我的单元文件中放入什么以确保我的服务在通过 ntp 设置时间后启动?
我有一个带有小型 python 脚本的树莓派,可以将数据记录到 SQL 数据库中。由于 rpi 没有 RTC 电池,在启动时或没有互联网连接时,时间和数据都是错误的。为避免数据库中的时间戳产生误导,脚本应在获取正确时间后运行。
到目前为止我的单位文件:
[Unit]
Description=desc
Requires=mysql.service
After=syslog.target mysql.service
[Service]
Type=simple
ExecStart= /usr/bin/python3 /etc/script/script.py
SyslogIdentifier=test
StandardOutput=null
StandardError=syslog
Restart=always
RestartSec=5
User=pi
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
我应该如何修改我的单元文件?
我的系统版本是:
#> systemctl --version
systemd 232
Run Code Online (Sandbox Code Playgroud) 我的 CentOS 服务器没有更新显示正确的时间。我已经设定
$ ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
Run Code Online (Sandbox Code Playgroud)
我仍然在格林威治标准时间。
我确实在 中看到了以下条目/etc/sysconfig/clock
:
$cat /etc/sysconfig/clock
ZONE="Europe/London"
UTC=true
ARC=false
Run Code Online (Sandbox Code Playgroud)
仍然没有显示正确的时间。
NTP 正在此服务器上运行:
$ ntpq -p
remote refid st t when poll reach delay offset jitter
+ IP Address 3 u 42 1024 377 0.476 63.077 0.001
* IP Address 3 u 53 1024 377 1.183 30.425 0.001
Run Code Online (Sandbox Code Playgroud)
ntp 服务器的时间正确。这些是 Windows 域控制器。
我已经从这里查看了答案https://serverfault.com/questions/267629/configure-centos-with-ntp但这对这种情况没有帮助。
有任何想法吗?
我正在设置一个 NTP 服务器(集群中的五个服务器之一)。我的配置文件:
restrict default kod nomodify notrap
driftfile /var/lib/ntp/drift
server tick.usno.navy.mil
server ntp.colby.edu
server tick.gatech.edu
#peer local-ntp.server.2
#peer local-ntp.server.3
#peer local-ntp.server.4
#peer local-ntp.server.5
Run Code Online (Sandbox Code Playgroud)
对等节点被注释掉是因为 a) 它们尚未配置 b) 我不确定是否应该使用它们。
这个想法是我配置的每个 NTP 服务器都将同步到 USNO 源。如果我们的出站连接出现故障,它们将相互同步,唯一目的是在网络上保持一致的时间。每个客户端都将配置为使用所有五个本地 NTP 服务器作为server
其 ntp.conf 中的指令。
最终,使用密钥身份验证会稍微复杂一些,但现在我从简单开始。我做得对吗?
我使用的是 Raspberry Pi 3,需要在重启系统后通过 ntp 更新时间。
它应该通过带有 dhcp 的 wifi 更新。通常它可以工作,但同步需要大约。半小时,我不明白为什么。
当我想手动启动 ntp 服务时
>>sudo /etc/init.d/ntp restart
Run Code Online (Sandbox Code Playgroud)
它说“好的”,但系统什么也不做——错误的时间仍然在 RTC 上。
你有什么想法,可能是什么问题?
另一个信息是,Pi 以只读模式运行……但是如果它在没有写访问权限的情况下无法工作,它在半小时后不会更新,不是吗?
更多细节:
在这里完成我的问题是ntp.conf:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
Driftfile /var/lib/ntp/ntp.drift
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
...
Server 0.de.pool.ntp.org iburst
Server 1.de.pool.ntp.org iburst
Server 2.de.pool.ntp.org iburst
Server 3.de.pool.ntp.org iburst
Server 127.127.1.0 #local clock
Fudge 127.127.1.0 …
Run Code Online (Sandbox Code Playgroud) 我想测试是否ntp
在我的机器上工作,所以我将时间设置回 5 分钟并重新启动 ntp
$ sudo service ntp stop
$ sudo date -s "9:40 AM" # This time was 5 minutes ago
$ sudo service ntp start
$ ntpq -c lpeer # Check if sync to servers is working
remote refid st t when poll reach delay offset jitter
==============================================================================
hachi.paina.jp .INIT. 16 u - 64 0 0.000 0.000 0.000
ts0.itsc.cuhk.e .INIT. 16 u - 64 0 0.000 0.000 0.000
ns.tx.primate.n .INIT. 16 u - 64 0 0.000 …
Run Code Online (Sandbox Code Playgroud)