登录站点

用户名

密码

构建自己的局域网时间同步服务器

热10已有 1385 次阅读  2011-09-30 09:04   标签:  服务器  时间同步  局域网 

随着公司业务的拓展,信息系统的不断完善,一个困扰IT人员的问题出现了,局域网有那么多网络设备象路由器、防火墙、交换机等,大量的数据库服务器、应用服务器、Web服务器、FTP服务器等等,每台设备都以自我为中心维持着自身的时间体系,而大量的业务需要一个准确的时间,如何及时准确地同步、更新这些设备的时间体系?一个传统的办法就是在局域网内架设一个时间同步服务器,通过卫星、GPS定位系统来保证与国家授时中心进行时间同步,投资价格通常在3000-50000元不等。

本文试图尝试以互联网为基础,以国内的NTP时间服务器为种子,构建自己的局域网时间同步服务器。

 

一、             网络及服务器环境

本公司网络以2台Cisco 4506组成HSRP双机冗余主交换机核心,分别连接2台Cisco 3825与电信MPLS-VPN专线连接构成数据专网,连接1台Cisco ASA5510与电信宽带连接提供上网环境,分别连接4台Cisco 2960构成办公网络环境。

网络中使用2台IBM P5-520Q组成数据库服务器,使用2台IBM x3550构成测试服务器及备份服务器。

本文试图在Cisco 4506上创建时间服务器,所有网络设备自动与时间服务器同步,所有服务器及PC端手动与时间服务器同步。

以下是在Cisco IOS系统中配置时间服务器及同步等所涉及的命令。

clock calendar-vaild

允许使用硬件时钟作为时间源

clock timezone Beijing 8

定义时区为Beijing +8

ntp clock-period 17179830

使用NTP进行系统时钟同步

ntp update-calendar

使NTP周期性地更新硬件时钟

ntp server x.x.x.x

系统时钟自动与指定的时间服务器进行同步

ntp master 3

允许本机作为NTP协议的主时钟,精度级别3

show clock

显示本机时间

show calendar

显示本机硬件时钟

show ntp status

显示本机NTP的状态

show ntp association

显示本机中NTP有关的信息,如轮询周期等

 

二、             创建时间服务器

4506A#configure terminal

1、  设置时区及硬件时钟

4506A(config)#clock timezone Beijing 8

4506A(config)#clock calendar-vaild

2、  设置时间更新方式

4506A(config)#ntp clock-period 17179830

4506A(config)#ntp update-calendar

3、  与互联网时间服务器同步

4506A(config)#ntp server 61.129.66.79

4506A(config)#ntp server 218.21.130.42

4、  创建时间服务器

4506A(config)#ntp master 5

5、  显示NTP状态

4506A(config)#end

4506A#show ntp status

Clock is synchronized, stratum 3, reference is 61.129.66.79

nominal freq is 250.0000 Hz, actual freq is 250.0069 Hz, precision is 2**18

reference time is CA1CBD85.AB5596F6 (15:25:57.669 Beijing Fri Jun 14 2007)

clock offset is 8.8476 msec, root delay is 322.77 msec

root dispersion is 150.76 msec, peer dispersion is 59.33 msec

4506A#show ntp association

      address         ref clock     st  when   poll reach   delay   offset    disp

 ~127.127.7.1      127.127.7.1       4     3    64  377     0.0    0.00     0.0

+~218.21.130.42    76.169.239.34     2   873  1024  377   117.7  -28.48     6.0

*~61.129.66.79     209.81.9.7        2   294  1024  377    11.5   46.17     3.3

 * master (synced), # master (unsynced), + selected, - candidate, ~ configured

 

三、             网络设备的自动时间同步

(一)  Cisco 4506、Cisco 3825等有硬件时钟网络设备的自动时间同步

以Cisco 4506为例:

4506B#configure terminal

1、  设置时区及硬件时钟

4506B(config)#clock timezone Beijing 8

4506B(config)#clock calendar-vaild

2、  设置时间更新方式

4506B(config)#ntp clock-period 17179830

4506B(config)#ntp update-calendar

3、  与内网时间服务器同步

4506B(config)#ntp server 172.16.1.1

4、  显示NTP状态

4506B(config)#end

4506B#show ntp status

Clock is synchronized, stratum 4, reference is 172.16.1.1

nominal freq is 250.0000 Hz, actual freq is 250.0031 Hz, precision is 2**18

reference time is CA1CB5F6.F13E2C31 (14:53:42.942 Beijing Fri Jun 14 2007)

clock offset is 9.9590 msec, root delay is 206.21 msec

root dispersion is 193.13 msec, peer dispersion is 5.45 msec

4506B#show ntp associations

      address         ref clock     st  when  poll  reach   delay   offset    disp

*~172.16.1.1       61.129.66.79      3   407   512  377     4.1    9.96     5.4

 * master (synced), # master (unsynced), + selected, - candidate, ~ configured

(二)  Cisco 2960等没有硬件时钟网络设备的自动时间同步

以Cisco 2960为例:

2960A#configure terminal

1、  设置时区

2960A (config)#clock timezone Beijing 8

2、  设置时间更新方式

2960A (config)#ntp clock-period 17179830

3、  与内网时间服务器同步

2960A (config)#ntp server 172.16.1.1

4、  显示NTP状态

2960A (config)#end

2960A #show ntp status

Clock is synchronized, stratum 4, reference is 172.16.1.1

nominal freq is 119.2092 Hz, actual freq is 119.2086 Hz, precision is 2**17

reference time is CA1CB52A.F0013C31 (14:50:18.937 Beijing Fri Jun 14 2007)

clock offset is -0.8028 msec, root delay is 202.42 msec

root dispersion is 163.86 msec, peer dispersion is 0.14 msec

2960A#show ntp associations

      address         ref clock     st  when  poll  reach   delay  offset    disp

*~172.16.1.1       61.129.66.79      3    10    64  377     1.1   -0.78     0.1

 * master (synced), # master (unsynced), + selected, - candidate, ~ configured

(三)  Cisco ASA5510的自动时间同步

2960A#configure terminal

1、  设置时区

5510 (config)#clock timezone Beijing 8

2、  与内网时间服务器同步

5510 (config)#ntp server 172.16.1.1

3、  显示NTP状态

5510 (config)#end

5510 #show ntp status

Clock is synchronized, stratum 4, reference is 172.16.1.1

nominal freq is 99.9984 Hz, actual freq is 100.0111 Hz, precision is 2**6

reference time is ca1cafd1.c158990d (14:27:29.755 Beijing Fri Jun 14 2007)

clock offset is 18.5363 msec, root delay is 236.28 msec

root dispersion is 229.02 msec, peer dispersion is 21.19 msec

5510# show ntp associations

      address         ref clock     st  when  poll  reach   delay   offset    disp

*~172.16.1.1       61.129.66.79      3     2  1024  377     0.9   19.17    19.0

 * master (synced), # master (unsynced), + selected, - candidate, ~ configured

 

四、             服务器端时间同步

1、  使用SCO UnixWare、Linux类操作系统的手动时间同步

# date;ntpdate 172.16.12.254

Thu Jun 14 16:30:53 CST 2007

14 Jun 16:30:54 ntpdate[31799]: adjust time server 172.16.12.254 offset 0.033395 sec

2、  使用Windows 2000 Server类操作系统的自动时间同步

1)指定主时间服务器。在DOS方式输入“net time /setsntp:172.16.1.1”。

2)开始与主时间服务器同步。先关闭windows time服务,再开启该服务。可以在“管理工具”的“服务”界面下完成,也可以以DOS方式输入“net stop w32time”、“net start w32time”。

3)设置电脑的Windows time服务的启动方式为自动。在“管理工具”的“服务”界面下完成。

 

五、             PC端自动时间同步

1、 使用Windows 2000 类操作系统的自动时间同步

同“Windows 2000 Server”。

2、 使用Windows XP类操作系统的自动时间同步

双击任务栏右下角的时钟图标,打开“日期时间属性”对话框,在“Internet时间”卡片上选中“自动与Internet时间服务器同步”,并在服务器上填入内部时间服务器的IP地址即可。

3、  如何检查时间是否同步

登录国家授时中心网站http://www.time.ac.cn/times/timefairy.htm并下载校时控件timefaify.exe,保存后双击安装,再次登录该网站,就可看到如下的图形:

 

分享 举报

发表评论 评论 (8 个评论)

涂鸦板