全部博文(19)
分类: LINUX
2008-09-22 16:22:05
目的:
完成10gR1
完成升级到
环境:
VMWare workstation
CentOS
Oracle 10gR1
步骤:
VMWare 和 CentOS的安装
建立共享磁盘并分区
安装CRS
安装数据库软件
建立数据库
测试TAF
参考文档:
文档1:
文档2:
注意事项:
VMWare 和 CentOS的安装
添加网卡时要注意选择“bridged”,如果在两张网卡分配好IP后,发现本机ping不通虚拟机了,请按如下步骤解决:
如果防火墙没关,关之
在VMWare的工具栏->VM->Removable Device->Ethernet 和 Ethernet 2(bridged)
操作如下:
1、将两者全disconnect
2、如果先connect Ethernet(eth0) 网络便通了
3、如果先connect Ethernet2(eth1)那网络便不通
对文档2中提到的
Other required package versions (or higher):
make-3.80-5
gcc-
compat-db-4.1.25-9
注意这3个软件包如果没有,一定得安装,不然会在CRS的安装中出错。
要修改/etc/redhat-release文件,因为Oracle depend on这个文件里的描述版本
cp /etc/redhat-release /etc/redhat-release.orig
cat > /etc/redhat-release << EOF
Red Hat Enterprise Linux AS release 3 (Taroon)
EOF
注意裸设备的分区,可能大家对裸设备有种神秘感,因为它不像文件系统那样直观,但用多了就会觉得好用了。
关键点是,要以裸设备来安装的话,必须先得把磁盘空间分配好,比如说哪个数据文件分多大。而需要划分几个空间呢,也就是说有几个数据文件是得先划分好了才能装的呢?如果是第一次装RAC的话,那文档2提供了答案。
在共享磁盘建好并分好区之后,一定要在所有虚拟机的VMX文件里,指定:
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"两个参数,如果没指定disk.locking = "FALSE",那第二个虚拟机会起不来。如果没指定diskLib.dataCacheMaxSize = "0"参数,则会在数据库建好之后,在数据库MOUNT或OPEN的时候,带来诸多错误。
以下是我机器上VMX的内容节选:
disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" scsi0.present = "TRUE" scsi0.virtualDev = "lsilogic" scsi0:0.present = "TRUE" scsi0:0.fileName = "Red Hat Enterprise Linux 4.vmdk" scsi0:0.redo = "" scsi1:0.present = "TRUE" scsi1:0.fileName = "E:\VRAW\vraw.vmdk" scsi1:0.mode = "independent-persistent" scsi1:0.redo = "" scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsi2.present = "TRUE" scsi2:0.present = "TRUE" scsi2:0.fileName = "E:\VRAW\vraw2.vmdk" scsi2:0.mode = "independent-persistent" scsi2.virtualDev = "lsilogic" scsi2:0.redo = "" |
裸设备划分好并建立完link之后
指定环境变量DBCA_RAW_CONFIG用来告诉安装程序,这些个数据文件放在哪个地方。
[oracle@rac02 admin]$ echo $DBCA_RAW_CONFIG
/opt/oracle/fracraw.conf
我机器上fracraw.conf内容如下:
system=/opt/oracle/oradata/frac/system_ sysaux=/opt/oracle/oradata/frac/sysaux_ undotbs1=/opt/oracle/oradata/frac/undotbs1_ undotbs2=/opt/oracle/oradata/frac/undotbs2_ example=/opt/oracle/oradata/frac/exampletbs_ users=/opt/oracle/oradata/frac/usertbs_ temp=/opt/oracle/oradata/frac/temptbs_ spfile=/opt/oracle/oradata/frac/spile_ pwdfile=/opt/oracle/oradata/frac/passwdfile_ control1=/opt/oracle/oradata/frac/ctlfile1_ control2=/opt/oracle/oradata/frac/ctlfile2_ redo1_1=/opt/oracle/oradata/frac/redolog1_1_ redo1_2=/opt/oracle/oradata/frac/redolog1_2_ redo2_1=/opt/oracle/oradata/frac/redolog2_1_ redo2_2=/opt/oracle/oradata/frac/redolog2_2_ |
安装CRS时
要注意两个节点的时间要同步(不能相差太多),可以用ntpdate或vmware tools来解决这个问题
安装时可能会报equivalence not be established等错,就是两个节点间没有建立平等关系。
除了文档2中提到的操作
这些连通测试还不够,对本机也要ssh!
[oracle@ds1 Disk1]$ ssh ds1 (ds1-priv) date
在出现的输入中 yes
[oracle@ds2 oracle]$ ssh ds2 (ds2-priv) date
在出现的输入中yes
再次输入以上命令,没提示了。已经knowned了
还有可能出现的问题是,在/etc/hosts中
127.0.0.1 localhost ds1 这一行,后面接了本机名(ds1)
应该把ds1拿掉
装完后可能会出现vipca运行出错
这是Oracle的一个BUG,你可以手动的再次执行$CRS_HOME/bin/vipca,也可以用命令:
srvctl add nodeapps -n crmnode1 -o /ora/ora10(ORACLE_HOME全路径) -
数据库软件安装完成后
先打
注意事项是严格按照PATCH的Readme文档来执行,这里也要注意equivalence的问题。
在升级数据库软件之前,得先升级CRS软件。有人会问CRS升级软件在哪,怎么装?
答案是CRS软件就在数据库软件升级包内,如果你将$ORACLE_HOME设为$CRS_HOME(CRS的主目录),运行升级包时则会装CRS。如果将$ORACLE_HOME设为$DB_HOME,则装的是数据库软件。
建库
在两个节点正常OPEN之后(如果没有正常OPEN,可以根据我上述的注意点去排查问题),我们就可以开始测试TAF了
TAF指的是Transparent Application Failover,即程序透明失败切换
Transparent Application Failover (TAF) is a feature of the Oracle Call Interface (OCI) driver at client side. It enables the application to automatically reconnect to a database, if the database instance to which the connection is made fails. In this case, the active transactions roll back. |
先配置listener.ora,再配置tnsname.ora
我机器上的listener.ora内容如下:
SID_LIST_LISTENER_RAC01 = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /opt/oracle/product/101/db) (PROGRAM = extproc) ) ) LISTENER_RAC01 = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521)(IP = FIRST)) ) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.106.22)(PORT = 1521)(IP = FIRST)) ) ) ) |
tnsname.ora
FRAC = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = frac) ) ) LISTENERS_FRAC = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521)) ) FRAC1_LOCAL = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521)) FRAC2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = frac) (INSTANCE_NAME = frac2) ) ) FRAC1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = frac) (INSTANCE_NAME = frac1) ) ) TAFFRAC = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.106.102)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.106.104)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = frac) (FAILOVER_MODE = (TYPE = SESSION)(METHOD = BASIC)) ) ) |
在RAC01上
[oracle@rac01 admin]$ sqlplus "system/oracle@taffrac" SQL*Plus: Release Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database With the Partitioning, Real Application Clusters, OLAP and Data Mining options SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- frac2 |
在RAC02上停掉instance 2
[oracle@rac02 admin]$ srvctl stop instance -d frac -i frac2
再回到RAC01刚才的界面
SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- frac1 SQL>发现instance_name“透明的”变成frac1了。完成TAF测试 |
以上测试是在RAC自身的结点上测试的TAF,而没在client端连进来测试,还不能说明问题。
找个client端(
TAFFRAC = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.106.102)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.106.104)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = frac) (FAILOVER_MODE = (TYPE = SESSION)(METHOD = BASIC)) ) ) |
接下来的步骤同上面的结点上的测试步骤一样。
在用sqlplus 去连接的时候,可能会出现如下错误:
[oracle@smsap ~]$ sqlplus "sys/oracle@taffrac as sysdba" SQL*Plus: Release Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12545: Connect failed because target host or object does not exist 原因:在服务端配置的tnsnames.ora 和listener.ora中,是以主机名来作为host的。 解决方法是:在客户端的/etc/hosts文件里(windows的文件为../system32/drivers/etc/hosts),加入对RAC节点主机的IP解析信息。 192.168.106.22 rac01 192.168.106.44 rac02 192.168.106.102 rac01-vip 192.168.106.104 rac02-vip (如果想不加如上信息,那么就得将服务端和客户端的所有tnsnames.ora和listener.ora的host值设为IP地址。) 并且确保各个RAC节点上设置如下参数: SQL> show parameter list; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string FRAC1_LOCAL remote_listener string LISTENERS_FRAC |
[oracle@smsap ~]$ sqlplus "sys/oracle@taffrac as sysdba" SQL*Plus: Release Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12705: invalid or unknown NLS parameter value specified 解决方法是:export NLS_LANG=American_America.WE8ISO8859P1 |