配置NTP时间同步

测试环境:有1windows 2008 IP:192.168.186.200作为时钟源,1rhel6.4 IP:192.168.186.87作为客户端进行ntp时间同步。在Windows Server 2008 R2 中用Windows Time(W32Time)service 建一个SNTP/NTP服务器为Windows或非windows客户端提供时间服务。windows时区为UTC+8linuxCST

1、在开始菜单栏中,点击“运行”输入regedit,打开Windows 注册表


2、设定成为NTP 服务器类型。

修改登陆档案中:

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters"

[Type]设定值修改为”NTP”。



3、设定授权时间服务器

修改登录档中:

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config"

[AnnounceFlags]修改设定值为5


4、启用NTP服务器

修改登录档中:

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer"

[Enabled]数值修改为1



5、重起Windows Time服务

打开开始菜单输入“CMD”在命令行模式下输入:

net stop w32time && net start w32time 重启一下win32time服务。


需要注意的问题:

1、在系统服务中设置W32Time服务启动模式为自动。


2、确定防火墙允许UDP123端口访问。

打开 UDP:123端口

打开开始菜单输入“CMD”在命令行模式下输入:

netsh firewall add portopening protocol = UDP port =123 name = NTPSERVER



客户端rhel6.4

[root@rhel6 ~]# rpm -qa|grep ntpd

ntpdate-4.2.4p8-3.el6.x86_64

确定ntp包已经安装。

 

ntp.conf配置如下:

[root@rhel6 ~]# vi /etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

server 192.168.186.200

driftfile /var/lib/ntp/drift

keys /etc/ntp/keys

 

[root@rhel6 ~]# date

Wed Aug  5 22:56:44 CST 2015

[root@rhel6 ~]# service ntpd stop

Shutting down ntpd:                                        [  OK  ]

[root@rhel6 ~]# ntpdate 192.168.186.200

 5 Aug 16:15:19 ntpdate[30041]: adjust time server 192.168.186.200 offset 0.017610 sec

[root@rhel6 ~]# service ntpd start

Starting ntpd:                                             [  OK  ]

[root@rhel6 ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

 192.168.186.200 .LOCL.           1 u   15   64    1    0.856    2.923   0.000

[root@rhel6 ~]# date

Wed Aug  5 16:15:50 CST 2015

现在已经同步

 

客户端采用ntpdate来更新,配置在crontab中。根据需要决定频率。在每一台需要同步时间的设备上设置crontab。如下配置为每天零点进行时间同步

[root@rhel6 ~]# crontab -l

00 00 * * * /usr/sbin/ntpdate 192.168.186.200


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30310891/viewspace-1762855/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30310891/viewspace-1762855/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值