Oracle Linux环境单实例迁移到RAC集群

Oracle Linux环境单实例迁移到RAC集群

  • 一、RMAN手动还原备份集方式
  • 二、RMAN DUPLICATE方式

一、RMAN手动还原备份集方式

1.1 迁移环境
源数据库

操作系统:CentsOS 7.2
Oracle数据库版本:11.2.0.4 单实例
ORACLE_SID:ORCL
DB_NAME:ORCL

目标数据库

操作系统:CentOS 7.5
Oracle数据库版本:11.2.0.4 RAC
ORACLE_SID:ORCL
DB_NAME:ORCL

1.2 迁移准备
1、在迁移前需要在单实例数据库做好RMAN全备,以及归档日志备份。在RAC环境还原时需要考虑pfile中控制文件的路径。
2、此案例中rac环境的实例名、DBNAME与源数据库均相同。如迁移完毕,可将旧数据文件从ASM中删除

1.3 迁移步骤
1.3.1 源服务器做RMAN全备

rman target /

run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database filesperset 2 format '/u01/rman/full_%d_%U.bak';
backup archivelog all format '/u01/rman/arch_%d_%U.bak';
release channel c1;
release channel c2;
}

1.3.2 查看备份集
ll /u01/rman

[root@gs oracle]# ll /u01/rman -hrt
总用量 2.0G
-rw-r----- 1 oracle oinstall 768M 11月 12 11:44 full_ORCL_7jti1ekt_1_1.bak
-rw-r----- 1 oracle oinstall 946M 11月 12 11:44 full_ORCL_7iti1ekt_1_1.bak
-rw-r----- 1 oracle oinstall 4.2M 11月 12 11:44 full_ORCL_7kti1elc_1_1.bak
-rw-r----- 1 oracle oinstall  96K 11月 12 11:44 full_ORCL_7mti1ele_1_1.bak
-rw-r----- 1 oracle oinstall  18M 11月 12 11:44 full_ORCL_7lti1elc_1_1.bak
-rw-r----- 1 oracle oinstall  12M 11月 12 11:44 arch_ORCL_7oti1elf_1_1.bak
-rw-r----- 1 oracle oinstall 252M 11月 12 11:44 arch_ORCL_7nti1elf_1_1.bak
-rw-r----- 1 oracle oinstall 8.0K 11月 12 11:44 arch_ORCL_7pti1elh_1_1.bak

1.3.3 拷贝备份到目标RAC数据库服务器

scp /u01/rman/* oracle@172.16.4.41:/u01/rman

1.3.4 在目标RAC数据库检查文件目录权限
RMAN备份目录

chown -R oracle:oinstall /u01/rman

adump目录

mkdir -p /u01/app/oracle/admin/orcl/adump/

1.3.5 rac数据库修改集群参数为false

$ sqlplus / as sysdba;

SQL> alter system set cluster_database=true scope=spfile sid='*';

1.3.6 生成pfile文件

create pfile from spfile;

1.3.7 关闭rac数据库

 srvctl stop database -d orcl

1.3.8 修改rac数据库pfile参数

su - oracle

vi $ORACLE_HOME/dbs/initorcl1.ora

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='none'
*.cluster_database=FALSE
*.compatible='11.2.0.4.0'
*.control_files='+DATA/orcl/controlfile/control1.ctl' 
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='orcl'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.memory_target=830472192
*.open_cursors=300
*.processes=150
*.remote_listener='rac-scan:1521'
*.remote_login_passwordfile='exclusive'
*.sessions=170
*.LOG_ARCHIVE_DEST_1='LOCATION=+data'

备注:需要注意控制文件以及归档日志文件的目录参数

1.3.9 目标rac数据库启动到nomount

sqlplus / as sysdba
startup nomount;

1.3.10 还原控制文件

[oracle@rac1 ~]$ rman target /
RMAN> restore controlfile from '/u01/rman/full_ORCL_7lti1elc_1_1.bak';
Starting restore at 2018/11/09 15:22:54
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=30 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/orcldb/controlfile/current.260.991669137
output file name=+CRS/orcldb/controlfile/current.256.991669137
Finished restore at 2018/11/09 15:22:56

1.3.11 数据库启动到mount状态

RMAN> alter database mount;

1.3.12 手动注册备份集目录到控制文件

RMAN> crosscheck backupset;
RMAN> catalog start with '/u01/rman';
RMAN> list backupset summary;

1.3.13 查看控制文件中数据文件、日志文件目录

set pagesize 200
set linesize 200
select file#,name from v$datafile;
FILE#       NAME
---------- ----------------------------------
1 /u01/app/oracle/oradata/orcl/SYSTEM01.DBF
2 /u01/app/oracle/oradata/orcl/SYSAUX01.DBF
3 /u01/app/oracle/oradata/orcl/UNDOTBS01.DBF
4 /u01/app/oracle/oradata/orcl/USERS01.DBF
5 /u01/app/oracle/oradata/orcl/ADMIN.DBF
SQL> select member from v$logfile;
 MEMBER
/u01/app/oracle/oradata/orcl/REDO03.LOG
/u01/app/oracle/oradata/orcl/REDO02.LOG
/u01/app/oracle/oradata/orcl/REDO01.LOG
SQL> select name from v$tempfile;
/u01/app/oracle/oradata/orcl/TEMP01.DBF

1.3.14 生成RMAN恢复数据文件脚本

select 'set newname for datafile ' || file# || ' to ''' ||'+DATA'||''';' cmd from v$datafile;

set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for datafile 5 to '+DATA';
set newname for datafile 6 to '+DATA';
select 'set newname for tempfile '||FILE#||' to '''||'+DATA'||''';' cmd from v$tempfile;
set newname for tempfile 1 to '+DATA';

1.3.15 RMAN还原数据文件

rman target /

run {
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for datafile 5 to '+DATA';
set newname for datafile 6 to '+DATA';
set newname for tempfile 1 to '+DATA';
restore database;
switch datafile all;
switch tempfile all;
}

日志过程:

Starting restore at 2018/11/12 13:56:46
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to +DATA
channel ORA_DISK_1: restoring datafile 00004 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/rman/full_ORCL_7jti1ekt_1_1.bak
channel ORA_DISK_1: piece handle=/u01/rman/full_ORCL_7jti1ekt_1_1.bak tag=TAG20181112T114429
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATA
channel ORA_DISK_1: restoring datafile 00006 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/rman/full_ORCL_7iti1ekt_1_1.bak
channel ORA_DISK_1: piece handle=/u01/rman/full_ORCL_7iti1ekt_1_1.bak tag=TAG20181112T114429
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to +DATA
channel ORA_DISK_1: restoring datafile 00005 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/rman/full_ORCL_7kti1elc_1_1.bak
channel ORA_DISK_1: piece handle=/u01/rman/full_ORCL_7kti1elc_1_1.bak tag=TAG20181112T114429
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 2018/11/12 13:58:44

datafile 1 switched to datafile copy
input datafile copy RECID=19 STAMP=992008725 file name=+DATA/orcl/datafile/system.270.992008645
datafile 2 switched to datafile copy
input datafile copy RECID=20 STAMP=992008725 file name=+DATA/orcl/datafile/sysaux.277.992008609
datafile 3 switched to datafile copy
input datafile copy RECID=21 STAMP=992008726 file name=+DATA/orcl/datafile/undotbs1.272.992008689
datafile 4 switched to datafile copy
input datafile copy RECID=22 STAMP=992008726 file name=+DATA/orcl/datafile/users.269.992008609
datafile 5 switched to datafile copy
input datafile copy RECID=23 STAMP=992008726 file name=+DATA/orcl/datafile/securespace.275.992008689
datafile 6 switched to datafile copy
input datafile copy RECID=24 STAMP=992008727 file name=+DATA/orcl/datafile/tbs.271.992008647

renamed tempfile 1 to +DATA in control file

1.3.16 查看备份集中归档日志最新的SCN

RMAN> list backup of archivelog all;
List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
222     251.91M    DISK        00:00:00     2018/11/12 11:44:47
        BP Key: 225   Status: AVAILABLE  Compressed: NO  Tag: TAG20181112T114447
        Piece Name: /u01/rman/arch_ORCL_7nti1elf_1_1.bak

  List of Archived Logs in backup set 222
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    38      5569280    2018/11/06 22:13:07 5645987    2018/11/12 11:25:57

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
223     11.49M     DISK        00:00:00     2018/11/12 11:44:47
        BP Key: 226   Status: AVAILABLE  Compressed: NO  Tag: TAG20181112T114447
        Piece Name: /u01/rman/arch_ORCL_7oti1elf_1_1.bak

  List of Archived Logs in backup set 223
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    39      5645987    2018/11/12 11:25:57 5653922    2018/11/12 11:41:27
  1    40      5653922    2018/11/12 11:41:27 5654022    2018/11/12 11:42:23

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
224     7.50K      DISK        00:00:00     2018/11/12 11:44:49
        BP Key: 227   Status: AVAILABLE  Compressed: NO  Tag: TAG20181112T114447
        Piece Name: /u01/rman/arch_ORCL_7pti1elh_1_1.bak

  List of Archived Logs in backup set 224
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    41      5654022    2018/11/12 11:42:23 5654198 -->最新的scn   2018/11/12 11:44:47

1.3.17 恢复数据库

RMAN> recover database until scn 5654198;

1.3.18 修改RAC环境redo文件路径

set line 150
col member for a40
col status for a5
col IS_RECOVERY_DEST_FILE for a3
col type for a6
col GROUP# for 99

select * from v$logfile;
GROUP# STATU TYPE   MEMBER                                   IS_
------ ----- ------ ---------------------------------------- ---
     1       ONLINE /u01/app/oracle/oradata/orcl/redo01.log  NO
     2       ONLINE /u01/app/oracle/oradata/orcl/redo02.log  NO
     3       ONLINE /u01/app/oracle/oradata/orcl/redo03.log  NO
alter database rename file '/u01/app/oracle/oradata/orcl/redo01.log' to '+DATA';
alter database rename file '/u01/app/oracle/oradata/orcl/redo02.log' to '+DATA';
alter database rename file '/u01/app/oracle/oradata/orcl/redo03.log' to '+DATA';

1.3.19 打开数据库

alter database open resetlogs;

1.3.20 生成spfile文件

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

1.3.21 修改RAC的pfile将路径指向ASM的spfile
vi initorcl1.ora

SPFILE='+DATA/orcl/spfileorcl.ora'

1.3.22 数据库重启

shutdown immediate;
startup;

1.3.23 恢复RAC数据库集群参数

alter system set cluster_database=true scope=spfile sid='*';
alter system set cluster_database_instances=2 scope=spfile sid='*';
alter system set instance_number=1 scope=spfile sid='orcl1';
alter system set instance_number=2 scope=spfile sid='orcl2';
alter system set thread=1 scope=spfile sid='orcl1';
alter system set thread=2 scope=spfile sid='orcl2';

1.3.24 创建节点2的undo

show parameter undo_tablespace

create undo tablespace UNDOTBS2 datafile '+DATA/orcl/datafile/undotbs02.dbf' size 100M autoextend on;

 alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='orcl2';

1.3.25 节点2上增加redo日志组

SQL> select bytes/1024/1024 from v$log;

BYTES/1024/1024
---------------
            300
            300
            300
alter database add logfile thread 2 group 4 ('+DATA') size 300M;
alter database add logfile thread 2 group 5 ('+DATA') size 300M;
alter database add logfile thread 2 group 6 ('+DATA') size 300M;
alter database enable thread 2;
SQL> select bytes/1024/1024 from v$log;

BYTES/1024/1024
---------------
            300
            300
            300
            300
            300
            300

6 rows selected.

1.3.26 重建temp表空间

select name from v$tempfile;
NAME
---------
+DATA/orcl/tempfile/temp.258.992009741

alter tablespace temp add tempfile '+DATA' size 100M autoextend on;

1.3.27 将临时文件离线

alter database tempfile '+DATA/orcl/tempfile/temp.258.992009741' offline;

1.3.28 重启数据库

shutdown immediate;
startup
alter database tempfile '+DATA/orcl/tempfile/temp.258.992009741' drop including datafiles;

1.3.29 启动RAC所有实例

srvctl start database -d orcl -o open

1.3.30 查看集群状态、以及RAC数据库

crsctl stat res -t
col instance_name for a20
col host_name for a10
select instance_number,instance_name ,host_name from gv$instance;
INSTANCE_NUMBER INSTANCE_NAME        HOST_NAME
--------------- -------------------- ----------
              1 orcl1                rac1
              2 orcl2                rac2

1.3.31 执行catclust.sql脚本创建相关视图

 @$ORACLE_HOME/rdbms/admin/catclust.sql

1.3.32 查看REDO日志组状态

set pagesize 9999
col member for a50

select group#,member from v$logfile order by group#;
GROUP# MEMBER
---------- --------------------------------------------------
         1 +DATA/orcl/onlinelog/group_1.273.992009711
         2 +DATA/orcl/onlinelog/group_2.264.992009715
         3 +DATA/orcl/onlinelog/group_3.259.992009727
         4 +DATA/orcl/onlinelog/group_4.256.992010487
         5 +DATA/orcl/onlinelog/group_5.260.992010493
         6 +DATA/orcl/onlinelog/group_6.266.992010507

1.3.33 查看数据的配置情况

srvctl config database -d orcl

Database unique name: orcl
Database name: 
Oracle home: /u01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: 
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA,CRS
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed

1.3.34 再次查看集群状态
crsctl stat res -t

[root@rac1 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               ONLINE  ONLINE       rac1                                         
               ONLINE  ONLINE       rac2                                         
ora.DATA.dg
               ONLINE  ONLINE       rac1                                         
               ONLINE  ONLINE       rac2                                         
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                                         
               ONLINE  ONLINE       rac2                                         
ora.asm
               ONLINE  ONLINE       rac1                     Started             
               ONLINE  ONLINE       rac2                     Started             
ora.gsd
               OFFLINE OFFLINE      rac1                                         
               OFFLINE OFFLINE      rac2                                         
ora.net1.network
               ONLINE  ONLINE       rac1                                         
               ONLINE  ONLINE       rac2                                         
ora.ons
               ONLINE  ONLINE       rac1                                         
               ONLINE  ONLINE       rac2                                         
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac2                                         
ora.cvu
      1        ONLINE  ONLINE       rac2                                         
ora.oc4j
      1        ONLINE  ONLINE       rac2                                         
ora.orcl.db
      1        ONLINE  ONLINE       rac1                     Open                
      2        ONLINE  ONLINE       rac2                     Open                
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                                         
ora.rac2.vip
      1        ONLINE  ONLINE       rac2                                         
ora.scan1.vip
      1        ONLINE  ONLINE       rac2 

单实例迁移到RAC环境完毕

二、RMAN DUPLICATE方式

2.1 迁移环境
源数据库

操作系统:CentsOS 7.2
Oracle数据库版本:11.2.0.4 单实例
ORACLE_SID:ORCL
DB_NAME:ORCL

目标数据库

操作系统:CentOS 7.5
Oracle数据库版本:11.2.0.4 RAC
ORACLE_SID:ORCL
DB_NAME:ORCL

2.2 迁移准备
1、在迁移前需要在单实例数据库做好RMAN全备,以及归档日志备份。在RAC环境还原时需要考虑pfile中控制文件的路径。
2、rman还原之后需要做如下动作
生成asm的spfile
恢复rac环境的集群参数
恢复节点2undo表空间
增加节点2 thread日志组
在srvctl组件中增加数据库节点

2.3 操作步骤

[oracle@rac1:/home/oracle]$rman auxiliary /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Dec 17 10:30:36 2018

Copyright © 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate database to orcl backup location '/u01/rman/';
Starting Duplicate Db at 2018-12-17 10:30:54

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     835104768 bytes

Fixed Size                     2257840 bytes
Variable Size                247467088 bytes
Database Buffers             583008256 bytes
Redo Buffers                   2371584 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u01/rman/full_ORCL_7lti1elc_1_1.bak';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     835104768 bytes

Fixed Size                     2257840 bytes
Variable Size                247467088 bytes
Database Buffers             583008256 bytes
Redo Buffers                   2371584 bytes

Starting restore at 2018-12-17 10:31:25
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=30 device type=DISK

channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=+ORADATA/orcl/controlfile/control1.ctl
Finished restore at 2018-12-17 10:31:28

database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=30 device type=DISK

contents of Memory Script:
{
   set until scn  5654198;
   set newname for datafile  1 to 
 "+ORADATA/orcl/datafile/system01.dbf";
   set newname for datafile  2 to 
 "+ORADATA/orcl/datafile/sysaux01.dbf";
   set newname for datafile  3 to 
 "+ORADATA/orcl/datafile/undotbs01.dbf";
   set newname for datafile  4 to 
 "+ORADATA/orcl/datafile/users01.dbf";
   set newname for datafile  5 to 
 "+ORADATA/orcl/datafile/secure.dbf";
   set newname for datafile  6 to 
 "+ORADATA/orcl/datafile/tbs.dbf";
   restore
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2018-12-17 10:31:34
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to +ORADATA/orcl/datafile/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to +ORADATA/orcl/datafile/tbs.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/full_ORCL_7iti1ekt_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman/full_ORCL_7iti1ekt_1_1.bak tag=TAG20181112T114429
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00002 to +ORADATA/orcl/datafile/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to +ORADATA/orcl/datafile/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/full_ORCL_7jti1ekt_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman/full_ORCL_7jti1ekt_1_1.bak tag=TAG20181112T114429
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to +ORADATA/orcl/datafile/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to +ORADATA/orcl/datafile/secure.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/full_ORCL_7kti1elc_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman/full_ORCL_7kti1elc_1_1.bak tag=TAG20181112T114429
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018-12-17 10:32:53

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=995106775 file name=+ORADATA/orcl/datafile/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=995106775 file name=+ORADATA/orcl/datafile/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=995106775 file name=+ORADATA/orcl/datafile/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=995106775 file name=+ORADATA/orcl/datafile/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=995106775 file name=+ORADATA/orcl/datafile/secure.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=995106775 file name=+ORADATA/orcl/datafile/tbs.dbf

contents of Memory Script:
{
   set until scn  5654198;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 2018-12-17 10:32:56
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=41
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/arch_ORCL_7pti1elh_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman/arch_ORCL_7pti1elh_1_1.bak tag=TAG20181112T114447
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=+ARCH/orcl/archivelog/2018_12_17/thread_1_seq_41.261.995106781 thread=1 sequence=41
channel clone_default: deleting archived log(s)
archived log file name=+ARCH/orcl/archivelog/2018_12_17/thread_1_seq_41.261.995106781 RECID=1 STAMP=995106781
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018-12-17 10:33:05
Oracle instance started

Total System Global Area     835104768 bytes

Fixed Size                     2257840 bytes
Variable Size                247467088 bytes
Database Buffers             583008256 bytes
Redo Buffers                   2371584 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''ORCL'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''ORCL'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     835104768 bytes

Fixed Size                     2257840 bytes
Variable Size                247467088 bytes
Database Buffers             583008256 bytes
Redo Buffers                   2371584 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY     2920
 LOGFILE
  GROUP   1 ( '+ORADATA/orcl/onlinelog/redo01.log' ) SIZE 300 M  REUSE,
  GROUP   2 ( '+ORADATA/orcl/onlinelog/redo02.log' ) SIZE 300 M  REUSE,
  GROUP   3 ( '+ORADATA/orcl/onlinelog/redo03.log' ) SIZE 300 M  REUSE
 DATAFILE
  '+ORADATA/orcl/datafile/system01.dbf'
 CHARACTER SET ZHS16GBK


contents of Memory Script:
{
   set newname for tempfile  1 to 
 "+ORADATA/orcl/datafile/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "+ORADATA/orcl/datafile/sysaux01.dbf", 
 "+ORADATA/orcl/datafile/undotbs01.dbf", 
 "+ORADATA/orcl/datafile/users01.dbf", 
 "+ORADATA/orcl/datafile/secure.dbf", 
 "+ORADATA/orcl/datafile/tbs.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +ORADATA/orcl/datafile/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=+ORADATA/orcl/datafile/sysaux01.dbf RECID=1 STAMP=995106815
cataloged datafile copy
datafile copy file name=+ORADATA/orcl/datafile/undotbs01.dbf RECID=2 STAMP=995106815
cataloged datafile copy
datafile copy file name=+ORADATA/orcl/datafile/users01.dbf RECID=3 STAMP=995106815
cataloged datafile copy
datafile copy file name=+ORADATA/orcl/datafile/secure.dbf RECID=4 STAMP=995106815
cataloged datafile copy
datafile copy file name=+ORADATA/orcl/datafile/tbs.dbf RECID=5 STAMP=995106815

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=995106815 file name=+ORADATA/orcl/datafile/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=995106815 file name=+ORADATA/orcl/datafile/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=995106815 file name=+ORADATA/orcl/datafile/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=995106815 file name=+ORADATA/orcl/datafile/secure.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=995106815 file name=+ORADATA/orcl/datafile/tbs.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database add supplemental log data
Executing: alter database add supplemental log data(PRIMARY KEY, FOREIGN KEY) columns

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 2018-12-17 10:34:14

2.4 创建节点1的spfile

SQL> create spfile='+ORADATA/orcl/spfileorcl.ora' from pfile='initorcl1.ora.zero';

File created.

2.5 重启节点1已spfile方式启动

SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup;

2.6 创建节点2的undo

SQL> show parameter undo_table

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace                      string      UNDOTBS1
SQL> create undo tablespace UNDOTBS2 datafile '+DATA/orcl/datafile/undotbs02.dbf' size 100M autoextend on;
 SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='orcl2';

2.7 恢复rac环境的特有参数

SQL> show parameter cluster

SQL> alter system set cluster_database=true sid='*' scope=spfile;

System altered.


SQL> alter system set cluster_database_instances=2 sid='*' scope=spfile;

System altered.

SQL> alter system set instance_number=1 sid='orcl1' scope=spfile;

System altered.

SQL> alter system set instance_number=2 sid='orcl2' scope=spfile;  

System altered.

SQL> alter system set thread=1 sid='orcl1' scope=spfile;

System altered.

SQL> alter system set thread=2 sid='orcl2' scope=spfile;   

System altered.

2.8 节点2上增加redo日志组

SQL> select bytes/1024/1024 from v$log;

BYTES/1024/1024
---------------
            300
            300
            300
alter database add logfile thread 2 group 4 ('+DATA') size 300M;
alter database add logfile thread 2 group 5 ('+DATA') size 300M;
alter database add logfile thread 2 group 6 ('+DATA') size 300M;
alter database enable thread 2;
SQL> select bytes/1024/1024 from v$log;

BYTES/1024/1024
---------------
            300
            300
            300
            300
            300
            300

6 rows selected.

2.9 重启数据库

srvctl stop database -d orcl
srvctl start database -d orcl

2.10 查看集群状态、以及RAC数据库

crsctl stat res -t
col instance_name for a20
col host_name for a10
select instance_number,instance_name ,host_name from gv$instance;
INSTANCE_NUMBER INSTANCE_NAME        HOST_NAME
--------------- -------------------- ----------
              1 orcl1                rac1
              2 orcl2                rac2

2.11 执行catclust.sql脚本创建相关视图

 @$ORACLE_HOME/rdbms/admin/catclust.sql

2.12 查看REDO日志组状态

set pagesize 9999
col member for a50

select group#,member from v$logfile order by group#;
GROUP# MEMBER
---------- --------------------------------------------------
         1 +DATA/orcl/onlinelog/group_1.273.992009711
         2 +DATA/orcl/onlinelog/group_2.264.992009715
         3 +DATA/orcl/onlinelog/group_3.259.992009727
         4 +DATA/orcl/onlinelog/group_4.256.992010487
         5 +DATA/orcl/onlinelog/group_5.260.992010493
         6 +DATA/orcl/onlinelog/group_6.266.992010507

2.13 查看数据的配置情况

srvctl config database -d orcl

Database unique name: orcl
Database name: 
Oracle home: /u01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: 
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA,CRS
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed

数据库迁移完毕

你可能感兴趣的:(迁移,Oracle数据库多环境迁移,linux,单实例到rac)