本次主要测试19c rac pdb迁移到单实例cdb库,数据库本身数据比较大,通过expdp导出导入方式影响整个迁移的效率,通过rman恢复方式来达成数据迁移的目的。
一、环境介绍
1、操作系统ORHEL 7.9 x64 rac
ip:10.10.10.11 rac1
ip: 10.10.10.12 rac2
ip-scan:10.10.10.15
2、数据库 oracle 19c 单实例
ip: 10.10.10.100
二、本方案适合于目标服务器全新部署或大版本升级
1、rman备份源端全库
备份脚本:
run{
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
allocate channel ch00 device type disk;
allocate channel ch01 device type disk;
allocate channel ch02 device type disk;
allocate channel ch03 device type disk;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt expired backup;
report obsolete;
delete noprompt obsolete;
backup as compressed backupset database format '/home/oracle/backup/full_%T_%u_%p.%d' tag='FULLDB'
plus archivelog format '/home/oracle/backup/arch_%T_%u_%p.%d' tag='ARCH' delete all input ;
sql 'alter system archive log current';
backup current controlfile format '/home/oracle/backup/control_%T_%u_%p.%d.bak' tag='control';
backup spfile format '/home/oracle/backup/spfile_%T_%u_%p.%d.bak' tag='spfile';
release channel ch00;
release channel ch01;
release channel ch02;
release channel ch03;
}
2、执行源库备份
[oracle@rac1 backup]$ ll
total 663984
-rw-r-----. 1 oracle asmadmin 9728 Jan 22 14:37 arch_20260122_224eh9f_1.ORCL
-rw-r-----. 1 oracle asmadmin 6144 Jan 22 14:37 arch_20260122_234eh9f_1.ORCL
-rw-r-----. 1 oracle asmadmin 5632 Jan 22 14:37 arch_20260122_244eh9f_1.ORCL
drwxr-xr-x. 3 oracle oinstall 18 Jan 22 14:22 date
-rw-r-----. 1 oracle asmadmin 89464832 Jan 22 14:37 full_20260122_1m4eh7k_1.ORCL
-rw-r-----. 1 oracle asmadmin 240672768 Jan 22 14:37 full_20260122_1n4eh7k_1.ORCL
-rw-r-----. 1 oracle asmadmin 42098688 Jan 22 14:36 full_20260122_1o4eh7k_1.ORCL
-rw-r-----. 1 oracle asmadmin 41754624 Jan 22 14:36 full_20260122_1p4eh7l_1.ORCL
-rw-r-----. 1 oracle asmadmin 1155072 Jan 22 14:36 full_20260122_1q4eh84_1.ORCL
-rw-r-----. 1 oracle asmadmin 36741120 Jan 22 14:37 full_20260122_1r4eh85_1.ORCL
-rw-r-----. 1 oracle asmadmin 63217664 Jan 22 14:37 full_20260122_1s4eh86_1.ORCL
-rw-r-----. 1 oracle asmadmin 63455232 Jan 22 14:37 full_20260122_1t4eh8l_1.ORCL
-rw-r-----. 1 oracle asmadmin 61988864 Jan 22 14:37 full_20260122_1u4eh8l_1.ORCL
-rw-r-----. 1 oracle asmadmin 2424832 Jan 22 14:37 full_20260122_1v4ehm_1.ORCL
-rw-r-----. 1 oracle asmadmin 14958592 Jan 22 14:37 full_20260122_204eh8n_1.ORCL
-rw-r-----. 1 oracle asmadmin 21954560 Jan 22 14:37 full_20260122_214eh8v_1.ORCL
drwxr-xr-x. 2 oracle oinstall 28 Jan 22 14:23 logs
备注:控制文件在+DATA/ORCL/AUTOBACKUP/2026_01_22/s_1223217465.294.1223217465 拷贝一份到目标恢复主机上。
[grid@rac1 ~]$ asmcmd
ASMCMD> cp +DATA/ORCL/AUTOBACKUP/2026_01_22/s_1223217465.294.1223217465 /home/grid/control01.ctl
[grid@rac1 ~]$ ll
total 2840928
-rw-r-----. 1 grid oinstall 19922944 Jan 22 15:14 control01.ctl
drwxr-xr-x. 2 grid oinstall 6 Apr 20 2025 Desktop
drwxr-xr-x. 2 grid oinstall 6 Apr 20 2025 Documents
[oracle@rac1 ~]$ ll
total 3007464
-rw-r--r--. 1 oracle oinstall 836 Jan 22 11:00 0_rmanbak.log
drwxr-xr-x. 4 oracle oinstall 4096 Jan 22 14:37 backup
-rwxrwxr-x. 1 oracle oinstall 0 Jan 22 14:24 backup.sh
-rw-r-----. 1 oracle oinstall 19922944 Jan 22 15:16 control01.ctl
3、将备份文件备份到目标恢复主机(带控制文件)
[oracle@rac1 ~]$ scp -r backup oracle@10.10.10.100:/home/oracle/
[oracle@rac1 ~]$ scp control01.ctl oracle@10.10.10.100:/home/oracle/
4、编辑目标库参数文件pfile
[oracle@db100 ~]$ cat pfile111.ora
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=1593835520
orcl.__inmemory_ext_roarea=0
orcl.__inmemory_ext_rwarea=0
orcl.__java_pool_size=0
orcl.__large_pool_size=16777216
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=2147483648
orcl.__sga_target=2415919104
orcl.__shared_io_pool_size=117440512
orcl.__shared_pool_size=671088640
orcl.__streams_pool_size=0
orcl.__unified_pga_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/oradata/ORCL/controlfile/current.262.1199036959','/oradata/ORCL/controlfile/current.261.1199036959'
*.db_block_size=8192
*.db_create_file_dest='/oradata'
*.db_name='orcl'
*.db_recovery_file_dest='/flash_recovery'
*.db_recovery_file_dest_size=10g
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.enable_pluggable_database=true
family:dw_helper.instance_mode='read-only'
*.local_listener='(ADDRESS =(PROTOCOL=TCP)(HOST=10.10.10.100)(PORT=1521)(SID=orcl))'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=794m
*.processes=300
*.remote_login_passwordfile='exclusive'
*.resource_manager_plan='DEFAULT_CDB_PLAN'
*.sga_target=2382m
*.undo_tablespace='UNDOTBS1'
创建目录文件夹:
[oracle@db100 ~]$ mkdir -p /u01/app/oracle/admin/orcl/adump /oradata/ORCL/controlfile/ /oradata /flash_recovery
6、还原参数文件:
[oracle@db100 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jan 22 15:26:06 2026
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/home/oracle/pfile111.ora';
ORACLE instance started.
Total System Global Area 2499804888 bytes
Fixed Size 9137880 bytes
Variable Size 687865856 bytes
Database Buffers 1795162112 bytes
Redo Buffers 7639040 bytes
SQL> create spfile from pfile='/home/oracle/pfile111.ora';
File created.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 2499804888 bytes
Fixed Size 9137880 bytes
Variable Size 687865856 bytes
Database Buffers 1795162112 bytes
Redo Buffers 7639040 bytes
7、还原控制文件(直接复制拷贝)
*.control_files='/oradata/ORCL/controlfile/current.262.1199036959','/oradata/ORCL/controlfile/current.261.1199036959'
[oracle@db100 ~]$ cp control01.ctl /oradata/ORCL/controlfile/current.262.1199036959
[oracle@db100 ~]$ cp control01.ctl /oradata/ORCL/controlfile/current.261.1199036959
[oracle@db100 ~]$ ll /oradata/ORCL/controlfile/
total 57200
-rw-r-----. 1 oracle oinstall 19922944 Jan 22 15:31 current.261.1199036959
-rw-r-----. 1 oracle oinstall 19922944 Jan 22 15:30 current.262.1199036959
复制过程中需要检测控制文件前后md5sum是否一致
[oracle@db100 ~]$ md5sum control01.ctl
2d6b60fac062b6825cdaef9060cc242a control01.ctl
[oracle@db100 ~]$ cd /oradata/ORCL/controlfile/
[oracle@db100 controlfile]$ cp /home/oracle/control01.ctl current.262.1199036959
[oracle@db100 controlfile]$ md5sum current.262.1199036959
2d6b60fac062b6825cdaef9060cc242a current.262.1199036959
8、启动库到mount状态
SQL> alter database mount;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
ORCL MOUNTED
9、注册备份文件
RMAN> catalog start with '/home/oracle/backup';
Starting implicit crosscheck backup at 2026:01:2215:40:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
Crosschecked 16 objects
Finished implicit crosscheck backup at 2026:01:2215:40:11
Starting implicit crosscheck copy at 2026:01:2215:40:11
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2026:01:2215:40:11
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /flash_recovery/ORCL/archivelog/2025_04_16/o1_mf_1_6_mzyjjc53_.arc
File Name: /flash_recovery/ORCL/archivelog/2025_11_18/o1_mf_1_7_nks5h4v8_.arc
File Name: /flash_recovery/ORCL/archivelog/2025_12_19/o1_mf_1_8_nn9gofl3_.arc
File Name: /flash_recovery/ORCL/archivelog/2025_12_20/o1_mf_1_9_nncvdpjs_.arc
File Name: /flash_recovery/ORCL/archivelog/2025_12_21/o1_mf_1_10_nngl3cyj_.arc
File Name: /flash_recovery/ORCL/archivelog/2025_12_29/o1_mf_1_11_no52dbov_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_01/o1_mf_1_12_nodzjgot_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_03/o1_mf_1_13_nojy26q6_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_04/o1_mf_1_14_nomlpz8c_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_12/o1_mf_1_15_npb3m7ng_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_21/o1_mf_1_16_nq0twlkx_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_21/o1_mf_1_17_nq12vq85_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_21/o1_mf_1_18_nq1n5drd_.arc
File Name: /flash_recovery/ORCL/archivelog/2026_01_22/o1_mf_1_19_nq2n9qdn_.arc
10、恢复目标库
[oracle@db100 ~]$ rman target /
RMAN> restore database;
Starting restore at 2026:01:2217:10:09
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 00084 to +DATA/ORCL/4785C9AA302D481BE0630B0A0A0A3171/DATAFILE/sysaux.335.1221639155
channel ORA_DISK_1: restoring datafile 00087 to +DATA/ORCL/4785C9AA302D481BE0630B0A0A0A3171/DATAFILE/users.280.1221639155
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_20260122_3s4ehrcv_1.ORCL
channel ORA_DISK_1: piece handle=/home/oracle/backup/full_20260122_3s4ehrcv_1.ORCL tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 00120 to +DATA/ORCL/48E6C514D0AB9D3EE0630B0A0A0AC748/DATAFILE/sysaux.359.1223155299
channel ORA_DISK_1: restoring datafile 00122 to +DATA/ORCL/48E6C514D0AB9D3EE0630B0A0A0AC748/DATAFILE/data02.371.1223155299
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_20260122_3r4ehrcv_1.ORCL
channel ORA_DISK_1: piece handle=/home/oracle/backup/full_20260122_3r4ehrcv_1.ORCL tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
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 00004 to +DATA/ORCL/DATAFILE/undotbs1.259.1199036887
channel ORA_DISK_1: restoring datafile 00009 to +DATA/ORCL/DATAFILE/undotbs2.272.1199037679
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_20260122_3t4ehrdp_1.ORCL
channel ORA_DISK_1: piece handle=/home/oracle/backup/full_20260122_3t4ehrdp_1.ORCL tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
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/ORCL/DATAFILE/sysaux.258.1199036861
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_20260122_3p4ehrcv_1.ORCL
RMAN> recover database;
Starting recover at 2026:01:2217:14:49
using channel ORA_DISK_1
starting media recovery
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/22/2026 17:14:51
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 2 with sequence 48 and starting SCN of 8689016 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 53 and starting SCN of 8689012 found to restore
11、检查归档日志情况
目标库:
RMAN> list archivelog all;
List of Archived Log Copies for database with db_unique_name ORCL
===================================================================
Key Thrd Seq S Low Time
96 1 53 A 2026:01:2216:40:01
Name: +DATA/ORCL/ARCHIVELOG/2026_01_22/thread_1_seq_53.295.1223224809
95 2 48 A 2026:01:2216:40:03
Name: +DATA/ORCL/ARCHIVELOG/2026_01_22/thread_2_seq_48.293.1223224809
源库:
RMAN> list archivelog all;
List of Archived Log Copies for database with db_unique_name ORCL
====================================================================
