NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议。它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。为了保证同一个网络内的设备保持时间的一致,所以部署NTP服务器做时钟源,所有的网络设备都向NTP服务器校时。在Win Server 2012服务器搭建NTP服务如下:
1、打开运行窗口,输入regedit命令后点击确定,进入注册表。
2、打开注册表,进入目录:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters,把 Type设定值修改为”NTP”。
3、进入如下目录:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config",把AnnounceFlags修改设定值为5。
4、进入如下目录:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer ,把Enabled数值修改为1。
5、打开运行窗口,输入services.msc命令,点击确定,进入服务管理页面。
6、找到Windows Time服务,双击打开该服务。
7、在常规页面,把启动类型修改为自动,点击启动,然后点击确定。
8、重启Windows Time服务。以管理员身份运行cmd,输入net stop w32time && net start w32time重启该服务。
9、设置防火墙运行123端口访问。输入netsh firewall add portopening protocol = UDP port =123 name = NTPSERVER命令设置。或输入netsh advfirewall firewall add rule name="NTP Service" protocol=UDP dir=in localport=123 action=allow。
10、海康摄像机向时钟服务器校时。
11、大华摄像机向时钟服务器校时。
可以使用已经设置好的注册表,然后导出,如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time]
"Description"="@%SystemRoot%\\system32\\w32time.dll,-201"
"DisplayName"="@%SystemRoot%\\system32\\w32time.dll,-200"
"ErrorControl"=dword:00000001
"FailureActions"=hex:80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,14,00,00,\
00,01,00,00,00,60,ea,00,00,01,00,00,00,c0,d4,01,00,00,00,00,00,00,00,00,00
"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,73,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"
"RequiredPrivileges"=hex(7):53,00,65,00,41,00,75,00,64,00,69,00,74,00,50,00,72,\
00,69,00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,43,00,68,00,\
61,00,6e,00,67,00,65,00,4e,00,6f,00,74,00,69,00,66,00,79,00,50,00,72,00,69,\
00,76,00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,43,00,72,00,65,00,\
61,00,74,00,65,00,47,00,6c,00,6f,00,62,00,61,00,6c,00,50,00,72,00,69,00,76,\
00,69,00,6c,00,65,00,67,00,65,00,00,00,53,00,65,00,53,00,79,00,73,00,74,00,\
65,00,6d,00,54,00,69,00,6d,00,65,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,\
00,67,00,65,00,00,00,53,00,65,00,49,00,6d,00,70,00,65,00,72,00,73,00,6f,00,\
6e,00,61,00,74,00,65,00,50,00,72,00,69,00,76,00,69,00,6c,00,65,00,67,00,65,\
00,00,00,00,00
"ServiceSidType"=dword:00000001
"Start"=dword:00000003
"Type"=dword:00000020
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config]
"ClockAdjustmentAuditLimit"=dword:00000320
"ClockHoldoverPeriod"=dword:0000c350
"EventLogFlags"=dword:00000002
"FrequencyCorrectRate"=dword:00000004
"HoldPeriod"=dword:00000005
"LargePhaseOffset"=dword:02faf080
"LocalClockDispersion"=dword:0000000a
"MaxAllowedPhaseOffset"=dword:00000001
"MaxNegPhaseCorrection"=dword:0000d2f0
"MaxPollInterval"=dword:0000000f
"MaxPosPhaseCorrection"=dword:0000d2f0
"MinPollInterval"=dword:0000000a
"PhaseCorrectRate"=dword:00000001
"PollAdjustFactor"=dword:00000005
"SpikeWatchPeriod"=dword:00000384
"TimeJumpAuditOffset"=dword:00007080
"UpdateInterval"=dword:00057e40
"UtilizeSslTimeData"=dword:00000001
"AnnounceFlags"=dword:00000005
"LastKnownGoodTime"=hex(b):43,d1,32,aa,e4,15,d6,01
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"NtpServer"="time.windows.com,0x9"
"ServiceDll"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,\
00,74,00,25,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
"ServiceDllUnloadOnStop"=dword:00000001
"ServiceMain"="SvchostEntry_W32Time"
"Type"="NTP"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\SecureTimeLimits]
"SecureTimeEstimated"=hex(b):48,a1,77,57,ef,15,d6,01
"SecureTimeHigh"=hex(b):48,09,3c,b9,f7,15,d6,01
"SecureTimeLow"=hex(b):48,39,b3,f5,e6,15,d6,01
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\SecureTimeLimits\RunTime]
"SecureTimeTickCount"=hex(b):64,ec,de,14,00,00,00,00
"SecureTimeConfidence"=dword:00000006
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Security]
"Security"=hex:01,00,04,80,98,00,00,00,a4,00,00,00,00,00,00,00,14,00,00,00,02,\
00,84,00,06,00,00,00,00,00,14,00,fd,01,02,00,01,01,00,00,00,00,00,05,12,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,14,00,8d,01,02,00,01,01,00,00,00,00,00,05,04,00,00,00,00,00,14,00,\
8d,01,02,00,01,01,00,00,00,00,00,05,06,00,00,00,00,00,14,00,9d,01,02,00,01,\
01,00,00,00,00,00,05,13,00,00,00,00,00,14,00,a9,00,02,00,01,01,00,00,00,00,\
00,05,13,00,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]
"AllowNonstandardModeCombinations"=dword:00000001
"CompatibilityFlags"=dword:80000000
"CrossSiteSyncFlags"=dword:00000002
"DllName"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,\
74,00,25,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
"Enabled"=dword:00000001
"EventLogFlags"=dword:00000001
"InputProvider"=dword:00000001
"LargeSampleSkew"=dword:00000003
"ResolvePeerBackoffMaxTimes"=dword:00000007
"ResolvePeerBackoffMinutes"=dword:0000000f
"SignatureAuthAllowed"=dword:00000001
"SpecialPollInterval"=dword:00093a80
"SpecialPollTimeRemaining"=hex(7):74,00,69,00,6d,00,65,00,2e,00,77,00,69,00,6e,\
00,64,00,6f,00,77,00,73,00,2e,00,63,00,6f,00,6d,00,2c,00,37,00,65,00,33,00,\
30,00,30,00,37,00,65,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer]
"AllowNonstandardModeCombinations"=dword:00000001
"ChainDisable"=dword:00000000
"ChainEntryTimeout"=dword:00000010
"ChainLoggingRate"=dword:0000001e
"ChainMaxEntries"=dword:00000080
"ChainMaxHostEntries"=dword:00000004
"DllName"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,\
74,00,25,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
"EventLogFlags"=dword:00000000
"InputProvider"=dword:00000000
"RequireSecureTimeSyncRequests"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider]
"DllName"=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,76,\
00,6d,00,69,00,63,00,74,00,69,00,6d,00,65,00,70,00,72,00,6f,00,76,00,69,00,\
64,00,65,00,72,00,2e,00,64,00,6c,00,6c,00,00,00
"Enabled"=dword:00000001
"InputProvider"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider\Parameters]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TriggerInfo]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TriggerInfo\0]
"Action"=dword:00000001
"GUID"=hex:ba,0a,e2,1c,51,98,21,44,94,30,1d,de,b7,66,e8,09
"Type"=dword:00000003
然后使用批处理自动设置服务器的NTP服务,如下:
sc config w32time start= auto
ping -n 3 127.1>nul
net start w32time && net stop w32time && net start w32time
ping -n 3 127.1>nul
netsh firewall add portopening protocol = UDP port =123 name = NTPSERVER
ping -n 3 127.1>nul
netsh advfirewall firewall add rule name="NTP Service" protocol=UDP dir=in localport=123 action=allow
ping -n 3 127.1>nul
pause