适用范围
建议 12.2.0.1 及以上版本使用
方案概述
Oracle rac 12.2 cdb环境的rman备份需要恢复到12.2单实例环境上进行测试使用,不完全恢复即可,备份在源端和目标端都配置了共享nfs,挂载的路径分别为/rac/rman/test1和/baktmp/rman/test1。源端每周日进行0级全量备份,周一到周六进行1级增量备份
实施步骤
1.查看备份脚本
– 全量备份脚本
$ cat rman_0_level_full.sh
#!/bin/sh
source /home/oracle/.bash_profile
export ORACLE_SID=test1
DAY_TAG=`date +"%Y-%m-%d"`
backdir1=/rac/rman/test1
rman target / nocatalog msglog /rac/rman/test1/log/fullback_$DAY_TAG.log catalog start with '/baktmp/rman/test1';
RMAN> crosscheck backup;
RMAN> delete noprompt expired backup;
2.4.恢复数据文件
$ cat restore.sh
#!/bin/sh
rman target / log=/home/oracle/rman_restore.log alter database disable thread 2;
SQL> alter database drop logfile group 5;
SQL> alter database drop logfile group 6;
SQL> alter database drop logfile group 7;
SQL> alter database drop logfile group 9;
2.9.启动监听并注册本地监听
$ lsnrctl start
$ sqlplus / as sysdba
SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.8)(PORT=1521))';
SQL> alter system register;
2.10.修改max_string_size为extend
$ sqlplus / as sysdba
SQL> alter system set max_string_size = extended scope=spile;
SQL> shut immeidate;
SQL> startup;
SQL> alter pluggable database all open;
SQL> alter pluggable database all save state;
上面sql拼接生成的rename的文本,可以拿过来执行进行rename操作
3.遇到问题
3.1.启动nomount报错
startup nomount pfile='/data/oracle/product/12.2.0.1/dbhome_1/dbs/inittest.ora';
ORA-00371: not enough shared pool memory, should be at least 503735201 bytes
inittest.ora参数文件添加shared_pool_size=5368709120 后重启到nomount
shared_pool_size=5368709120
3.2.权限不足无法找到备份文件
RMAN> restore controlfile from '/baktmp/rman/TEST1/ctl_TEST_20240408_1165174769_27019_1';
Starting restore at 08-APR-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=633 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/08/2024 15:53:41
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
RMAN>
赋权限解决
# cd /baktmp/rman/test1
# chmod 777 *20240407* *20240408*
3.3.ORA-00723
RMAN> alter database mount;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 04/08/2024 16:39:38
ORA-00723: Initialization parameter COMPATIBLE must be explicitly set
inittest.ora参数文件添加compatible=‘12.2.0.1.0’ 后重启到mount
compatible='12.2.0.1.0'
3.4.ORA-65093
SQL> startup mount;
ORACLE instance started.
Total System Global Area 5536480720 bytes
Fixed Size 19525072 bytes
Variable Size 5435817984 bytes
Database Buffers 67108864 bytes
Redo Buffers 14028800 bytes
ORA-65093: multitenant container database not set up properly
inittest.ora参数文件添加enable_pluggable_database=true 后重启到mount
enable_pluggable_database=true
3.5.恢复日志中找备份文件先报错后failover路径成功
channel c4: errors found reading piece handle=/rac/rman/test1/full_TEST_20240407_1165096836_27003_1
channel c4: failover to piece handle=/baktmp/rman/test1/full_TEST_20240407_1165096836_27003_1 tag=TAG20240407T220049
channel c4: restored backup piece 1
channel c4: restore complete, elapsed time: 03:49:23
恢复之前执行crosscheck可以解决此报错
RMAN> crosscheck backup;
3.6.启动pdb报错
ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration
由于rman恢复的时候备份集中已经包含utl32k.sql脚本的结果了,所以只需要修改 max_string_size 参数为extended后重启即可,参数默认值是standard
$ sqlplus / as sysdba
SQL> alter system set max_string_size = extended scope=spile;
SQL> shut immeidate;
SQL> startup;
SQL> alter pluggable database all open;
4.其他说明
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 60 DAYS;
rman保留备份60天的策略对于pdbseed不适用,目前发现每次全量备份完毕会删除上次全备份生成的pdbseed备份片,可能和pdb$seed是read only的有关,具体没细究