Oracle RAC节点间通信对时间的一致性要求比较高,在10g时我们通常借助于NTP或是使用crontab调用脚本去执行节点间时间同步。在11g Clusterware引入一个新的进程CTSS,该进程主要负责集群的时间管理,确保每个节点的集群时间一致,如果系统的NTP进程运行,则CTSS进程处于observer模式,否则NTP进程没有运行,CTSS运行于ACTIVE模式。该文档只要演示如何使用NTP来进行RAC节点间的时间同步。
这里我们使用RAC节点1作为NTP Server,节点2作为Client与节点1进行时间同步:
rac1的IP:192.0.2.101 NTP服务端
rac2的IP:192.0.2.102 NTP客户端
NTP配置过程如下:
1)配置NTP服务器之前确认服务器已装好NTP所需的rpm包
[root@rac1 ~]# rpm -qa|grep ntp
ntp-4.2.2p1-9.el5_3.2
chkfontpath-1.10.1-1.1
2)然后再把服务器的系统时钟与硬件时间同步一下
[root@rac1 ~]# date
Wed May 6 18:14:42 CST 2015
[root@rac1 ~]# hwclock
Wed 06 May 2015 06:14:46 PM CST -0.644785 seconds
[root@rac1 ~]# clock –systohc
3)编辑rac1节点的配置文件(添加如下内容)
[root@rac1 ~]# vi /etc/ntp.conf
server 192.0.2.101 prefer
restrict 192.0.2.0 mask 255.255.255.0 nomodify notrap noquery
broadcastdelay 0.008
4)编辑rac2节点ntp.conf文件(添加如下内容)
[root@rac2 ~]# vi /etc/ntp.conf
server 192.0.2.101 prefer
broadcastdelay 0.008
5)分别在rac1/rac2节点上修改NTPD参数文件(RAC安装时需要检测的-x参数,参考MOS Doc ID 1056693.1)
[root@rac1 ~]# cat /etc/sysconfig/ntpd
# Drop root to id ‘ntp:ntp’ by default.
OPTIONS=”-x -u ntp:ntp -p /var/run/ntpd.pid”
SYNC_HWCLOCK=yes
[root@rac2 ~]# cat /etc/sysconfig/ntpd
# Drop root to id ‘ntp:ntp’ by default.
OPTIONS=”-x -u ntp:ntp -p /var/run/ntpd.pid”
SYNC_HWCLOCK=yes
6)添加NTP服务器地址或者主机名
[root@rac1 ~]# cd /etc/ntp
[root@rac1 ntp]# ls
keys ntpservers step-tickers
[root@rac1 ntp]# cat 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.
#clock.redhat.com
#clock2.redhat.com
rac1.oracle.com
[root@rac2 ~]# cd /etc/ntp
[root@rac2 ntp]# ll
total 20
-rw——- 1 root root 73 May 19 2009 keys
-rw-r–r– 1 root root 186 Jul 8 2009 ntpservers
-rw-r–r– 1 root root 0 May 19 2009 step-tickers
[root@rac2 ntp]# cat 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.
#clock.redhat.com
#clock2.redhat.com
rac1.oracle.com
7)注意查看step-tickers内容,如果step-tickers错误也会导致ntp不同步
[root@rac1 ntp]# more step-tickers
[root@rac2 ntp]# more step-tickers
8)在rac1/rac2上执行chkconfig使NTP服务开机启动
[root@rac1 ~]# chkconfig ntpd on
[root@rac2 ~]# chkconfig ntpd on
[root@rac1 ~]# service ntpd restart
Shutting down ntpd: [ OK ]
ntpd: Synchronizing with time server: [FAILED]
Starting ntpd: [ OK ]
9)确保该端口以udp方式开放
[root@rac1 ~]# netstat -an|grep 123
udp 0 0 192.168.0.101:123 0.0.0.0:*
udp 0 0 192.0.2.101: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 fe80::20c:29ff:fe93:274:123 :::*
udp 0 0 ::1:123 :::*
udp 0 0 fe80::20c:29ff:fe93:26a:123 :::*
udp 0 0 :::123 :::*
unix 3 [ ] STREAM CONNECTED 43123 @/tmp/dbus-McFa70uJsL
10)查看ntp状态
[root@rac1 ~]# ntpstat
unsynchronised
time server re-starting
polling server every 64 s
11)在rac2节点启动ntp服务
[root@rac2 ~]# service ntpd restart
Shutting down ntpd: [ OK ]
ntpd: Synchronizing with time server: [FAILED]
Starting ntpd: [ OK ]
12)切换至事先配好互信关系的grid用户来验证两节点时间
[grid@rac1 ~]$ sh ssh.sh
Wed May 6 18:52:19 CST 2015
Wed May 6 18:52:19 CST 2015
Wed May 6 18:52:19 CST 2015
Wed May 6 18:52:19 CST 2015
经过验证,RAC两个节点时间已同步,但是也需要注意,生产环境下,应该考虑使用单独的Server作为NTP时间同步服务器。
搜索
复制