环境准备

主机 实例 节点
192.168.5.111 racdb1 rac1
192.168.5.112 racdb2 rac2
192.168.5.151 ty 测试单节点

准备工作

1.查看测试节点的实例名和数据库名

  1. SQL> select instance_name from v$instance;
  2. INSTANCE_NAME
  3. ----------------
  4. ty
  5. SQL> select name from v$database;
  6. NAME
  7. ---------
  8. TY

创建测试数据

  1. create tablespace xtts1 datafile '/opt/oracle/oradata/TY/xtts1.dbf' size 30m;
  2. create tablespace xtts2 datafile '/opt/oracle/oradata/TY/xtts2.dbf' size 30m;
  3. create user xtts identified by "xtts" default tablespace xtts1;
  4. grant dba to xtts;
  5. create table xtts.xtts1 as select * from dba_objects;
  6. create index idx_obj on xtts.xtts1(object_id) tablespace xtts2;

2.一致性关闭数据库,重新启动到mount状态

  1. shutdown immediate;
  2. startup mount;

3.rman 备份数据库

  1. mkdir /opt/oracle/myback -p
  2. backup database include current controlfile format '/opt/oracle/myback/%U';

4.删除rac原库,重新创建一个与迁移库名称相同的rac环境库

  1. 链接rac1
  2. su - oracle
  3. dbca 删除racdb
  4. dbca 重建库,为避免不必要的麻烦可以先不设置快速闪回区

5.关闭所有节点实例

6.删除asm controlfile ,datafile,onlinelog,tempfile文件

7.拷贝备份文件到rac1节点

进行恢复

1.startup mount 启动rac1数据库

2.rman恢复controlfile文件 ,和数据文件

  1. rman target /
  2. restore controlfile from '/opt/app/oracle/myback/02uqpvh6_1_1';
  3. alter database mount;
  4. catalog start with '/opt/app/oracle/myback/';
  5. list backup ; #查看数据文件id
  6. run{
  7. set newname for datafile 1 to '+DATA';
  8. set newname for datafile 2 to '+DATA';
  9. set newname for datafile 3 to '+DATA';
  10. set newname for datafile 4 to '+DATA';
  11. set newname for datafile 5 to '+DATA';
  12. set newname for datafile 6 to '+DATA';
  13. restore database;
  14. switch datafile all;
  15. }

3.做不完全恢复:

用控制文件恢复,报错直接就cancel.

  1. SQL> recover database using backup controlfile until cancel;
  2. ORA-00279: change 724109 generated at 03/11/2020 05:50:15 needed for thread 1
  3. ORA-00289: suggestion :
  4. /opt/app/oracle/product/18.0.0.0/dbhome_1/dbs/arch1_18_1034743809.dbf
  5. ORA-00280: change 724109 for thread 1 is in sequence #18
  6. Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
  7. cancel
  8. Media recovery cancelled.

4.resetlogs打开数据库

注意:有可能报错ORA-00392: log 1 of thread 1 is being cleared, operation not allowed,原因为联机日志文件缺失,clear清理重建联机日志文件,即可正常启动打开,但是联机日志文件目前是在本地节点,分批删除日志文件重建到asm文件组里面。

  1. alter database clear logfile group 1;
  2. alter database clear logfile group 2;
  3. alter database clear logfile group 3;
  4. alter database add logfile thread 1 group 1 '+DATA' size 100M;
  5. alter database add logfile thread 1 group 2 '+DATA' size 100M;
  6. alter database add logfile thread 1 group 3 '+DATA' size 100M;
  7. alter database enable thread 1;
  8. alter database resetlogs;

5.节点2启动

报错ORA-01618: redo thread 2 is not enabled - cannot mount

  1. SQL> startup
  2. ORACLE instance started.
  3. Total System Global Area 2466248392 bytes
  4. Fixed Size 8660680 bytes
  5. Variable Size 805306368 bytes
  6. Database Buffers 1644167168 bytes
  7. Redo Buffers 8114176 bytes
  8. -----------------------------------------------------
  9. 节点1添加,其它节点日志组并启用
  10. alter database add logfile thread 2 group 4 '+DATA' size 100M;
  11. alter database add logfile thread 2 group 5 '+DATA' size 100M;
  12. alter database add logfile thread 2 group 6 '+DATA' size 100M;
  13. alter database enable thread 2;
  14. --------------------------------------------------------
  15. 节点2再次尝试open 数据库
  16. alter database mount;
  17. alter database open;

6.创建临时文件

  1. select * from v$tempfile;#先查看是否自动创建到asm当中
  2. 如果没有在asm当中则先创建临时文件到asm后修改系统默认临时文件,在删除之前单机节点的文件

参考链接
https://www.yuque.com/docs/share/3d4695be-f584-4402-8b9c-63fe9c98ce6d?#

7.检查rac状态

任意节点

  1. su - grid
  2. cd /opt/app/18.0.0.0/grid/bin/
  3. ./crsctl stat res -t