分类: Oracle
2011-05-27 09:47:42
http://taelons.javaeye.com/blog/594318 网上有很多关于在VMWare server 2.x上安装RED HAT ENTERPRISE LINUX 5虚拟机(以下简称RHEL5),实现oracle rac的文章,参考http://hi.baidu.com/ggb98/blog/item/749e2554803b7dc3b745aebe.html。这篇文章已经介绍得很详细,以下为几点补充。 首先,安装、配置好linux后,在安装Oracle Clusterware以前,建议将虚拟机节点目录备份,今后无论是重装,还是增加新的Oracle RAC节点,都可以此副本作为安装起点,避免安装、配置linux的繁琐步骤。当然,如果是新增节点,不要忘记修改虚拟机.vmx文件、/home/oracle/.bash_profile、/etc/hosts中的设置。 其次,oracle cluster的ocr、votingdisk、asm必须在共享存储中,所以不能在VMWare server 2.x的“Create Virtual Machine”向导中上创建虚拟磁盘,因为向导中创建的虚拟磁盘并非共享的,而是各虚拟机节点独有的,这会导致安装完oracle cluster后,在第二个节点上运行root.sh报错: Failure at final check of Oracle CRS stack 这时,运行两个节点上crs安装目录下的bin/ocrcheck.sh或bin/cluvfy.sh,显示两个节点的ocr的id属性不相等(ID值必须相等),导致cluster安装失败。 应该使用VMware/VMware Server目录下的vmware-vdiskmanager,在命令行创建虚拟磁盘,然后在两个虚拟机的vmx文件中,分别指定这些虚拟磁盘: Java代码 1.scsi1.present = "TRUE" 2.scsi1.virtualDev = "lsilogic" 3.scsi1.sharedBus = "virtual" 4. 5.scsi1:1.present = "TRUE" 6.scsi1:1.mode = "independent-persistent" 7.scsi1:1.filename = "c:\vmwareshares\votingdisk.vmdk" 8.scsi1:1.deviceType = "disk" 9. 10.scsi1:2.present = "TRUE" 11.scsi1:2.mode = "independent-persistent" 12.scsi1:2.filename = "c:\vmwareshares\ocr.vmdk" 13.scsi1:2.deviceType = "disk" 14. 15.scsi1:3.present = "TRUE" 16.scsi1:3.mode = "independent-persistent" 17.scsi1:3.filename = "c:\vmwareshares\asm.vmdk" 18.scsi1:3.deviceType = "disk" 19. 20.disk.locking = "false" 21.diskLib.dataCacheMaxSize = "0" 22.diskLib.dataCacheMaxReadAheadSize = "0" 23.diskLib.DataCacheMinReadAheadSize = "0" 24.diskLib.dataCachePageSize = "4096" 25.diskLib.maxUnsyncedWrites = "0" scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsi1.sharedBus = "virtual" scsi1:1.present = "TRUE" scsi1:1.mode = "independent-persistent" scsi1:1.filename = "c:\vmwareshares\votingdisk.vmdk" scsi1:1.deviceType = "disk" scsi1:2.present = "TRUE" scsi1:2.mode = "independent-persistent" scsi1:2.filename = "c:\vmwareshares\ocr.vmdk" scsi1:2.deviceType = "disk" scsi1:3.present = "TRUE" scsi1:3.mode = "independent-persistent" scsi1:3.filename = "c:\vmwareshares\asm.vmdk" scsi1:3.deviceType = "disk" disk.locking = "false" diskLib.dataCacheMaxSize = "0" diskLib.dataCacheMaxReadAheadSize = "0" diskLib.DataCacheMinReadAheadSize = "0" diskLib.dataCachePageSize = "4096" diskLib.maxUnsyncedWrites = "0" 以上配置内容中,scsi1.sharedBus设置为"virtual",c:\vmwareshares\votingdisk.vmdk、c:\vmwareshares\ocr.vmdk、c:\vmwareshares\asm.vmdk为vmware-vdiskmanager创建的虚拟磁盘,被两个虚拟机节点共享。 第三,注意在cluster安装向导界面中,当提示设置CRS安装目录/名称时,不要将CRS安装目录/名称和数据库的安装目录/名称混淆,CRS安装目录/名称一般设置为: /opt/ora10g/product/10.2.0/crs_1和Ora10Crs_home 数据库安装目录/名称一般设置为: /opt/ora10g/product/10.2.0/db_1和Ora10Db_Home 两者在/opt/ora10g/product/10.2.0下同一层不同子目录中,不能安装在同一子目录下或有包含关系,否则后面安装数据库时会报错。请在安装向导界面中看清楚,不能一味按"next"。本人在安装Clusterware时,安装界面默认的安装目录是/opt/ora10g/product/10.2.0/db_1,应该改为/opt/ora10g/product/10.2.0/crs_1 第四,当用dbca创建数据库时,可能会有出现以下错误提示窗口: ORA-27504: IPC error creating OSD context ORA-27300: OS system dependent operation:skgxpcini failed with status: 0 ORA-27301: OS failure message: Error 0 ORA-27302: failure occurred at: past_inmemor 若发生以上错误,先退出dbca界面,在命令行运行oifcfg getif,返回类似以下内容: eth0 192.168.1.0 global public eth1 10.10.17.0 global cluster_interconnect virbr0 192.168.122.0 global cluster_interconnect 多了一个cluster_interconnect,须将virbr0一行删除,为此,运行oifcfg delif -global virbr0,然后再次运行oifcfg getif,返回如下: eth0 192.168.1.0 global public eth1 10.10.17.0 global cluster_interconnect virbr0一行已删除,然后重新运行dbca。 第五,当oracle rac全部安装完后,必须测试负载均衡(load balance)和故障切换(failover)功能在两个节点间能否实现。 在数据库连接客户端的tnsnames.ora中设置: Java代码 1.RACDB = 2.(DESCRIPTION = 3. (load_balance = yes) 4. (FAILOVER = on) 5. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) 6. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.104)(PORT = 1521)) 7. (CONNECT_DATA = 8. (SERVER = DEDICATED) 9. (SERVICE_NAME = RACDB) 10. (failover_mode = (type = select)(method = basic)) 11. ) 12.) RACDB = (DESCRIPTION = (load_balance = yes) (FAILOVER = on) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.104)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RACDB) (failover_mode = (type = select)(method = basic)) ) ) 在两个虚拟机节点上的oracle的tnsnames.ora中设置: Java代码 1.RACDB = 2.(DESCRIPTION = 3. (load_balance = yes) 4. (FAILOVER = on ) 5. (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521)) 6. (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) 7. (CONNECT_DATA = 8. (SERVER = DEDICATED) 9. (SERVICE_NAME = RACDB) 10. (failover_mode = (type = select)(method = basic)) 11. ) 12.) RACDB = (DESCRIPTION = (load_balance = yes) (FAILOVER = on ) (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RACDB) (failover_mode = (type = select)(method = basic)) ) ) 其中node1-vip和node2-vip对应两个节点的虚拟ip 按以上设置后,负载均衡和故障切换将能正常实现。可试着开多个sqlplus,分别运行: select instance_number, instance_name, host_name from v$instance; 从返回记录可以看出,sqlplus分摊到两个节点上,实现负载均衡。若所有sqlplus连接到同一个节点,试着在另一个节点上重启监听器: lsnrctl stop lsnrctl start 然后再看负载均衡是否正常。 在虚拟机节点上用以下命令停止/启动一个节点上的实例,看故障切换是否正常: srvctl stop instance -d racdb -i racdb1 srvctl start instance -d racdb -i racdb1 当某个节点上的实例停止后,上面的sql应返回另一个节点的instance_number/instance_name/host_name 第六,如果需要增加新的RAC节点,可按本文开头安装、配置好linux后的副本作为起点,先修改新节点的/etc/hosts文件,加入新节点的ip、priv ip、vip,接着在RAC主节点的$Ora10Crs_home/oui/bin/目录下,以oracle用户执行addNode.sh,按向导提示操作,添加新的crs节点。然后主节点的$Ora10gDb_/oui/bin目录下,以oracle用户执行addNode.sh,按向导提示操作,添加新的db节点。最后在主节点上运行dbca,将新节点上的实例添加到集群。 参考。 最后一点,首次安装RAC,安装失败几乎不可避免,由于步骤繁多,需要格外仔细。如果安装报错,请参考本文开头的URL中的文章。如果不得已需要重装,请按照oracle metalinke 239998.1中的步骤,删除各节点上的crs。如果没有删干净,重装很可能无法进行下去。 |