ITPub博客

首页 > 数据库 > Oracle > 配置NTP时间同步

配置NTP时间同步

原创 Oracle 作者:龙山游龙 时间:2015-08-05 16:51:56 0 删除 编辑

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

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博客 ” ,链接:https://blog.itpub.net/30310891/viewspace-1762855/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
传统商业、开源和国产据库领域十从业经验,TB级高并发数据库的管理经验。对于数据库内部原理、体系结构,数据页/块结构原理有着深刻认识;对于数据库新特性、分布式高可用架构和性能调优有着丰富的的实战经验。擅长故障诊断以及数据库异常打开及数据灾难挽救。

注册时间:2015-06-28

  • 博文量
    178
  • 访问量
    334647