导读
本文介绍如何将Oracle单实例数据库转换成Oracle RAC数据库
环境说明:
数据库节点2上有个单实例数据库zlxdb2,现在要将zlxdb2转换成RAC数据库,RAC数据库的两个实例分别是lzydb1和lzydb2。
以下是详细的操作步骤:
SYS@zlxdb2>show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SYS@zlxdb2>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '+DATA' SIZE 100m AUTOEXTEND ON;
SYS@zlxdb2>select tablespace_name from dba_tablespaces where contents='UNDO';
TABLESPACE_NAME
------------------------------
UNDOTBS1
UNDOTBS2
将UNDOTBS1表空间设置为数据库实例lzydb1的默认undo表空间,
将UNDOTBS2表空间设置为数据库实例lzydb2的默认undo表空间。
alter system set undo_tablespace=UNDOTBS2 SCOPE=SPFILE SID='lzydb2';
alter system set undo_tablespace=UNDOTBS1 SCOPE=SPFILE SID='lzydb1';
SYS@zlxdb2>select group#,member from v$logfile order by 1;
GROUP# MEMBER
---------- --------------------------------------------------
1 +DATA/lzydb/onlinelog/group_1.290.1120398077
2 +DATA/lzydb/onlinelog/group_2.291.1120398077
3 +DATA/lzydb/onlinelog/group_3.292.1120398077
SYS@zlxdb2>select group#,thread#,bytes/1024/1024 from v$log;
GROUP# THREAD# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
2 1 50
3 1 50
查看redo日志的thread号,单实例只有一个thread1
SYS@zlxdb2>select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
alter database add logfile thread 2 group 4 ('+DATA') size 50m,group 5 ('+DATA') size 50m,group 6 ('+DATA') size 50m;
SYS@zlxdb2>select group#,member from v$logfile order by 1;
GROUP# MEMBER
---------- --------------------------------------------------
1 +DATA/zlxdb/onlinelog/group_1.275.1120355965
2 +DATA/zlxdb/onlinelog/group_2.276.1120355967
3 +DATA/zlxdb/onlinelog/group_3.277.1120355967
4 +DATA/zlxdb/onlinelog/group_4.280.1120358085
5 +DATA/zlxdb/onlinelog/group_5.281.1120358085
6 +DATA/zlxdb/onlinelog/group_6.282.1120358087
SYS@zlxdb2>select group#,thread#,bytes/1024/1024 from v$log;
GROUP# THREAD# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
2 1 50
3 1 50
4 2 50
5 2 50
6 2 50
6 rows selected.
启用thread2线程的日志组
SYS@zlxdb2>alter database enable public thread 2;
SYS@zlxdb2>select THREAD#, STATUS, ENABLED from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED DISABLED
SYS@zlxdb2>alter system set cluster_database=true scope=spfile sid='*';
SYS@zlxdb2>alter system set cluster_database_instances=2 scope=spfile;
SYS@zlxdb2>alter system set remote_listener='scan-ip:1521';
SYS@zlxdb2>alter system set instance_number=1 scope=spfile sid='lzydb1';
SYS@zlxdb2>alter system set instance_number=2 scope=spfile sid='lzydb2';
SYS@zlxdb2>alter system set instance_name='lzydb1' scope=spfile sid='lzydb1';
SYS@zlxdb2>alter system set instance_name='lzydb2' scope=spfile sid='lzydb2';
SYS@zlxdb2>alter system set thread=1 sid='lzydb1';
SYS@zlxdb2>alter system set thread=2 sid='lzydb2';
SYS@zlxdb2>create pfile='/home/oracle/initzlxdb2.ora' from spfile;
参数文件信息如下:
*.audit_file_dest='/u01/app/oracle/admin/lzydb/adump'
*.audit_trail='db'
*.cluster_database=TRUE
*.cluster_database_instances=2
*.compatible='11.2.0.4.0'
*.control_files='+DATA/lzydb/controlfile/current.289.1120398075'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='lzydb'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lzydbXDB)'
lzydb1.instance_name='lzydb1'
lzydb2.instance_name='lzydb2'
lzydb1.instance_number=1
lzydb2.instance_number=2
*.open_cursors=300
*.pga_aggregate_target=314572800
*.processes=150
*.remote_listener='scan-ip:1521'
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=943718400
lzydb1.thread=1
lzydb2.thread=2
lzydb1.undo_tablespace='UNDOTBS1'
lzydb2.undo_tablespace='UNDOTBS2'
SYS@zlxdb2>show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/lzydb/spfilelzydb.ora
SYS@zlxdb2>shutdown immediate
SPFILE='+DATA/lzydb/spfilelzydb.ora'
SYS@zlxdb2>@?/rdbms/admin/catclust.sql
PL/SQL procedure successfully completed.
[oracle@node2 ~]$ cd $ORACLE_HOME/dbs
scp initlzydb2.ora node1:$ORACLE_HOME/dbs
[oracle@node1 ~]$ cd $ORACLE_HOME/dbs
mv initlzydb2.ora initlzydb1.ora
[oracle@node1 ~]$ mkdir -p /u01/app/oracle/admin/lzydb/adump
export ORACLE_SID=lzydb1
sqlplus / as sysdba
startup
[oracle@node2 ~]$ mkdir -p /u01/app/oracle/admin/lzydb/adump
export ORACLE_SID=lzydb2
sqlplus / as sysdba
startup
[oracle@node1 ~]$ crsctl stat res -t
[oracle@node1 ~]$ srvctl remove database -d lzydb -f
[oracle@node1 ~]$ srvctl add database -d lzydb -o $ORACLE_HOME -p +DATA/lzydb/spfilelzydb.ora
[oracle@node1 ~]$ srvctl add instance -d lzydb -n node1 -i lzydb1
[oracle@node1 ~]$ srvctl add instance -d lzydb -n node2 -i lzydb2
shut immediate
srvctl start database -d lzydb
[root@node1 ~]# crsctl stat res -t