Oracle Linux环境RAC数据库迁移到异机单实例
场景:
源数据库:RAC
dbname:rac
sid:rac1,rac2
目标数据库:新的单实例
dbname:rac
sid:rac
一、基于RMAN备份集 duplicate还原
基于RMAN duplicate方式,rman备份中必须要有归档备份
操作步骤:
1、RAC生成备份文件(数据文件,控制文件,归档文件)步骤略
2、拷贝至目标主机备份目录 步骤略
3、修改目标主机的ORACLE_SID
目标单实例主机:
[oracle@gs ~]$ export ORACLE_SID=rac
4、在目标主机创建参数文件,将其中cluster的参数删掉,保留或修改如下参数:
[oracle@gs ~]$ cd $ORACLE_HOME/dbs
[oracle@gs dbs]$ vi initrac.ora
audit_file_dest='/u01/app/oracle/admin/rac/adump'
audit_trail='none'
compatible='11.2.0.4.0'
control_files='/u01/app/oracle/oradata/rac/control01.ctl','/u01/app/oracle/oradata/rac/control02.ctl'
db_block_size=8192
db_domain=''
db_name='rac'
db_file_name_convert='+DATA/rac/datafile/','/u01/app/oracle/oradata/rac/','/soft/','/u01/app/oracle/oradata/rac/','+DATA/rac/tempfile/temp.265.965769119','/u01/app/oracle/oradata/rac/temp1.dbf'
log_file_name_convert='+DATA/rac/onlinelog/group_1.260.965769115','/u01/app/oracle/oradata/rac/redo01.log','+ARCH/rac/onlinelog/group_1.260.965769115' '/u01/app/oracle/oradata/rac/redo01_b.log','+DATA/rac/onlinelog/group_2.261.965769115','/u01/app/oracle/oradata/rac/redo02.log','+ARCH/rac/onlinelog/group_2.261.965769115','/u01/app/oracle/oradata/rac/redo02_b.log','+DATA/rac/onlinelog/group_3.268.965771071','/u01/app/oracle/oradata/rac/redo03.log','+ARCH/rac/onlinelog/group_3.262.965771071','/u01/app/oracle/oradata/rac/redo03_b.log','+DATA/rac/onlinelog/group_4.269.965771071','/u01/app/oracle/oradata/rac/redo04.log','+ARCH/ra℅nlinelog/group_4.263.965771071','/u01/app/oracle/oradata/rac/redo04_b.log'
diagnostic_dest='/u01/app/oracle'
sga_target=700m
pga_aggregate_target=300m
open_cursors=300
log_archive_dest_1='location=/u01/arch_rac'
log_archive_format='%t_%s_%r.dbf'
processes=1000
remote_login_passwordfile='exclusive'
sessions=1105
undo_tablespace='UNDOTBS1'
备注:
1、db_file_name_convert参数中,路径结尾后面需要已“/”结尾,否则rman会当文件名处理
2、使用duplicate方式rman备份还原到异机环境,rman备份中一定确保有归档备份,否则有如下报错:
RMAN-05541: no archived logs found in target database
5、创建数据文件目录、归档目录、adump目录、RMAN备份文件目录
[oracle@gs dbs]$ mkdir -p /u01/app/oracle/admin/rac/adump
[oracle@gs dbs]$ mkdir -p /u01/app/oracle/oradata/rac/
[oracle@gs dbs]$ mkdir -p /u01/arch_rac
[oracle@gs u01]$ mkdir -p /u01/rman_rac
6、启动数据库到nomount状态,并生成spfile文件
SQL> startup nomount;
SQL> create spfile from pfile;
File created.
重启数据库到nomount状态
SQL> startup nomount;
7、通过RMAN duplicate还原恢复数据库
[oracle@gs dbs]$ rman auxiliary /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 28 10:53:06 2018
Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: RAC (not mounted)
开始还原
RMAN> duplicate database to rac backup location '/u01/rman_rac';
还原过程
Starting Duplicate Db at 2018/06/28 10:53:31
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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''RAC'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''RAC'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/u01/rman_rac/control_20180627.bak';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''RAC'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''RAC'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
Starting restore at 2018/06/28 10:53:48
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/rac/control01.ctl
output file name=/u01/app/oracle/oradata/rac/control02.ctl
Finished restore at 2018/06/28 10:53:49
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1149 device type=DISK
datafile 9 not processed because file is offline
contents of Memory Script:
{
set until scn 1479268;
set newname for datafile 1 to
"/u01/app/oracle/oradata/rac/system.262.965769115";
set newname for datafile 2 to
"/u01/app/oracle/oradata/rac/sysaux.263.965769117";
set newname for datafile 3 to
"/u01/app/oracle/oradata/rac/undotbs1.264.965769119";
set newname for datafile 4 to
"/u01/app/oracle/oradata/rac/undotbs2.266.965769123";
set newname for datafile 5 to
"/u01/app/oracle/oradata/rac/users.267.965769123";
set newname for datafile 6 to
"/u01/app/oracle/oradata/rac/cs1.271.965812233";
set newname for datafile 7 to
"/u01/app/oracle/oradata/rac/undotbs1.272.971863999";
set newname for datafile 8 to
"/u01/app/oracle/oradata/rac/undotbs1.273.971864085";
restore
clone database
skip forever tablespace "XX" ;
}
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
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2018/06/28 10:53:54
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 /u01/app/oracle/oradata/rac/system.262.965769115
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/rac_full_20180627_03t6gm1d_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/rac_full_20180627_03t6gm1d_1_1.bak tag=TAG20180627T150721
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 /u01/app/oracle/oradata/rac/sysaux.263.965769117
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/rac/undotbs2.266.965769123
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/rac/users.267.965769123
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/rac/cs1.271.965812233
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/rac_full_20180627_02t6gm19_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/rac_full_20180627_02t6gm19_1_1.bak tag=TAG20180627T150721
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 /u01/app/oracle/oradata/rac/undotbs1.264.965769119
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/rac_full_20180627_04t6gm1h_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/rac_full_20180627_04t6gm1h_1_1.bak tag=TAG20180627T150721
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 00007 to /u01/app/oracle/oradata/rac/undotbs1.272.971863999
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/rac_full_20180627_06t6gm1j_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/rac_full_20180627_06t6gm1j_1_1.bak tag=TAG20180627T150721
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
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 00008 to /u01/app/oracle/oradata/rac/undotbs1.273.971864085
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/rac_full_20180627_05t6gm1i_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/rac_full_20180627_05t6gm1i_1_1.bak tag=TAG20180627T150721
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 2018/06/28 10:54:05
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/system.262.965769115
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/sysaux.263.965769117
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/undotbs1.264.965769119
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/undotbs2.266.965769123
datafile 5 switched to datafile copy
input datafile copy RECID=13 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/users.267.965769123
datafile 6 switched to datafile copy
input datafile copy RECID=14 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/cs1.271.965812233
datafile 7 switched to datafile copy
input datafile copy RECID=15 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/undotbs1.272.971863999
datafile 8 switched to datafile copy
input datafile copy RECID=16 STAMP=979988045 file name=/u01/app/oracle/oradata/rac/undotbs1.273.971864085
contents of Memory Script:
{
set until scn 1479268;
recover
clone database
skip forever tablespace "XX" delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2018/06/28 10:54:05
using channel ORA_AUX_DISK_1
Executing: alter database datafile 9 offline drop
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=2 sequence=39
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=94
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_rac/arch_full_08t6gm1q_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u01/rman_rac/arch_full_08t6gm1q_1_1.bak tag=TAG20180627T150737
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/arch_rac/1_94_965769112.dbf thread=1 sequence=94
archived log file name=/u01/arch_rac/2_39_965769112.dbf thread=2 sequence=39
channel clone_default: deleting archived log(s)
archived log file name=/u01/arch_rac/1_94_965769112.dbf RECID=1 STAMP=979988046
channel clone_default: deleting archived log(s)
archived log file name=/u01/arch_rac/2_39_965769112.dbf RECID=2 STAMP=979988046
media recovery complete, elapsed time: 00:00:00
Finished recover at 2018/06/28 10:54:07
Oracle instance started
Total System Global Area 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''RAC'' 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 = ''RAC'' 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 730714112 bytes
Fixed Size 2256832 bytes
Variable Size 243269696 bytes
Database Buffers 478150656 bytes
Redo Buffers 7036928 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "RAC" RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/rac/redo01.log', '/u01/app/oracle/oradata/rac/redo01_b.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/rac/redo02.log', '/u01/app/oracle/oradata/rac/redo02_b.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/rac/system.262.965769115'
CHARACTER SET ZHS16GBK
sql statement: ALTER DATABASE ADD LOGFILE
INSTANCE 'i2'
GROUP 3 ( '/u01/app/oracle/oradata/rac/redo03.log', '/u01/app/oracle/oradata/rac/redo03_b.log' ) SIZE 50 M REUSE,
GROUP 4 ( '/u01/app/oracle/oradata/rac/redo04.log', '/u01/app/oracle/oradata/rac/redo04_b.log' ) SIZE 50 M REUSE
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/rac/temp1.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/rac/sysaux.263.965769117",
"/u01/app/oracle/oradata/rac/undotbs1.264.965769119",
"/u01/app/oracle/oradata/rac/undotbs2.266.965769123",
"/u01/app/oracle/oradata/rac/users.267.965769123",
"/u01/app/oracle/oradata/rac/cs1.271.965812233",
"/u01/app/oracle/oradata/rac/undotbs1.272.971863999",
"/u01/app/oracle/oradata/rac/undotbs1.273.971864085";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/rac/temp1.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/sysaux.263.965769117 RECID=1 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/undotbs1.264.965769119 RECID=2 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/undotbs2.266.965769123 RECID=3 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/users.267.965769123 RECID=4 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/cs1.271.965812233 RECID=5 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/undotbs1.272.971863999 RECID=6 STAMP=979988061
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac/undotbs1.273.971864085 RECID=7 STAMP=979988061
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/sysaux.263.965769117
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/undotbs1.264.965769119
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/undotbs2.266.965769123
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/users.267.965769123
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/cs1.271.965812233
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/undotbs1.272.971863999
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=979988061 file name=/u01/app/oracle/oradata/rac/undotbs1.273.971864085
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Dropping offline and skipped tablespaces
Executing: drop tablespace "XX" including contents cascade constraints
Finished Duplicate Db at 2018/06/28 10:54:28
已恢复完毕
8、禁用THREAD 2日志组
由于rac是2节点实例,迁移到单实例,只需要thread 1
先查询THREAD 2使用的状态
SQL> select thread#,status,enabled from v$thread;
1 OPEN PUBLIC
2 CLOSED PUBLIC
SQL>alter database diable thread 2;
SQL> select thread#,status,enabled from v$thread;
1 OPEN PUBLIC
2 CLOSED DISABLED
已禁用thread 2
9、删除thread 2日志组
由于源数据库是RAC环境,thread有2个,现在只需保留一个
先查询thread 2使用的日志组号
SQL> select group#,archived,status from v$log where thread#=2;
3 YES INACTIVE
4 YES UNUSED
删除日志组
SQL> alter database drop logfile group 3;
SQL> alter database drop logfile group 4;
10、删除原数据库不用的undo表空间
先查询当前使用的undo表空间
SQL> show parameter undo
SQL> select * from v$tablespace where name like '%UNDO%'
删除不用的undo表空间
SQL> drop tablespace undotbs2 including contents and datafiles
11、重新生成新的undo表空间
SQL> create undo tablespace undo datafile '/u01/app/oracle/oradata/rac/undotbs1.dbf' size 200m autoextend on next 10m maxsize 1g;
Tablespace created.
SQL> alter system set undo_tablespace=undo scope=both;
System altered.
SQL> drop tablespace undotbs1 including contents and datafiles;
Tablespace dropped.
12、将新数据库添加到oratab中
[oracle@gs dbs]$ vi /etc/oratab
orcl3:/u01/app/oracle/product/11.2.0/db_1:N
13、迁移之后检查数据库完整性
二、通过备份文件手动恢复
操作步骤:
1、RAC生成备份文件(数据文件,控制文件,归档文件)步骤略
2、拷贝至目标主机备份目录 步骤略
3、修改目标主机的ORACLE_SID
目标单实例主机:
[oracle@gs ~]$ export ORACLE_SID=rac
4、在目标主机创建参数文件,将其中cluster的参数删掉,保留或修改如下参数:
[oracle@gs ~]$ cd $ORACLE_HOME/dbs
[oracle@gs dbs]$ vi initrac.ora
audit_file_dest='/u01/app/oracle/admin/rac/adump'
audit_trail='none'
compatible='11.2.0.4.0'
control_files='/u01/app/oracle/oradata/rac/control01.ctl','/u01/app/oracle/oradata/rac/control02.ctl'
db_block_size=8192
db_domain=''
db_name='rac'
diagnostic_dest='/u01/app/oracle'
sga_target=700m
pga_aggregate_target=300m
open_cursors=300
log_archive_dest_1='location=/u01/arch_rac'
log_archive_format='%t_%s_%r.dbf'
processes=1000
remote_login_passwordfile='exclusive'
sessions=1105
undo_tablespace='UNDOTBS1'
5、创建数据文件目录、归档目录、adump目录、RMAN备份文件目录
[oracle@gs dbs]$ mkdir -p /u01/app/oracle/admin/rac/adump
[oracle@gs dbs]$ mkdir -p /u01/app/oracle/oradata/rac/
[oracle@gs dbs]$ mkdir -p /u01/arch_rac
[oracle@gs u01]$ mkdir -p /u01/rman_rac
6、启动数据库到nomount状态,并生成spfile文件
SQL> startup nomount;
SQL> create spfile from pfile;
File created.
重启数据库到nomount状态
SQL> startup nomount;
7、通过RMAN恢复控制文件
RMAN> restore controlfile from '/u01/rman_rac/control_20180627.bak';
Starting restore at 2018/06/27 15:16:53
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/rac/control01.ctl
output file name=/u01/app/oracle/oradata/rac/control02.ctl
Finished restore at 2018/06/27 15:16:54
8、数据库启动到mount
启动到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
9、追加源主机RMAN备份文件到控制文件中
手动添加RAC环境下的备份集到单实例控制文件中
RMAN> catalog start with '/u01/rman_rac';
List of Files Unknown to the Database
=====================================
File Name: /u01/rman_rac/control_20180627.bak
File Name: /u01/rman_rac/rac_full_20180627_04t6gm1h_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_02t6gm19_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_07t6gm1k_1_1.bak
File Name: /u01/rman_rac/rac_rman.tar.gz
File Name: /u01/rman_rac/rac_full_20180627_06t6gm1j_1_1.bak
File Name: /u01/rman_rac/arch_full_08t6gm1q_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_05t6gm1i_1_1.bak
File Name: /u01/rman_rac/arch_full_01t6gm16_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_03t6gm1d_1_1.bak
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/rman_rac/control_20180627.bak
File Name: /u01/rman_rac/rac_full_20180627_04t6gm1h_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_02t6gm19_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_07t6gm1k_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_06t6gm1j_1_1.bak
File Name: /u01/rman_rac/arch_full_08t6gm1q_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_05t6gm1i_1_1.bak
File Name: /u01/rman_rac/arch_full_01t6gm16_1_1.bak
File Name: /u01/rman_rac/rac_full_20180627_03t6gm1d_1_1.bak
10、交叉检验备份文件
RMAN> crosscheck backup;
11、还原数据文件到单实例
由于rac下使用的是OMF路径,所以先用脚本查询出RAC环境中的数据文件名以及路径
set head off feed off verify off echo off pages 0 trimspool on
set line 132 pagesize 0
spo newname.sql
--
select 'run{' from dual;
--
select
'set newname for datafile ' || file# || ' to ' || '''' || name || '''' || ';'
from v$datafile;
--
select
'restore database;' || chr(10)||
'switch datafile all;' || chr(10) ||
'}'
from dual;
--
spo off;
修改数据文件到新的路径,如下:
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/rac/system.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/rac/sysaux.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/rac/undotbs1.264.965769119';
set newname for datafile 4 to '/u01/app/oracle/oradata/rac/undotbs2.266.965769123';
set newname for datafile 5 to '/u01/app/oracle/oradata/rac/users.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/rac/cs1.dbf';
set newname for datafile 7 to '/u01/app/oracle/oradata/rac/undotbs1.272.971863999';
set newname for datafile 8 to '/u01/app/oracle/oradata/rac/undotbs1.273.971864085';
set newname for datafile 9 to '/u01/app/oracle/oradata/rac/xx.dbf';
restore database;
switch datafile all;
}
将如上run块脚本执行,还原数据文件
12、恢复数据库
RMAN> recover database;
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 12 and starting SCN of 1119977
如果遇到如上提示,此行并没有问题,RMAN会不断寻找合适的日志进行恢复。
13、对日志文件重命名
先查询下源RAC数据库日志文件路径
SQL> select member from v$logfile;
+DATA/rac/onlinelog/group_1.260.965769115
+ARCH/rac/onlinelog/group_1.260.965769115
+DATA/rac/onlinelog/group_2.261.965769115
+ARCH/rac/onlinelog/group_2.261.965769115
+DATA/rac/onlinelog/group_3.268.965771071
+ARCH/rac/onlinelog/group_3.262.965771071
+DATA/rac/onlinelog/group_4.269.965771071
+ARCH/rac/onlinelog/group_4.263.965771071
更改新单实例数据库日志文件组路径
alter database rename file '+DATA/rac/onlinelog/group_1.260.965769115' to '/u01/app/oracle/oradata/rac/redo01.log';
alter database rename file '+ARCH/rac/onlinelog/group_1.260.965769115' to '/u01/app/oracle/oradata/rac/redo01_b.log';
alter database rename file '+DATA/rac/onlinelog/group_2.261.965769115' to '/u01/app/oracle/oradata/rac/redo02.log';
alter database rename file '+ARCH/rac/onlinelog/group_2.261.965769115' to '/u01/app/oracle/oradata/rac/redo02_b.log';
alter database rename file '+DATA/rac/onlinelog/group_3.268.965771071' to '/u01/app/oracle/oradata/rac/redo03.log';
alter database rename file '+ARCH/rac/onlinelog/group_3.262.965771071' to '/u01/app/oracle/oradata/rac/redo03_b.log';
alter database rename file '+DATA/rac/onlinelog/group_4.269.965771071' to '/u01/app/oracle/oradata/rac/redo04.log';
alter database rename file '+ARCH/rac/onlinelog/group_4.263.965771071' to '/u01/app/oracle/oradata/rac/redo04_b.log';
14、打开数据库
RMAN>alter database open resetlogs;
15、禁用THREAD 2日志组
先查询THREAD 2使用的状态
SQL> select thread#,status,enabled from v$thread;
1 OPEN PUBLIC
2 CLOSED PUBLIC
SQL>alter database diable thread 2;
SQL> select thread#,status,enabled from v$thread;
1 OPEN PUBLIC
2 CLOSED DISABLED
已禁用thread 2
16、删除thread 2日志组
由于源数据库是RAC环境,thread有2个,现在只需保留一个
先查询thread 2使用的日志组号
SQL> select group#,archived,status from v$log where thread#=2;
3 YES INACTIVE
4 YES UNUSED
删除日志组
SQL> alter database drop logfile group 3;
SQL> alter database drop logfile group 4;
17、删除原数据库不用的undo表空间
先查询当前使用的undo表空间
SQL> show parameter undo
删除不用的undo表空间
SQL> drop tablespace undotbs2 including contents and datafiles;
18、创建新的临时表空间
先查询下当前的临时表空间文件
SQL> select name from v$tempfile;
+DATA/rac/tempfile/temp.265.965769119
创建新的临时表空间temp
SQL>create temporary tablespace temp1 tempfile '/u01/app/oracle/oradata/rac/temp01.dbf' size 200m;
更改为默认临时表空间
SQL>alter database default temporary tablespace temp1;
删除旧的临时表空间
SQL>drop tablespace temp including contents and datafiles;
查询临时表空间是否生成
SQL> select name from v$tempfile;
/u01/app/oracle/oradata/rac/temp01.dbf
19、将新数据库添加到oratab中
[oracle@gs dbs]$ vi /etc/oratab
orcl3:/u01/app/oracle/product/11.2.0/db_1:N
20、迁移完毕之后检查数据库完整性