windows 2003 配置NTP

来源:互联网 发布:中岛美嘉 知乎 编辑:程序博客网 时间:2024/06/06 02:22

http://gyawjk.blog.163.com/blog/static/338711072011113031018492/


3 Windows Server 2003

3.1 命令介绍

Windows Server 2003下有关时间的命令有两个,net timeW32tm,下面对这两个命令的语法和参数加以说明。

3.1.1 NET TIME

net time命令使计算机的时钟与另一个计算机或域的时钟同步。如果在没有 /set 选项的情况下使用,则显示另一个计算机或域的时间。net time的语法为:

net time [\computername | /domain[:domainname] | /rtsdomain[:domainname]] [/set]

net time [\computername] [/querysntp] | [/setsntp[:ntp server list]]

参数说明:

无参数,显示被指派为本地计算机的Windows服务器域时间服务器的当前时间。

l \computername,指定要检查或与之同步的服务器的名称。

l /domain[:domainname],指定要同步时间的域。

l /rtsdomain[:domainname],指定要与之同步的可信时间服务器所在的域。

l /set,使计算机的时钟与指定的计算机或域的时间同步。

l /querysntp,显示当前为本地计算机或 \computername 所指定的计算机配置网络时间协议(NTP)服务器的名称。

l /setsntp[:ntp server list],指定本地计算机所使用的NTP时间服务器的列表。该列表可以包含IP地址或DNS名称,用空格分开。如果要使用多个时间服务器,该列表必须用引号引起来。参见注册表项中NtpServer项说明。

3.1.2 W32time

W32tm是用来同步本地计算机与远程计算机或域时间的类似命令。在域控制器上使用W32tm前必须停止W32Time,完成后再启动W32TimeW32tm的语法为:

w32tm [/? | /register | /unregister ]

w32tm /monitor [/domain:<domain name>]

[/computers:<name>[,<name>[,<name>...]]]

[/threads:<num>]

w32tm /ntte <NT time epoch>

w32tm /ntpte <NTP time epoch>

w32tm /resync [/computer:<computer>] [/nowait] [/rediscover] [/soft]

w32tm /stripchart /computer:<target> [/period:<refresh>]

[/dataonly] [/samples:<count>]

w32tm /config [/computer:<target>] [/update]

[/manualpeerlist:<peers>] [/syncfromflags:<source>]

[/LocalClockDispersion:<seconds>]

w32tm /tz

w32tm /dumpreg [/subkey:<key>] [/computer:<target>]

关于W32tm语法的详细说明,可以在命令提示符下键入W32tm /?,将列出语法和所有参数的说明。

3.2 注册表项

以下注册表项位于 HKLM\SYSTEM\CurrentControlSet\Services\W32Time

注册表项

 MaxPosPhaseCorrection

路径

 HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config

注意

  项指定服务可进行的最大正时间校准量(以秒为单位)。如果服务确定某个更改幅度大于所需的幅度,它将记录一个事件。特殊情况:0xFFFFFFFF 表示总是校准时间。域成员的默认值是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,00015 小时)。

注册表项

 MaxNegPhaseCorrection

路径

 HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config

注意

 该项指定服务可进行的最大负时间校准量(以秒为单位)。如果服务确定某个更改幅度大于所需的幅度,它将转而记录一个事件。特殊情况:-1 表示总是校准时间。域成员的默认值是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,00015 小时)。

注册表项

 MaxPollInterval

路径

 HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config

注意

 该项指定系统轮询间隔所允许的最大间隔(单位是对数表示的秒)。请注意,尽管系统必须根据预定的间隔进行轮询,但是提供程序可以根据请求拒绝生成示例。域成员的默认值是 10。独立客户端和服务器的默认值是 15

注册表项

 SpecialPollInterval

路径

 HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient

注意

 该项指定手动对等端的特殊轮询间隔(以秒为单位)。当启用 SpecialInterval 0x1 标志时,W32Time 将使用此轮询间隔而非操作系统确定的轮询间隔。域成员的默认值是3,600。独立客户端和服务器的默认值是 604,800

注册表项

 MaxAllowedPhaseOffset

路径

 HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config

注意

 该项指定 W32Time 尝试使用时钟速率调整计算机时钟的最大偏移(以秒为单位)。当偏移大于该速率时,W32Time 将直接设置计算机时钟。域成员的默认值是 300。独立客户端和服务器的默认值是 1

3.2.1 Parameters\NtpServer

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer

Data type

 Range

 Default value

REG_SZ

 DNS name or IP address[,0x1 | 0x2 | 0x3]

 time.windows.com,0x1

Description

Stores a list of time sources that this computer uses to synchronize its time. The time sources appear either as a DNS name or an IP address of the time source server. The list is space-delimited, with one address per line.

Each time source may also be followed by a comma and a DWORD containing flags for special handling of that time source. If the flags are not specified, they default to 0x0. The available flags are:

Value

 Meaning

0x1

 Instead of following the NTP specification, wait for the interval specified in the SpecialPollInterval entry before attempting to recontact this time source. Setting this flag decreases network usage, but it also decreases accuracy.

0x2

 Use this time source only as a fallback. If all time sources that are not fallbacks have failed, then the system selects one fallback time source at random and uses it.

0x4

 Set the local computer to operate in symmetric active mode in the association with this source.

0x8

 Set the local computer to operate in client mode in the association with this source.

例如net time /setsntp:"time.nist.gov,0x1 time-a.nist.gov,0x1”,其中的0x1是在使用完整域名称作为NTP服务器的时候需要的,如果使用IP地址则可以忽略。

Change Method

You can change the value of this entry by using the /setsntp parameter of the net time command at the command line. For more information about net time, see Help and Support Center for Windows Server 2003.

3.2.2 Parameters\Type

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters

Data type

 Range

 Default value

REG_SZ

 NoSync | NTP | Nt5DS | AllSync

 Nt5DS for computers joined to a domain; NTP for others

Description

Specifies the type of time sources, if any, to which the computer synchronizes its time.

Value

 Meaning

NoSync

 Does not synchronize time.

NTP

 Synchronizes time to the time sources specified in the Parameters\NtpServer entry.

Nt5DS

 Synchronizes time to the domain hierarchy.

AllSync

 Uses all synchronization mechanisms available.

Change Method

To change the value of this entry, use the command-line tool w32tm.exe (specifically, the command w32tm /config /syncfromflags). For more information about w32tm.exe, see Windows Server 2003 Help and Support Center.

Activation Method

To make changes to this entry effective, at the command line, type:

w32tm /config /update

3.3 设置示例

3.3.1 使用“时间和日期 属性”设置对话框

双击任务栏右下角“时间”,打开“时间和日期 属性”设置对话框;

选择“Internet时间”标签;

选中“自动与Internet时间服务器同步”选项,在“服务器”中填入网络时间服务器的IP地址,如“192.168.1.232”(只能输入1个服务器地址)。按“立即更新”可直接同步。

3.3.2 命令方式

在“运行(R)”中用“cmd”命令进入在DOS命令行窗体;执行以下命令(注意空格):

net time /setsntp: ”192.168.1.232 time.windows.com,0x1”

net stop w32time

net start w32time

w32tm /resync /nowait /rediscover

 (设置时间服务器地址,可多个)

(停止时间服务)

(启动时间服务)

(立即同步时间)

3.4 可能出现的问题

计算机没有同步。因为没有可用的时间数据。(The computer did not resync because no time data was available

出现该问题的原因可能是windows time service没有正确的启动,或者与组策略中的时间配置冲突。请在组策略(gpedit.msc)中将配置更改为“未配置”。


0 0
原创粉丝点击