一、NTP服务器创建
- NTP服务器与交易所对时
NTP服务器与交易所对时使用交易所提供的ezNTP对时工具对时,ezNTP对时工具加入系统自启动。
- Windows 2008 NTP服务启动
- 修改以下选项的键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
Services\W32Time\TimeProviders\NtpServer内的[Enabled]设定为1。
打开NTP服务器功能(默认是不开启NTP Server服务)。
B. 修改以下键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W32Time\Config\AnnounceFlags设定为5.
该设定强制主机将它自身宣布为可靠的时间源。
C. 修改HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
W32Time\Parameters\Type内的[Type]设定为NTP。
D. 在windows服务里面将windows time服务启动类型改为自动,将状态改为启动。
二、linux服务器客户端对时
1.如果操作系统自带ntpd服务,并且已启动,需手工关闭ntpd服务自启动,且停止服务。否则在执行ntpdate命令的时候会报错。关闭系统服务命令如下:
chkconfig ntpd off #关闭ntpd开机自启动服务
service ntpd off #停止ntpd服务
2.将ntpdate对时命令加入计划任务
使用crontab –e 添加30 7 * * 1-5 ntpdate 192.168.141.25 #每周一至周五7:30定时执行对时任务
- windows服务器客户端对时
- 创建对时脚本
要实现Windows服务器定时与NTP服务器对时,需要通过计划任务来实现,故需要写一个对时脚本 (这不是图标,是批处理文件,可通过复制提取)。将对时脚本添加到计划任务里面,每天定时执行即可。
ntp type.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"NtpServer"="time.windows.com,0x8"
"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"
ntp config.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config]
"AnnounceFlags"=dword:00000005
"ClockAdjustmentAuditLimit"=dword:00000320
"ClockHoldoverPeriod"=dword:00001e78
"EventLogFlags"=dword:00000002
"FrequencyCorrectRate"=dword:00000004
"HoldPeriod"=dword:00000005
"LargePhaseOffset"=dword:02faf080
"LastKnownGoodTime"=hex(b):30,3d,bb,d6,80,e1,d5,01
"LocalClockDispersion"=dword:0000000a
"MaxAllowedPhaseOffset"=dword:0000012c
"MaxNegPhaseCorrection"=dword:ffffffff
"MaxPollInterval"=dword:0000000a
"MaxPosPhaseCorrection"=dword:ffffffff
"MinPollInterval"=dword:00000006
"PhaseCorrectRate"=dword:00000001
"PollAdjustFactor"=dword:00000005
"SpikeWatchPeriod"=dword:00000384
"TimeJumpAuditOffset"=dword:00007080
"UpdateInterval"=dword:00000064
"UtilizeSslTimeData"=dword:00000001
ntp enable.reg
Windows Registry Editor Version 5.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
"Enabled"=dword:00000001
"EventLogFlags"=dword:00000000
"InputProvider"=dword:00000000
"RequireSecureTimeSyncRequests"=dword:00000000