两台windows上NTP服务器和客户端的安装与使用总结 (ntpq 和ntpdate)

Windows时间服务

从Windows 2000起的所有Microsoft Windows版本都包括Windows时间服务(W32Time),其具有将计算机时钟同步到NTP服务器的能力。微软称W32Time服务不能可靠地将同步时间保持在1至2秒的范围内。如果需要更高的精度,微软建议使用其他NTP实现。

windows高精度同步说明(Windows 10 和 Windows 服务器 2016)

官方说明:https://support.microsoft.com/zh-cn/help/939322/support-boundary-to-configure-the-windows-time-service-for-high-accuracy-environments


参考文章:http://blog.csdn.net/fan_hai_ping/article/details/8161306

用ntp同步两台机器的时间
1.安装:
  1.1.windows上安装ntp
   百度中搜ntp for Windows可以找到官方网站 
   软件下载:https://www.meinbergglobal.com/english/sw/ntp.htm#ntp_stable
   安装说明:http://www.satsignal.eu/ntp/setup.html
  1.2.Ubuntu上安装ntp
   直接apt-get install ntp即可


2.使用:
  其中一台作为服务器另一台作为客户端(window的cmd要以管理员身份运行
  分别举例说明:以Windows和Ubuntu做为服务器分别说明
  2.1.Windows作为服务器
    2.1.1在Windows上安装完ntp软件以后(软件自带了ntpdate命令,不需要再安装ntp客户端了
           将安装目录‘’Tools/etc/ntp,conf‘’文件中
           去除server 127.127.1.0和fudge 127.127.1.0 stratum 12 前的#符号(最好将stratum 12 改成 stratum 8)
           然后重启ntp,先用命令net stop ntp再用命令net start ntp
     2.1.2在Ubuntu的root权限下运行 ntpdate -b  ip(服务器ip地址)  即可同步两台机器的时间
  2.2.Ubuntu作为服务器
     2.2.1修改/etc/ntp.conf文件。
            a.添加这两行
               server 127.127.1.0
               fudge 127.127.1.0 stratum 10
            b.重启ntp服务
                先service ntp stop再service ntp start
     2.2.2在Windows的管理员权限的cmd中
             启动了ntp之后默认是作为服务器的,要用ntpdate命令需要先关闭服务器。
             在cmd中运行net stop ntp,然后运行 ntpdate  -b   ip(服务器ip地址)


3.错误解决
3.1:ntpdate[5588]: bind() fails: Permission denied
以管理员身份在cmd中运行ntpdate -b  192.168.195.129
出现错误:           7 Jun 17:01:28 ntpdate[5588]: bind() fails: Permission denied
解决方法:这是由于没有关闭ntp的原因,ntp和ntpdate不能同时运行。使用net stop ntp之后就可以正常运行了
3.2:ntpdate[4565]: the NTP socket is in use, exiting
运行ntpdate -b ip后出现ntpdate[4565]: the NTP socket is in use, exiting
解决方法:service ntp stop关闭ntp服务(ntp客户端和服务端只能同时存在一个)
3.3: no server suitable for synchronization found
运行ntpdate -b ip后出现 no server suitable for synchronization found
解决方法:1.确认对端ntp服务有没有起  用命令ntp -p查看
                2.这里有详细的解决http://www.blogjava.net/spray/archive/2008/07/10/213964.html


其他错误解决:http://www.chinaunix.net/old_jh/4/461976.html


4.其它
4.1:参考网址:
使用ntp进行时钟同步:http://blog.csdn.net/strangerzz/article/details/45243981
CentOS 7 中使用NTP进行时间同步:http://www.linuxidc.com/Linux/2015-11/124911.htm
4.2:命令说明
命令:ntpq -pn结果说明
remote:亦即是 NTP 主机的 IP 或主机名啰~注意最左边的符号
如果有『 * 』代表目前正在作用当中的上层 NTP
如果是『 + 』代表也有连上线,而且可作为下一个提供时间更新的候选者。
refid:参考的上一层 NTP 主机的地址
st:就是 stratum 阶层啰!
when:几秒钟前曾经做过时间同步化更新的动作;
poll:下一次更新在几秒钟之后;
reach:已经向上层 NTP 服务器要求更新的次数
delay:网络传输过程当中延迟的时间,单位为 10^(-6) 秒
offset:时间补偿的结果,单位与 10^(-3) 秒
jitter:Linux 系统时间与 BIOS 硬件时间的差异时间, 单位为 10^(-6) 秒。


ntpdate:参数
-p指定运行几次
-d一次同步到位(大于500ms一次同步,小于500ms不能一次同步到位所以要加-b参数)


猜你喜欢

转载自blog.csdn.net/tsh123321/article/details/72901972