NTP多种模式的配置

NTP多种模式的配置

2023年6月30日发(作者:)

NTP多种模式的配置⾃⼰安装和配置了⼀个NTP服务器的⼀些⼼得,希望与⼤家分享。写了⼀个⽂档包含了各个命令和参数的具体含义,由于不能上传⽆法与⼤家分享。以后还希望⼤家多多⽀持和帮助我们共同成长,我会不断做把这些年的经营和教训与⼤家分享。在⽇常⽣活中,我们会遇到服务器或我们的PC时间不准确的问题。特别是在⼀些⽐较重要的⾏业中,系统对时间的要求⼜⽐较⾼。系统需要⼀个准确⽽可靠的时钟源来保障应⽤的运⾏。特别在证券⾏业中,时间的要求更加严格。⼀般可以根据证交所提供的时间为准,在报盘系统的⼯作站上,证交所会每天强制更新其时间,以达到该时间与交易所配置的标准时间为准。我们可以设置该⼯作站为NTP服务器,为其他系统提供与交易所相同的时间服务。同时在互联⽹上有⼤量的时间服务器可以连接,可以配置为其客户端来校准我们主机的时间。1 NTP服务介绍Network Time Protocol(NTP)是⽤来使计算机时间同步化的⼀种协议,它可以使计算机对其服务器或时钟源(如⽯英钟,GPS等等)做同步化,它可以提供⾼精准度的时间校正(LAN上与标准间差⼩于1毫秒,WAN上⼏⼗毫秒),且可介由加密确认的⽅式来防⽌恶毒的协议攻击。NTP可以利⽤多个途径和来源的时间服务器来更加精确的校正时间。现在绝⼤部分的操作系统都⽀持NTP,⽐如在Unix和Windows中都有他们⾃⼰的NTP服务。⽐如在Windows中的SNTP。由于各个系统⼚商会根据⾃⼰的系统情况对NTP来进⾏优化和设置,更加适合他⾃⼰的系统,对于其他系统的兼容性就会差很多。还有不同时期的系统会使⽤不同版本的NTP服务。最新版本位V4,由于每个版本都要他⾃⼰的⼀些特征。所以在设置NTP服务器时会有⼀些兼容性问题。因此,在多类型操作系统的环境中,尽量使⽤NTP官⽅组织提供的软件进⾏设置⽽不使⽤其他⼚商在系统中默认提供的NTP服务器。NTP官⽅组织为 2 NTP服务器的运⾏⽅式NTP服务器的使⽤⽅式包括,固定连接和动态连接⽅式。在固定连接中,客户端仅仅接收指定的服务器端的连接,⽆论服务端是否正常连接他都不会去换另外的服务器端接收时间。⼀般客户/服务器⽅式为这种模式。另外⼀直为动态连接,客户端在不停接收服务器端的⼴播信息,当⼀台服务器停⽌服务,只要有服务器⼴播出来的正确可靠的时间信息,客户端就可以正常的更新时间。⼀般为⼴播⽅式连接。

服务器/客户端⽅式客户服务器⽅式为在互联⽹上使⽤最为⼴泛的⼀种⽅法,在设定服务器后,他可以灵活的配置客户端,让客户端选择是否使⽤NTP服务器或使⽤那台NTP服务器。客户服务器⽅式使⽤常⽤的RPC(remote-procedure-call)⽅式来传输时间信息。他们运⾏的过程为,客户端发出时间请求给服务器端,然后根据服务器端的答复来调节时间。⼀般在客户端可以定义他们同步时间的间隔,和他们请求最⼤和最⼩的时间间隔。客户端会根据⾃⼰时钟时间和NTP服务器时间进⾏⽐对,如果客户端本机时钟⽐较准确,他们查询的时间间隔就会变长,如果本机时间出现误差较⼤,客户端会在⽐较短的时间内做出时间请求,来保障客户端时间的精确度。

⼴播/多播⽅式多播和⼴播⽅式利⽤在以太⽹上的⼴播和多播协议来进⾏时间同步,时间服务器会定时发出⼴播和多播信息给指定的⽹段。使⽤⼴播和多播需要⽹络设备⽀持该协议,同时客户端也⽀持该协议。可以使⽤multicasting和manycasting在不同⽹段进⾏⼴播信息,来达到在包含多个⽹段的复杂⽹络中使⽤⼴播和多播来提供NTP服务。

主动/被动⽅式主动/被动⽅式最多使⽤在集群系统中,由于集群系统对同⼀集群内的所有服务器的时间同步要求⽐较严格,他们相互配置为NTP服务器端和客户端,在不停的提供时钟同步服务,当其中的⼀台服务器出现停顿时不会影响到其他服务器的时间同步。可以说时互备的⽅式来进⾏时间同步服务。3 NTP配置⽂件⽂件名配置⽂件频率⽂件进程pid⽂件⽇志⽂件库⽂件状态信息⽂件密码⽂件默认位置/etc//etc/onesystem logNone/var/NTP/usr/local/etc选项-c-f-p-lnone-s-k使⽤命令nonedriftfilepidfilelogfileincludefilestatsdirkeysdir密码⽂件

/usr/local/etc-kkeysdir4 NTP服务器的配置服务器端配置在NTP服务器端的默认配置⽂件为/etc/⽂件(根据不同OS可能在不同位置,如在Solaris下为 /etc/inet/)。配置⽂件的参数:主要的四个参数:server address [options ...]peer address [options ...]broadcast address [options ...]manycastclient address [options ...]这四个参数主要是指定NTP服务器使⽤的服务器名称和IP地址以及他们的运⾏模式。名称或地址可以是主机名、IP地址和DNS解析后的域名。Server⼀般⽤于服务器端,该服务器不会去同步其他服务器时间,⼀般server后可以跟 127.127.1.0 该地址代表本级的时钟,如果Server后跟其他服务器IP,表⽰会去同步其他时间服务器的地址。Peer⼀般配置中表⽰,服务器接收其他服务器的地址,同时也会为其他设备提供NTP服务器。Broadcast配置为⼴播地址Manycastclient配置为多播地址具体解释如下:serverFor type s and r addresses (only), this command normally mobilizes a persistent client mode association with the specified remote server orlocal reference clock. If the preempt flag is specified, a preemptable association is mobilized instead. In client mode the client clock cansynchronize to the remote server or local reference clock, but the remote server can never be synchronized to the client clock. Thiscommand should NOT be used for type b or m r type s addresses (only), this command mobilizes a persistent symmetric-active mode association with the specified remote peer. In thismode the local clock can be synchronized to the remote peer or the remote peer can be synchronized to the local clock. This is useful in anetwork of servers where, depending on various failure scenarios, either the local or remote peer may be the better source of time. Thiscommand should NOT be used for type b, m or r astFor type b and m addresses (only), this command mobilizes a persistent broadcast mode association. Multiple commands can be used tospecify multiple local broadcast interfaces (subnets) and/or multiple multicast groups. Note that local broadcast messages go only to theinterface associated with the subnet specified, but multicast messages go to all broadcast mode the local server sends periodic broadcast messages to a client population at the address specified, which is usually thebroadcast address on (one of) the local network(s) or a multicast address assigned to NTP. The IANA has assigned the multicast groupaddress IPv4 224.0.1.1 and IPv6 ff05::101 (site local) exclusively to NTP, but other nonconflicting addresses can be used to contain themessages within administrative boundaries. Ordinarily, this specification applies only to the local server operating as a sender; foroperation as a broadcast client, see the broadcastclient or multicastclient commands stclientFor type m addresses (only), this command mobilizes a preemptable manycast client mode association for the multicast group addressspecified. In this mode a specific address must be supplied which matches the address used on the manycastserver command for thedesignated manycast servers. The NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means aretaken to avoid spraying large areas of the Internet with these messages and causing a possibly massive implosion of replies at the manycastclient command specifies that the host is to operate in client mode with the remote servers that are discovered as the result ofbroadcast/multicast messages. The client broadcasts a request message to the group address associated with the specified address andspecifically enabled servers respond to these messages. The client selects the servers providing the best time and continues as with theserver command. The remaining servers are discarded as if never heard.

附加选项参数:同时还可以添加⼀下的参数来控制NTP服务autokeyburstiburstkey keyminpoll minpollmaxpoll maxpollnoselectpreemptprefer

truettl ttlversion versiondynamic

同时NTP服务器还有配置安全,加密,在不同⽹段等的配置,具体可以参照 .客户端配置1. UNIX、Linux服务器的配置⽅法为:编辑/etc/(在Solaris中为/etc/inet/)在⽂件中加⼊ server IPADDRESS

2. 在Windows 2000中配置⽅式:在命令⾏模式输⼊:net time /SETSNTP:10.20.0.1 (指定NTP服务器IP)net stop w32time (关闭NTP服务)Net start w32time (启动NTP服务)w32tm –s (同步NTP时间)

3. 在Windows XP中配置为:控制⾯板à⽇期、时间、语⾔和区域设置à⽇期和时间在服务器筐中添加NTP服务器的IP地址就可以了。5 NTP中的命令ntpd命令ntpd命令为NTP服务的配置进程,同时ntpd命令可以配置ntp服务。执⾏时ntpd从配置⽂件/etc/中读取配置信息然后去执⾏该配置⽂件中指定的属性。ntpd命令的参数选项使⽤⽅法:ntpd [ -46aAbdDgLmnNqx ] [ -c conffile ] [ -f driftfile ] [ -i jaildir ] [ -k keyfile ] [ -l logfile ] [ -p pidfile ] [ -Ppriority ] [ -r broadcastdelay ] [ -s statsdir ] [ -t key ] [ -u user[:group] ] [ -U interface_update_interval ] [ -v variable ] [ -V variable ]

Ntpq命令Ntpq命令是⽤来查询ntp服务的命令,可以查询⽐较详细的信息,其中包含参数命令模式和交互命令模式。ntpq [-inp] [-c command] [host] [...]

Ntpdc命令Ntpdc是⼀个特殊的ntp查询命令ntpdc [ -ilnps ] [ -c command ] [ host ] [ ... ]

Ntptrace命令Ntptrace命令是追踪ntp服务传输信息的命令,可以查看服务的传输状况,查找ntp信息从那个服务器发出以及命令传输的过程。ntptrace [ -vdn ] [ -r retries ] [ -t timeout ] [ server ]

发布者:admin,转转请注明出处:http://www.yc00.com/news/1688120937a85098.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信