域内主机会自动同步域服务器的时间,可有时候发现服务器的时间不对了,连锁反应就来了。
方法1:
运行gpedit.msc 打开本地策略组(Winserver2012和2016应该是一样的),路径为:计算机配置->管理模板->系统->Windows 时间服务:
1.1配置Windows NTP客户端
(ntp服务器一般用 ntp.windows.com或ntp.aliyun.com)
1.2.启用Windows NTP客户端
1.3.重启 Windows time服务
C:\WINDOWS\system32>w32tm /query /status
Leap 指示符: 3(未同步)
层次: 0 (未指定)
精度: -23 (每刻度 119.209ns)
根延迟: 0.0000000s
根分散: 0.0000000s
引用 ID: 0x00000000 (未指定)
上次成功同步时间: 未指定
源: Local CMOS Clock
轮询间隔: 10 (1024s)
C:\WINDOWS\system32>w32tm /query /configuration |findstr 'Ntp'
NtpClient (本地)
NtpServer: time.windows.com,0x9 (本地)
NtpServer (本地)
C:\WINDOWS\system32>reg query HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
AllowNonstandardModeCombinations REG_DWORD 0x1
ChainDisable REG_DWORD 0x0
ChainEntryTimeout REG_DWORD 0x10
ChainLoggingRate REG_DWORD 0x1e
ChainMaxEntries REG_DWORD 0x80
ChainMaxHostEntries REG_DWORD 0x4
DllName REG_EXPAND_SZ %systemroot%\system32\w32time.dll
Enabled REG_DWORD 0x0
EventLogFlags REG_DWORD 0x0
InputProvider REG_DWORD 0x0
RequireSecureTimeSyncRequests REG_DWORD 0x0
**ntp server 的 Enabled REG_DWORD 0x0 说明不为ntp server,
**修改为1,可为ntp server
C:\Users\lan>w32tm /stripchart /computer:ntp.aliyun.com
正在跟踪 ntp.aliyun.com [203.107.6.88:123]。
当前时间是 2023/9/14 10:14:11。
10:14:11, d:+00.0280954s o:-04.6155786s [ * | ]
10:14:13, d:+00.0200577s o:-04.6180718s [ * | ]
10:14:15, d:+00.0242482s o:-04.6184669s [ * | ]
10:14:17, d:+00.0282700s o:-04.6171150s [ * | ]
w32tm /config /syncfromflags:MANUAL /manualpeerlist:'ntp.aliyun.com,0x09' /reliable:YES /update
C:\WINDOWS\system32>w32tm /config /update
成功地执行了命令。
如果上述设置后,时间差距较大,不能立即同步,可以执行以下命令来同步
w32tm /resync
报以下错误
首先,运行如下命令删除时间配置:
#net stop w32time
#C:\Users\lan>w32tm /unregister
W32Time 成功取消注册。
然后,再运行如下命令加载默认时间配置
W32tm /register
官方文档
https://learn.microsoft.com/zh-cn/windows-server/networking/windows-time-service/Windows-Time-Service-Tools-and-Settings?redirectedfrom=MSDN&tabs=config
联系客服