本文作者:admin

检查ntp服务器是否有效linux?

admin 2024-05-07 0 0条评论

一、检查ntp服务器是否有效linux?

查看ntp服务的状态:1# service ntpd status然后可以用ntp客户端测试一下:12# /usr/sbin/ntpdate -u 210.72.145.44 从时间服务器更新系统时间# /usr/sbin/ntpdate -q 210.72.145.44 查询不更新(ServerIp:210.72.145.44)

二、linux如何配置与ntp服务器同步?

Linux可以通过配置NTP(Network Time Protocol)与NTP服务器同步时间。

首先,需要安装ntp软件包,然后编辑/etc/ntp.conf文件,将NTP服务器的IP地址添加到server行中。

保存并退出文件后,启动ntp服务并设置开机自启动。

使用命令ntpdate -q <NTP服务器IP地址>可以测试与NTP服务器的连接。

最后,使用命令systemctl restart ntpd重启ntp服务,使其与NTP服务器同步时间。这样,Linux系统就可以自动与NTP服务器同步时间,确保时间的准确性。

三、如何在linux suse中配置NTP服务器?

在suse上配置ntp

$vim /etc/ntp.conf

#增加时间源

server 192.168.56.1

$chkconfig ntp on # 在系统重启时启动服务

$service ntp start # 启动ntp

$service ntp status # 查看ntp状态

问题:

1)为什么在故意改了一个错误的时间,ntpd没有更新时间?

如果差异很大,需要重新doing an Initial Synchronization,If the time on the local server is very different from that of its primary time server your NTP daemon will eventually terminate itself leaving an error message in the /var/log/messages file. You should run the ntpdate -u command to force your server to become instantly synchronized with its NTP servers before starting the NTP daemon for the first time. The ntpdate command doesn't run continuously in the background, you will still have to run the ntpd daemon to get continuous NTP updates.

2)/etc/ntp.conf中选择主NTP Server

选择了哪个server做为主server是按stratum的大小决定的?应该不是,由ntp的算法决定,如在virtualbox中的suse怎么样都无法选择外部时钟源,ntpd在几次poll time后算法就决定使用local源,郁闷啊。由于是虚拟机中运行,时钟和cpu的频率有关系,跳得比真实的硬件快,在virtaulbox中ntp的算法认为local源比外部源更准确就使用了local的,解决的方法可以去掉local源,只使用外部源或者在crontab中每分钟执行一次ntpdate了。

即使把本机的stratum设置为比外部源更高的,过了一段时间以后,virtualbox中的suse还是选择了local,郁闷again

fudge 127.127.1.0 stratum 12 # not disciplined

remote refid st t when poll reach delay offset jitter

==============================================================================

LOCAL(0) .LOCL. 15 l 9 64 1 0.000 0.000 0.002

192.168.56.1 139.114.32.134 14 u 8 64 1 3.739 -53.045 0.002

注意最开始的时候,ip地址前面是没有符号的,poll几次以后ntp就会选择一个主时间源,前面带 * 号标识。

3)windows上的ntp server配置

官方ntp.org推荐的win上的ntp server,http://www.meinberg.de/german/sw/ntp.htm

3)如何知道ntp的运行状态

使用ntpq命令

$watch ntpq -p # 可以使用watch命令来查看一段时间内服务器各项数值的变化

使用ntpq命令查看与您同步的服务器. 它提供你一份时间服务器配置清单,包括延误值(delay),偏差值(offset)和抖动值(jitter). 为了能正确同步,延迟值和偏移值应该不为零,抖动值(jitter)应小于100 .

$/usr/local/ntp/bin/ntpq -p

显示如下:

remote refid st t when poll reach delay offset jitter

========================================================

time.nist.gov .ACTS. 1 u 1606 1024 22 357.845 334.375 71.122

*LOCAL(0) .LOCL. 10 l 11 64 377 0.000 0.000 0.001

ntpq -p 可以列出目前我们的NTP与相关的上层NTP的状态,几个字段的意义为:

remote:亦即是 NTP 主机的 IP 或主机名称啰~注意最左边的符号,http://www.ece.udel.edu/~mills/ntp/html/decode.html#peer

*

它告诉我们远端的服务器已经被确认为我们的主NTP Server,我们系统的时间将由这台机器所提供

+

它将作为辅助的NTP Server和带有*号的服务器一起为我们提供同步服务. 当*号服务器不可用时它就可以接管

-

远程服务器被clustering algorithm认为是不合格的NTP Server

x

远程服务器不可用

refid:参考的上一层 NTP 主机的地址

st:stratum 阶层

when:几秒钟前曾经做过时间同步化更新的动作;

poll:下一次更新在几秒钟之后;

reach:已经向上层 NTP 服务器要求更新的次数

delay:网络传输过程当中延迟的时间,单位为 10^(-6) 秒

offset:时间补偿的结果,单位与 10^(-6) 秒

jitter:Linux 系统时间与 BIOS 硬件时间的差异时间, 单位为 10^(-6) 秒。

也可以检查一下BIOS时间与Linux系统时间的差异,就是/var/lib/ntp/drift的内容,就能了解到Linux系统时间与BIOS硬件时钟到底差多久?单位为 10^(-6) 秒

下面的从http://www.meinberg.de/english/info/ntp.htm上摘下来的,详细说明了ntpq -p输出的每个列的意思,reach列为377表示前8次同步都成功。

Checking the NTP Status

The command line utility ntpq can be used to check the status of a NTP daemon on either the local machine or on a remote host.

ntpq can be run in an interactive mode or in batch mode. In batch mode, ntpq executes a command and returns to the command prompt. The parameter -p ('peers') lets ntpq print the status of a NTP daemon. Enter

ntpq -p

to display the status of the daemon on the local machine, or

ntpq -p ntp_server

to display the status of the daemon on the remote host ntp_server. The command should print a table with one status line for each reference time source which has been configured for the NTP daemon on the specified host:

remote refid st t when poll reach delay offset jitter

=======================================================================

LOCAL(0) LOCAL(0) 12 l 30 64 377 0.000 0.000 0.000

*GENERIC(0) .DCFa. 0 - 24 64 377 0.000 0.050 0.003

+172.16.3.103 .PPS. 1 u 36 64 377 1.306 -0.019 0.043

The table above shows the output for a NTP daemon which has 3 reference time sources: its own local clock, a DCF77 radio clock as refclock-0, plus an NTP daemon on the network, with IP address 172.16.3.103.

If the first character of a line is not blank then it contains a qualifier for the corresponding reference time source. Immediately after the daemon has been started all qualifiers are blank. The NTP daemon needs several polling cycles to check the available time sources and declare one of them as the reference it synchronizes to.

An asterisk * in the first column marks the reference time source which is currently preferred by the NTP daemon, the + character marks high quality candidates for the reference time which could be used if the currently selected reference time source should become unavailable.

The column remote displays the IP address or the host name of the reference time source, where LOCAL refers to the local clock. The refid shows the type of the reference clock, where e.g. LOCAL or LCL refers to the local clockagain, .DCFa. refers to a standard DCF77 time source, and .PPS. indicates that the reference clock is disciplined by a hardware pulse-per-second signal. Other identifiers are possible, depending on the type of the reference clock.

The column st reflects the stratum number of the reference time source. In the example above, the local clock has stratum 12, the remote time server at 172.16.3.103 has stratum 1 which is the best you can see across the network, and the local radio clock has stratum 0, so the radio clock is currently being preferred.

Every time a when count reaches the poll number in the same line, the NTP daemon queries the time from the corresponding time source and resets the when count to 0. The query results of each polling cycle are filtered and used as a measure for the clock's quality and reachability.

The column reach shows if a reference time source could be reached at the last polling intervals, i.e. data could be read from the reference time source, and the reference time source was synchronized. The value must be interpreted as an 8 bit shift register whose contents is for historical reasons displayed as octal values. If the NTP daemon has just been started, the value is 0. Each time a query was successful a '1' is shifted in from the right, so after the daemon has been started the sequence of reach numbers is 0, 1, 3, 7, 17, 37, 77, 177, 377. The maximum value 377 means that the eight last queries were completed successfully.

Queries are considered successful if data can be received from the time source, and the time source in turn claims to be synchronized to some other timesource. In case of a hardware reference clock this means the query considered unsuccessful if the hardware reference clock is not synchronized to its incoming time signal, e.g. because the clock's antenna has been disconnected, or if no data can be received e.g. because the serial cable to an external device has been disconnected.

The NTP daemon must have reached a reference time source several times (reach not 0) before it selects a preferred time source and puts an asterisk in the first column.

The columns delay, offset and jitter show some timing values which are derived from the query results. In some versions of ntpq the last column is labeled disp (for dispersion) instead of jitter. All values are in in milliseconds. The delay value is derived from the roundtrip time of the queries. The offset value shows the difference between the reference time and the system clock. The jitter value indicates the magnitude of jitter between several time queries.

四、linux查看ntp服务器的端口是否开启?

要查看Linux上的NTP服务器端口是否开启,可以使用以下命令:

1. 首先,使用netstat命令查看当前系统上所有的网络连接和监听端口:

```

netstat -tuln

```

2. 在netstat的输出中,找到NTP服务器所使用的端口,默认情况下,NTP服务器使用UDP端口123。

3. 如果在netstat的输出中找不到UDP端口123,则表示NTP服务器端口未开启。

4. 另外,还可以使用telnet命令测试NTP服务器端口的连通性:

```

telnet <NTP服务器IP> 123

```

如果连接成功,则表示NTP服务器端口开启;如果连接失败,则表示NTP服务器端口未开启。

请注意,执行上述命令需要具有足够的权限,通常需要使用root用户或具有sudo权限的用户来执行。

五、linux怎么查看ntp服务地址?

1. Linux中查看nto服务的地址,可以执行ntpq -p进行查询。

2.或者可以通过查看ntp的配置文件:/etc/ntp.conf

执行more /etc/ntp.conf|grep server

在这个配置文件里面一般记录着ntp服务的上一级ntp server的IP地址或者域名。

3.或者查看历史记录,因为有的时候执行的是类似ntpdate ntp.api.bz 或者ntpdate cn.pool.ntp.org。所以通过历史记录可以直接查询到。

六、海康ntp服务器地址?

海康提供的NTP服务器 120.24.166.46 端口 123

七、ntp服务器品牌排名?

ntp服务厂家其实并不多,有:

北京泰福特,西安同步电子科技,深圳思利敏,烟台持久,青岛广研所,成都可为,上海锐呈等一些新生厂家。

北京泰福特:做的比较久了,技术也相对领先,比如1000M网卡,但是相对同类价格高很多,但是有早些年的底子也没啥影响;

八、ntp服务器连接异常?

可能是以下几种情况:

1、连接机顶盒的信号弱。

解决方法:连接机顶盒的信号线插头松了,需把信号线重新接好即可恢复信号。

2、机顶盒的信号解调器坏了。

解决方法:让专业师傅更换信号解调器。

3、广电前端对个别节目进行停播调整,使得出现节目不能收看。

解决方法:等广电修改完即可。

九、ntp服务器

互联网时代的到来,使得人们对时间的精准度有了更高的要求,尤其对于计算机网络而言,在各个设备间进行时间同步显得尤为重要。而在实现网络时间同步的过程中,NTP服务器起到了至关重要的作用。

什么是NTP服务器?

NTP(Network Time Protocol)是一种用于在Internet上传输时间信息的协议,它通过一种层级结构的方式将时间同步传递到各个设备上,确保网络中的计算机具有相同的时间标准。而NTP服务器则是在网络中提供NTP服务的设备,它充当着时间源的角色,为其他设备提供准确的时间信息。

一台NTP服务器通过连接GPS设备、原子钟或其他可靠的时间源来获得高精度的时间信息,并将这些信息传输给网络中的其他设备。这样一来,整个网络中的设备就可以根据NTP服务器提供的时间信息进行时间同步,保持时钟的准确性。

NTP服务器的工作原理

NTP服务器工作的基本原理可以简单地概括为:

  1. 获取时间信息:NTP服务器通过连接外部时间源获取准确的时间信息,如GPS设备、原子钟等。
  2. 时间校准:NTP服务器根据获取的时间信息进行时间校准,确保其本身的时钟精度。
  3. 提供服务:NTP服务器将校准后的时间信息传输给其他设备,充当时间源。
  4. 时间同步:其他设备通过与NTP服务器进行通信,获取时间信息并进行时间同步,保持整个网络的时间一致性。

选择合适的NTP服务器

在选择NTP服务器时,需考虑以下几个关键因素:

  • 可靠性:选择具有高可靠性的NTP服务器,它应该能够稳定地工作,并能够自动纠正时间误差。
  • 精确度:选择具有高精确度的NTP服务器,确保提供的时间信息尽可能准确。
  • 容量:根据网络规模和连接设备数量选择适当的NTP服务器容量,避免出现过载或性能下降。
  • 安全性:选择具有安全机制的NTP服务器,以防止未经授权的访问和篡改。

通过综合考虑以上因素,选择一台适合自身需求的NTP服务器,可以帮助网络运维人员实现更精确、更稳定的时间同步。

部署NTP服务器的步骤

要在网络中部署一台NTP服务器,并确保其正常工作,可以按照以下步骤进行:

  1. 选择硬件:根据网络规模和需求选择合适的NTP服务器硬件,如专用服务器、路由器或交换机等。
  2. 安装NTP服务器软件:将选择的NTP服务器硬件上安装NTP服务器软件,如NTPd、Chrony等。
  3. 配置NTP服务器:按照需求配置NTP服务器,指定时间源、时间策略等参数。
  4. 测试与调试:在部署完成后,进行测试和调试,确保NTP服务器正常工作,并能提供准确的时间信息。
  5. 扩展与监控:根据需要,可以扩展NTP服务器的容量,同时设置合适的监控机制,及时发现并解决可能的问题。

常见的NTP服务器

市场上有许多可供选择的NTP服务器,以下是一些常见的NTP服务器:

  • Microsemi SyncServer:Microsemi SyncServer系列产品是一系列精密的NTP服务器,具有高性能和可靠性,广泛应用于通信、金融、电力等领域。
  • Meinberg LANTIME:Meinberg LANTIME系列产品是一系列专业级NTP服务器,具有灵活性和高度精确的时间同步能力。
  • Trimble Thunderbolt:Trimble Thunderbolt是一款高精度的NTP服务器,采用GPS作为时间源,能够提供非常精确的时间信息。

无论选择哪一款NTP服务器,都需要根据自身需求和实际情况进行评估,选择最合适的一款。

总结

NTP服务器在网络时间同步中起到了重要的作用,通过提供准确的时间信息,使得整个网络中的设备能够保持一致的时间标准。选择合适的NTP服务器,并正确地部署和配置,可以帮助网络运维人员实现更精确、更稳定的时间同步。因此,在建设网络时,务必要重视NTP服务器的选择与部署。

十、ntp服务器哪个品牌好?

ntp服务厂家其实并不多,有:

北京泰福特,西安同步电子科技,深圳思利敏,烟台持久,青岛广研所,成都可为,上海锐呈等一些新生厂家。

北京泰福特:做的比较久了,技术也相对领先,比如1000M网卡,但是相对同类价格高很多,但是有早些年的底子也没啥影响;