ntp时间同步会导致mysql关闭吗?_ntp时间同步问题解决方法

本文详细介绍了如何配置和调整Windows系统以实现ntp时间同步,包括修改注册表、设置外部时间源、启用NTP服务、设置查询时间间隔以及处理时间修正。同时,提供了客户端同步时间的脚本。通过这些步骤,可以避免ntp时间同步可能对MySQL等服务造成的影响。
摘要由CSDN通过智能技术生成

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

d00b8106f62bd79db7118de4acb800cb.png

2.1.2 设置授权时间服务器

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config"

[AnnounceFlags]修改设定值为5

68038f2b67ea57b417325cbd66f2023f.png

2.1.3 启用NTP服务

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" [Type]设定值修改为NTP

9b45bb187c87f11e881e9922765e730d.png

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" [Enabled]数值修改为1

a773e4654834c8235d327e04b7cc6415.png

2.1.4 设定查询时间间隔

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" [SpecialPollInterval]修改数值为"十进制"600

a6c756088948043f55381abbaf761788.png

2.1.5 时间修正设置

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config"

[MaxPosPhaseCorrection]修改为十进制6000 (负差校正) – 若网络时间比本地时间慢超过这个秒数就不自动更正

[MaxNegPhaseCorrection]修改为十进制6000 (正差校正) – 若网络时间比本地时间快超过这个秒数就不自动更正

1cf5899137deae75078b4a4bbad15bae.png

2.1.6 开启时间服务端口

netsh firewall add portopening protocol=UDP port=123 name=NTPSERVER

cbc6f83a2a98404ca97200f5d288faf2.png

2.1.7 重启Time32时间服务并同步外部时间源

Net stop w32time & net start w32time //重启w32time时间服务器

W32tm /config /update //更新时间服务配置信息

W32tm /resync //同步时间源

w32tm /query /peers //查询时间同步服务器及相关情报

W32tm /query /source //查看同步时间源

3dad1bab196db65a9df23f271da25a63.png

2.2 修改AD相关设置

2.2.1 设置AD时间源服务器

c7bf374b31ea9b8818bcde7bfa19d92d.png

2.2.2 修改PDC服务器使用内部时间源

93b17a726ebebfc4281fced751368aff.png

2.2.3 组策略设置

f6b03ede4aa52ff9b3c26e83abc1c7c4.png

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,然后重启时间同步服务即可;

同步时间遇到“找不到元素”时这样操作可以解决。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值