2013年(350)
分类: Oracle
2013-04-28 10:08:03
查看集群相关初始化参数:
SQL> select * from v$option where parameter = ¨Real Application Clusters¨;
PARAMETER VALUE
---------------------------------------- --------------------
Real Application Clusters TRUE
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean FALSE
cluster_database_instances integer 1
cluster_interconnects string由上述返回结果可知,特性是支持的,不过尚未启用集群,因此接下来首先要改的,就是enable CLUSTER DATABASE,操作如下:
SQL> alter system set cluster_database=true scope=spfile;
System altered.
SQL> alter system set cluster_database_instances=2 scope=spfile;
System altered.
SQL> alter system set instance_number=1 scope=spfile sid=¨repdb1¨;
System altered.
SQL> alter system set instance_number=2 scope=spfile sid=¨repdb2¨;
System altered.
SQL> alter system set thread=1 scope=spfile sid=¨repdb1¨;
System altered.
SQL> alter system set thread=2 scope=spfile sid=¨repdb2¨;
System altered.新建一组UNDO表空间和线程2使用的两组REDO文件:
SQL> create undo tablespace undotbs2 datafile ¨+ASMDISK2/repdb/datafile/undob01.dbf¨ size 256m;
Tablespace created.
SQL> alter system set undo_tablespace=¨undotbs1¨ scope=spfile sid=¨repdb1¨;
System altered.
SQL> alter system set undo_tablespace=¨undotbs2¨ scope=spfile sid=¨repdb2¨;
System altered.
SQL> create undo tablespace undotbs2 datafile ¨+ASMDISK2/repdb/datafile/undob01.dbf¨ size 256m;
Tablespace created.
SQL> alter database add logfile thread 2 group 3 ¨+ASMDISK2/repdb/redofile/redoc01.dbf¨ size 50m;
Database altered.
SQL> alter database add logfile thread 2 group 4 ¨+ASMDISK2/repdb/redofile/redod01.dbf¨ size 50m;
Database altered.
SQL> alter database enable thread 2;
Database altered.酌情对log_archive_dest_n,* _file_dest 等参数进行设置,由于RAC数据库的各个实例分别在不同节点上运行,一定要确保上述参数的路径对所有节点均有效,同时各个节点的目录也应满足上述参数的需要,避免由目录不存在导致的数据库错误。
关闭数据库,并退出sqlplus命令行环境,修改ORACLE_SID以适应多实例环境,先在节一个节点中进行操作:
[oracle@jssdbn2 oradata]$ export ORACLE_SID=repdb2
[oracle@jssdbn2 oradata]$ echo "SPFILE=¨+ASMDISK2/repdb/spfile/spfilerepdb.ora¨" > /data/ora10g/product/10.2.0/db_1/dbs/initrepdb2.ora
[oracle@jssdbn2 oradata]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Mar 25 14:22:54 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes
Database mounted.
Database opened.
SQL> show parameter cluster;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
SQL> set line 150 pages 1000
SQL> select instance_number,instance_name,host_name from v$instance;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME
--------------- ---------------- ----------------------------------------------------------------
2 repdb2 jssdbn2然后再到另一个节点中执行,注意更改ORACLE_SID:
[oracle@jssdbn1 ~]$ export ORACLE_SID=repdb1
[oracle@jssdbn1 ~]$ echo "SPFILE=¨+ASMDISK2/repdb/spfile/spfilerepdb.ora¨" > /data/ora10g/product/10.2.0/db_1/dbs/initrepdb1.ora
[oracle@jssdbn1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Mar 25 14:23:45 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 2083368 bytes
Variable Size 88081880 bytes
Database Buffers 188743680 bytes
Redo Buffers 6303744 bytes
Database mounted.
Database opened.
SQL> set line 150 pages 1000
SQL> show parameter cluster;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
SQL> select instance_number,instance_name,host_name from v$instance;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME
--------------- ---------------- ----------------------------------------------------------------
1 repdb1 jssdbn1查询gv$视图看看:
SQL> select instance_number,instance_name,host_name from gv$instance;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME
--------------- ---------------- ----------------------------------------------------------------
1 repdb1 jssdbn1
2 repdb2 jssdbn2OK ,现在已经是集群的数据库了,整个恢复工作基本完成。剩下的比如修改监听、配置网络服务名,创建密钥文件等操作相信大家已经熟悉的不能再熟悉,这里不再演示相关操作了(注意密钥文件也是建议创建到共享存储端,否则的话就得在各个节点分别创建一份)。
不过这时候通过crs_stat -t查看的时候,还看不到新创建的repdb数据库信息:
[oracle@jssdbn2 ~]$ /data/ora10g/product/10.2.0/crs_1/bin/crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.jssdb.db application OFFLINE OFFLINE
ora....n1.inst application OFFLINE OFFLINE
ora....n2.inst application OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE jssdbn1
ora....N1.lsnr application ONLINE ONLINE jssdbn1
ora....bn1.gsd application ONLINE ONLINE jssdbn1
ora....bn1.ons application ONLINE ONLINE jssdbn1
ora....bn1.vip application ONLINE ONLINE jssdbn1
ora....SM2.asm application ONLINE ONLINE jssdbn2
ora....N2.lsnr application ONLINE ONLINE jssdbn2
ora....bn2.gsd application ONLINE ONLINE jssdbn2
ora....bn2.ons application ONLINE ONLINE jssdbn2
ora....bn2.vip application ONLINE ONLINE jssdbn2这是正常的,因为手动恢复数据库,其配置信息并没有维护到crs中,需要手动处理,操作如下:
[oracle@jssdbn2 ~]$ srvctl add database -d repdb -o $ORACLE_HOME -n repdb -p +ASMDISK2/repdb/spfile/spfilerepdb.ora
[oracle@jssdbn2 ~]$ srvctl add instance -d repdb -i repdb1 -n jssdbn1
[oracle@jssdbn2 ~]$ srvctl add instance -d repdb -i repdb2 -n jssdbn2上述3条命令分别配置了数据库和两个实例,此时3项服务刚刚配置完成,crs中尚未同步其状态,因此需要执行一下srvctl start database,然后再通过crs_stat即可查看正确的状态了:
[oracle@jssdbn2 ~]$ srvctl start database -d repdb
[oracle@jssdbn2 ~]$ /data/ora10g/product/10.2.0/crs_1/bin/crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.jssdb.db application OFFLINE OFFLINE
ora....n1.inst application OFFLINE OFFLINE
ora....n2.inst application OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE jssdbn1
ora....N1.lsnr application ONLINE ONLINE jssdbn1
ora....bn1.gsd application ONLINE ONLINE jssdbn1
ora....bn1.ons application ONLINE ONLINE jssdbn1
ora....bn1.vip application ONLINE ONLINE jssdbn1
ora....SM2.asm application ONLINE ONLINE jssdbn2
ora....N2.lsnr application ONLINE ONLINE jssdbn2
ora....bn2.gsd application ONLINE ONLINE jssdbn2
ora....bn2.ons application ONLINE ONLINE jssdbn2
ora....bn2.vip application ONLINE ONLINE jssdbn2
ora.repdb.db application ONLINE ONLINE jssdbn1
ora....b1.inst application ONLINE ONLINE jssdbn1
ora....b2.inst application ONLINE ONLINE jssdbn2恢复操作至此基本完成。
关于RAC与其它特性的应用,请继续关注下一个系列文章:ORACLE RAC数据库与 GUARD。
全文完,下载pdf版本请至: