linux时间同步windows,windows 和linux做时间同步方法

周海汉 /文

2010.6.9

此前写了篇《

0818b9ca8b590ca3270a3433284dd417.png

但如果windows系统不能上公网时,必须使用本地的时间服务器。由于我linux局域网的时间服务器地址是192.168.12.31.如果直接将时间服务器的IP修改为192.168.12.31, 更新时间会失败。加入域的windows缺省的时间同步类型是nt5ds,没有加入域的是ntp.

可以在windows直接安装一个ntp时间服务器。比如到此下载 :http://www.meinberg.de/english/sw/ntp.htm

现在既然linux已经有了时间服务器,就不必再安装时间服务器了。

由于windows自带时间同步客户端,可以直接修改注册表配置。

方便起见,直接导入注册表文件。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time]

"Description"="维护在网络上的所有客户端和服务器的时间和日期同步。如果此服务被停止,时间和日期的同步将不可用。如果此服务被禁用,任何明确依赖它的服务都将不能启动。

"

"DisplayName"="Windows Time"

"ErrorControl"=dword:00000001

"FailureActions"=hex:05,00,00,00,00,00,00,00,00,00,00,00,02,00,00,00,64,00,20,/

00,01,00,00,00,60,ea,00,00,01,00,00,00,60,ea,00,00

"Group"=""

"ImagePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,/

74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,/

00,76,00,63,00,68,00,6f,00,73,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,/

6b,00,20,00,4c,00,6f,00,63,00,61,00,6c,00,53,00,65,00,72,00,76,00,69,00,63,/

00,65,00,00,00

"Objectname"="NT AUTHORITY//LocalService"

"Start"=dword:00000004

"Type"=dword:00000020

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Config]

"LastClockRate"=dword:0002625a

"MinClockRate"=dword:000260d4

"MaxClockRate"=dword:000263e0

"FrequencyCorrectRate"=dword:00000004

"PollAdjustFactor"=dword:00000005

"LargePhaseOffset"=dword:02faf080

"SpikeWatchPeriod"=dword:00000384

"HoldPeriod"=dword:00000005

"LocalClockDispersion"=dword:0000000a

"EventLogFlags"=dword:00000002

"PhaseCorrectRate"=dword:00000001

"MinPollInterval"=dword:0000000a

"MaxPollInterval"=dword:0000000f

"UpdateInterval"=dword:00057e40

"MaxNegPhaseCorrection"=dword:0000d2f0

"MaxPosPhaseCorrection"=dword:0000d2f0

"AnnounceFlags"=dword:00000005

"MaxAllowedPhaseOffset"=dword:00000001

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Parameters]

"ServiceMain"="SvchostEntry_W32Time"

"ServiceDll"=hex(2):43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,57,00,53,/

00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,77,00,33,00,/

32,00,74,00,69,00,6d,00,65,00,2e,00,64,00,6c,00,6c,00,00,00

"NtpServer"="192.168.12.31,0x1"

"Type"="NTP"

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Security]

"Security"=hex:01,00,14,80,a8,00,00,00,b4,00,00,00,14,00,00,00,30,00,00,00,02,/

00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00,/

00,00,02,00,78,00,05,00,00,00,00,00,14,00,8d,00,02,00,01,01,00,00,00,00,00,/

05,0b,00,00,00,00,00,18,00,ff,01,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,/

20,02,00,00,00,00,18,00,8d,00,02,00,01,02,00,00,00,00,00,05,20,00,00,00,23,/

02,00,00,00,00,14,00,9d,00,00,00,01,01,00,00,00,00,00,05,04,00,00,00,00,00,/

18,00,9d,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,21,02,00,00,01,01,00,/

00,00,00,00,05,12,00,00,00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/TimeProviders]

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/TimeProviders/NtpClient]

"Enabled"=dword:00000001

"InputProvider"=dword:00000001

"AllowNonstandardModeCombinations"=dword:00000001

"CrossSiteSyncFlags"=dword:00000002

"ResolvePeerBackoffMinutes"=dword:0000000f

"ResolvePeerBackoffMaxTimes"=dword:00000007

"CompatibilityFlags"=dword:80000000

"EventLogFlags"=dword:00000001

"LargeSampleSkew"=dword:00000003

"DllName"="C://WINDOWS//system32//w32time.dll"

"SpecialPollTimeRemaining"=hex(7):00,00

"SpecialPollInterval"=dword:00000e10

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/TimeProviders/NtpServer]

"InputProvider"=dword:00000000

"AllowNonstandardModeCombinations"=dword:00000001

"DllName"="C://WINDOWS//system32//w32time.dll"

"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Enum]

"0"="Root//LEGACY_W32TIME//0000"

"Count"=dword:00000001

"NextInstance"=dword:00000001

将以上脚本另存为ntp.reg, 192.168.12.31修改为你要的ntp服务器地址,然后导入。

Windows ntp客户端配置

除标准时钟服务器外,其它的Windows 平台都作为客户端,不需要安装程序,只作注册表配置。导入压缩包里的注册表ntp.reg ,打开注册表,根据需要做以下修改:

1 .如果导入前没有修改ntp地址,则必须进入注册表编辑如下键值

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Parameters/NtpServer

这一项是设置标准时钟源IP 地址的。将192.168.12.31 替换为选定的时钟服务器的IP 地址,后面的,0x1 留着不要改。

2 .(根据需要更改)

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/TimeProviders/NtpClient/SpecialPollInterval

这一项是设置客户端向服务器同步的轮询间隔,单位为秒,默认设为1 小时,可根据需要做修改。

3 .( 根据需要更改 )

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Config/MaxPosPhaseCorrection

这一项是设置最大的正时间校准量,单位为秒,默认设为15 小时,可根据需要修改。

4 .( 根据需要更改)

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/Config/MaxNegPhaseCorrection

这一项是设置最大的负时间校准量,单位为秒,默认设为15 小时,可根据需要修改。

5 . 退出注册表编辑器。

6 .在命令提示符处,键入以下命令以重新启动 Windows 时间服务,然后按 Enter :

net stop w32time && net start w32time

也可以到系统的服务里找到windows time服务,重启该服务。对集群服务器,会引起集群服务的关闭。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值