温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ntp时间同步问题解决方法

发布时间:2020-07-21 01:24:21 来源:网络 阅读:13595 作者:海斌2019 栏目:系统运维

亚洲 - asia.pool.ntp.org http://www.pool.ntp.org/zone/asia
0.asia.pool.ntp.org
1.asia.pool.ntp.org
2.asia.pool.ntp.org
3.asia.pool.ntp.org

2.1 注册表信息修改
PDC配置外部时间源设置

#config external NTP server
w32tm.exe /config /manualpeerlist:”0.asia.pool.ntp.org,1.asia.pool.ntp.org,2.asia.pool.ntp.org,3.asia.pool.ntp.org,0x1” /syncfromflags:manual /reliable:YES /update

#update
w32tm.exe /config /update
#此处可以在配置过程中不使用,在配置不生效的情况下再执行关闭和开启服务器的动作
#stop w32time
Stop-Service W32Time
#start w32time
start-Service w32time

#internal NTP for PDC
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" -Name "Type" -Value NTP
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config" -Name "AnnounceFlags" -Value 5
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" -Name "Enabled" -Value 1
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" -Name "SpecialPollInterval" -Value 900
说明:
以上代码配置可以直接对PDC配置外部时间源,同时针对客户端的更细频率等参数进行设置,设置可以根据客户的实际要求酌情进行调整

2.1.1 指定外部时间源
w32tm /config /manualpeerlist:"time.stdtime.gov.tw clock.stdtime.gov.tw tick.stdtime.gov.tw watch.stdtime.gov.tw,0x1" /syncfromflags:manual /reliable:yes /update
ntp时间同步问题解决方法
2.1.2 设置授权时间服务器
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config"
[AnnounceFlags]修改设定值为5

ntp时间同步问题解决方法
2.1.3 启用NTP服务
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" [Type]设定值修改为NTP
ntp时间同步问题解决方法
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" [Enabled]数值修改为1

ntp时间同步问题解决方法

2.1.4 设定查询时间间隔
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" [SpecialPollInterval]修改数值为"十进制"600
ntp时间同步问题解决方法
2.1.5 时间修正设置
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config"
[MaxPosPhaseCorrection]修改为十进制6000 (负差校正) – 若网络时间比本地时间慢超过这个秒数就不自动更正
[MaxNegPhaseCorrection]修改为十进制6000 (正差校正) – 若网络时间比本地时间快超过这个秒数就不自动更正
ntp时间同步问题解决方法

2.1.6 开启时间服务端口
netsh firewall add portopening protocol=UDP port=123 name=NTPSERVER

ntp时间同步问题解决方法

2.1.7 重启Time32时间服务并同步外部时间源
Net stop w32time & net start w32time //重启w32time时间服务器
W32tm /config /update //更新时间服务配置信息
W32tm /resync //同步时间源
w32tm /query /peers //查询时间同步服务器及相关情报
W32tm /query /source //查看同步时间源
ntp时间同步问题解决方法
2.2 修改AD相关设置

2.2.1 设置AD时间源服务器
ntp时间同步问题解决方法

2.2.2 修改PDC服务器使用内部时间源
ntp时间同步问题解决方法
2.2.3 组策略设置
ntp时间同步问题解决方法
3 同步时间测试
没有加域的客户端第一次需要运行同步时间脚本,来指定内部NTP服务器进行时间同步
脚本 内容如下:
@echo off
color 2f
title 调整 Time
echo.
echo.
echo.
echo. 开启防火墙123端口
netsh firewall add portopening protocol = UDP port =123 name = NTPSERVER
echo.
echo.
echo.
echo. 写入注册表信息
w32tm /config /update /manualpeerlist:"172.16.108.7 ntp.fudan.edu.cn s1b.time.edu.cn s1c.time.edu.cn,0x1"
echo.
echo.
echo.
echo. 重启w32time服务
net stop w32time & net start w32time
echo.
echo.
echo.
echo. 更新时间配置
w32tm /config /update
w32tm /config /update
w32tm /config /update
w32tm /resync
w32tm /resync
w32tm /resync
w32tm /resync
w32tm /resync
w32tm /resync
pause
经过反复测试,客户端可以成功同步时间服务器时间;

查看注册表分支:[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient],找到Enabled,修改0为1,然后重启时间同步服务即可;
同步时间遇到“找不到元素”时这样操作可以解决。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI