11G RAC  配置NTP服务器

tip01的IP:162.20.1.228  NTP服务端
tip02的IP:162.20.1.229  NTP客户端

配置NTP服务器之前,确认服务器已装好NTP包

[root@tip01 ~]# rpm -qa  | grep ntp
ntp-4.2.2p1-9.el5_4.1
chkfontpath-1.10.1-1.1

然后再把服务器的系统时钟与硬件时间同步一下

先查看下系统
[root@tip01 ~]# date
2012年05月20日 星期日 22:07:01 CST

查看硬件时钟
[root@tip01 ~]# hwclock 
2012年05月20日 星期日 13时33分46秒  -0.415712 seconds

这里,系统时钟与硬件时钟不同步,我们通过以下命令来把硬件时钟与系统时钟同步
[root@tip01 ~]# clock --systohc

在查看下系统时钟与硬件时钟,已经同步了

[root@tip01 ~]# date
2012年 05月20日 星期日 22:08:07 CST
[root@tip01 ~]# hwclock 
2012年 05月20日 星期日 22时08分12秒  -0.154372 seconds
[root@tip01 ~]# 


编辑tip01节点的配置文件

# 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  162.20.1.228    #
server  127.127.1.0     #local clock

fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

restrict 162.20.1.228  mask 255.255.255.255 nomodify notrap noquery


编辑tip02节点ntp.conf文件
# vi /etc/ntp.conf 

server tip01
restrict tip01 mask 255.255.255.255 nomodify notrap noquery


3.分别在tip01,tip02上修改NTPD参数文件

#vi /etc/sysconfig/ntpd

SYNC_HWCLOCK=yes
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

#RAC安装时需要检测的-x参


# cd /etc/ntp
# ls
keys  ntpservers  step-tickers

# more ntpservers 
#This file contains a list of ntp servers to show in the system-config-date user interface.
#It is not recommended that you modify this file by hand.

#添加ntp 服务器地址或者主机名
 tip01

注:注意查看step-tickers内容,如果step-tickers错误也会导致ntp不同步

# more step-tickers 
# 


在tip01,tip02上执行chkconfig,使NTP服务开机启动
[root@tip01 ~]# chkconfig  ntpd on
[root@tip02 ~]# chkconfig  ntpd on


[root@tip01 ~]# service ntpd restart
关闭 ntpd:[确定]
ntpd: 同步时间服务器:[失败]
启动 ntpd:[确定]



确保该端口以udp方式开放。
[root@tip01 ~]# netstat -an |grep 123
udp        0      0 192.168.99.228:123          0.0.0.0:*                               
udp        0      0 162.20.1.228:123            0.0.0.0:*                               
udp        0      0 127.0.0.1:123               0.0.0.0:*                               
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               
udp        0      0 ::1:123                     :::*                                    
udp        0      0 fe80::250:56ff:fe9d:123     :::*                                    
udp        0      0 :::123                      :::*

查看ntp状态
[root@tip01 ~]# ntpstat 

synchronised to local net at stratum 11 
   time correct to within 11 ms
   polling server every 1024 s


在tip02节点启动ntp服务

[root@tip02 ~]# service ntpd start
ntpd: 同步时间服务器:[确定]
同步硬件时钟到系统时钟 [确定]
启动 ntpd:[确定]


切换至事先配好的grid用户来验证两节点时间

[grid@tip02 ~]$ ssh tip01 date
2012年 05月 20日 星期日 22:21:46 CST
[grid@tip02 ~]$ ssh tip02 date
2012年 05月 20日 星期日 22:21:48 CST
[grid@tip02 ~]$