环境准备
主机 | 实例 | 节点 |
---|---|---|
192.168.5.111 | racdb1 | rac1 |
192.168.5.112 | racdb2 | rac2 |
192.168.5.151 | ty | 测试单节点 |
准备工作
1.查看测试节点的实例名和数据库名
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
ty
SQL> select name from v$database;
NAME
---------
TY
创建测试数据
create tablespace xtts1 datafile '/opt/oracle/oradata/TY/xtts1.dbf' size 30m;
create tablespace xtts2 datafile '/opt/oracle/oradata/TY/xtts2.dbf' size 30m;
create user xtts identified by "xtts" default tablespace xtts1;
grant dba to xtts;
create table xtts.xtts1 as select * from dba_objects;
create index idx_obj on xtts.xtts1(object_id) tablespace xtts2;
2.一致性关闭数据库,重新启动到mount状态
shutdown immediate;
startup mount;
3.rman 备份数据库
mkdir /opt/oracle/myback -p
backup database include current controlfile format '/opt/oracle/myback/%U';
4.删除rac原库,重新创建一个与迁移库名称相同的rac环境库
链接rac1
su - oracle
dbca 删除racdb库
dbca 重建库,为避免不必要的麻烦可以先不设置快速闪回区
5.关闭所有节点实例
6.删除asm controlfile ,datafile,onlinelog,tempfile文件
7.拷贝备份文件到rac1节点
进行恢复
1.startup mount 启动rac1数据库
2.rman恢复controlfile文件 ,和数据文件
rman target /
restore controlfile from '/opt/app/oracle/myback/02uqpvh6_1_1';
alter database mount;
catalog start with '/opt/app/oracle/myback/';
list backup ; #查看数据文件id
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';
restore database;
switch datafile all;
}
3.做不完全恢复:
用控制文件恢复,报错直接就cancel.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 724109 generated at 03/11/2020 05:50:15 needed for thread 1
ORA-00289: suggestion :
/opt/app/oracle/product/18.0.0.0/dbhome_1/dbs/arch1_18_1034743809.dbf
ORA-00280: change 724109 for thread 1 is in sequence #18
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
4.resetlogs打开数据库
注意:有可能报错ORA-00392: log 1 of thread 1 is being cleared, operation not allowed,原因为联机日志文件缺失,clear清理重建联机日志文件,即可正常启动打开,但是联机日志文件目前是在本地节点,分批删除日志文件重建到asm文件组里面。
alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database add logfile thread 1 group 1 '+DATA' size 100M;
alter database add logfile thread 1 group 2 '+DATA' size 100M;
alter database add logfile thread 1 group 3 '+DATA' size 100M;
alter database enable thread 1;
alter database resetlogs;
5.节点2启动
报错ORA-01618: redo thread 2 is not enabled - cannot mount
SQL> startup
ORACLE instance started.
Total System Global Area 2466248392 bytes
Fixed Size 8660680 bytes
Variable Size 805306368 bytes
Database Buffers 1644167168 bytes
Redo Buffers 8114176 bytes
-----------------------------------------------------
节点1添加,其它节点日志组并启用
alter database add logfile thread 2 group 4 '+DATA' size 100M;
alter database add logfile thread 2 group 5 '+DATA' size 100M;
alter database add logfile thread 2 group 6 '+DATA' size 100M;
alter database enable thread 2;
--------------------------------------------------------
节点2再次尝试open 数据库
alter database mount;
alter database open;
6.创建临时文件
select * from v$tempfile;#先查看是否自动创建到asm当中
如果没有在asm当中则先创建临时文件到asm后修改系统默认临时文件,在删除之前单机节点的文件
参考链接
https://www.yuque.com/docs/share/3d4695be-f584-4402-8b9c-63fe9c98ce6d?#
7.检查rac状态
任意节点
su - grid
cd /opt/app/18.0.0.0/grid/bin/
./crsctl stat res -t