Oracle DataBase单实例迁移到Oracle RAC(3)

5. 创建thread 2的日志和另一个节点的undo表空间

[Oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus / as sysdba


查看节点1的日志,创建指定的目录:

SQL> set linesize 180
SQL> col member format a50
SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO

SQL> host mkdir -p /u01/app/oracle/oradata/orcl/

创建日志组和UNDO表空间,用于实例2的使用:

alter database add logfile thread 2
group 5 size 100M,
group 6 size 100M,
group 7 size 100M;


SQL> alter database add logfile thread 2
2 group 5 size 100M,
3 group 6 size 100M,
4 group 7 size 100M;

Database altered.

SQL> alter database open resetlogs;

Database altered.

SQL> alter database enable public thread 2;

Database altered.

SQL> CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '+DATA';

Tablespace created.

SQL>


6. 将在文件系统存放的日志,迁移到+ASM

alter database add logfile thread 1
group 8 size 100M,
group 9 size 100M;

alter database drop logfile group 2;
alter database drop logfile group 3;


alter system switch logfile;

alter system checkpoint;
alter database drop logfile group 1;
alter database add logfile group 1 size 100m, group 2 size 100m, group 3 size 100m;

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE +DATA/orcl/onlinelog/group_1.412.799341123 NO
1 ONLINE +FRA/orcl/onlinelog/group_1.265.799341129 YES
2 ONLINE +DATA/orcl/onlinelog/group_2.408.799341137 NO
5 ONLINE +DATA/orcl/onlinelog/group_5.363.799340635 NO
5 ONLINE +FRA/orcl/onlinelog/group_5.290.799340641 YES
6 ONLINE +DATA/orcl/onlinelog/group_6.386.799340649 NO
6 ONLINE +FRA/orcl/onlinelog/group_6.291.799340655 YES
7 ONLINE +DATA/orcl/onlinelog/group_7.389.799340661 NO
7 ONLINE +FRA/orcl/onlinelog/group_7.275.799340667 YES
8 ONLINE +DATA/orcl/onlinelog/group_8.400.799341055 NO
8 ONLINE +FRA/orcl/onlinelog/group_8.264.799341061 YES

GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
9 ONLINE +DATA/orcl/onlinelog/group_9.413.799341067 NO
9 ONLINE +FRA/orcl/onlinelog/group_9.292.799341073 YES
2 ONLINE +FRA/orcl/onlinelog/group_2.286.799341147 YES
3 ONLINE +DATA/orcl/onlinelog/group_3.394.799341153 NO
3 ONLINE +FRA/orcl/onlinelog/group_3.287.799341161 YES

16 rows selected.

SQL>

7. 创建cluster database的视图

create cluster database specific views within the existing instance

SQL> @$ORACLE_HOME/rdbms/admin/catclust.sql

8. 迁移临时文件

SQL> alter tablespace temp add tempfile '+DATA';

SQL> alter database tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' drop;


########################################################################

9. crs环境信息建立


在节点1操作:
[oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus / as sysdba

SQL> shutdown immediate

SQL> create pfile from spfile;
SQL> create spfile='+DATA/orcl/spfileorcl.ora' from pfile;


SQL> exit

[oracle@rac1 dbs]$ cd /u01/app/oracle/oracle/product/10.2.0/db_1/dbs
[oracle@rac1 dbs]$ rm spfileorcl1.ora
[oracle@rac1 dbs]$ echo "spfile='+DATA/orcl/spfileorcl.ora'" > initorcl1.ora


在节点2操作:


[oracle@rac2 dbs]$ cd /u01/app/oracle/oracle/product/10.2.0/db_1/dbs
[oracle@rac2 dbs]$ rm spfileorcl2.ora
rm: cannot remove `spfileorcl2.ora': No such file or directory
[oracle@rac2 dbs]$ echo "spfile='+DATA/orcl/spfileorcl.ora'" > initorcl2.ora
[oracle@rac2 dbs]$

10. 配置并启动RAC数据库

[oracle@rac1 dbs]$ srvctl add database -d orcl -o /u01/app/oracle/oracle/product/10.2.0/db_1
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl1 -n rac1
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl2 -n rac2

[oracle@rac1 dbs]$ srvctl modify instance -d orcl -i orcl1 -s +ASM1
[oracle@rac1 dbs]$ srvctl modify instance -d orcl -i orcl2 -s +ASM2

[oracle@rac1 dbs]$ srvctl start database -d orcl
[oracle@rac1 dbs]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.orcl.db application ONLINE ONLINE rac2
ora....l1.inst application ONLINE ONLINE rac1
ora....l2.inst application ONLINE ONLINE rac2
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
ora....b.AP.cs application OFFLINE OFFLINE
ora....db1.srv application OFFLINE OFFLINE
ora....b.GL.cs application OFFLINE OFFLINE
ora....db2.srv application OFFLINE OFFLINE
ora.racdb.db application OFFLINE OFFLINE
ora....b1.inst application OFFLINE OFFLINE
ora....b2.inst application OFFLINE OFFLINE
[oracle@rac1 dbs]$

##############################################

11. tnsnames.ora 网络配置文件


在两个节点的tnsnames.ora文件中操作

[oracle@rac1 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@rac1 admin]$ vi tnsnames.ora


添加:

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)


ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl1)
)
)


ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl2)
)
)

LISTENERS_ORCL =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

12. 验证


[oracle@rac1 admin]$ sqlplus system/oracle@orcl


SQL> col inst_name format a50
SQL> select * from v$active_instances;

INST_NUMBER INST_NAME
----------- --------------------------------------------------
1 rac1.localdomain:orcl1


2 rac2.localdomain:orcl2

SQL> col host_name format a20
SQL> select instance_name, host_name, archiver, thread#, status from gv$instance;

INSTANCE_NAME HOST_NAME ARCHIVE THREAD# STATUS
---------------- -------------------- ------- ---------- ------------
orcl1 rac1.localdomain STARTED 1 OPEN
orcl2 rac2.localdomain STARTED 2 OPEN

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7590481f361b3cdf684cf4da1a3a99e3.html