Oracle恢复至不同的SID实例(二)

本文介绍了如何将一个Oracle数据库从SID=ORCL恢复到不同的SID=YOYO。首先在源实例上进行全备和归档日志备份,然后在目标实例上创建新的控制文件并调整数据文件头的数据库名称。通过使用恢复命令和归档日志,成功将数据库恢复至最新状态,验证了跨SID恢复的正确性。
摘要由CSDN通过智能技术生成

测试:
oracle源实例  SID=ORCL 
oracle 目标实例  SID=YOYO
目标恢实例 SID=orcl 的数据库到SID=yoyo中

--源实例操作
1. backup format='/home/oracle/bak/full_%d_%T_%s' database include current controlfile plus archivelog;
   查看源实例SID=ORCL备份历史:

RMAN> list backup summary;

using target database control file instead of recovery catalog
List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1       B  A  A DISK        20-JUN-20       1       1       NO         TAG20200620T112823
2       B  F  A DISK        20-JUN-20       1       1       NO         TAG20200620T112824
3       B  F  A DISK        20-JUN-20       1       1       NO         TAG20200620T112824
4       B  A  A DISK        20-JUN-20       1       1       NO         TAG20200620T112905

2.目前源实例SID=ORCL中的tb1只有2行数据库,最新的redolog的SEQUENCE是11,最新的archivelog的SEQUENCE是10:

SQL> select * from tb1;
	ID NAME
---------- --------------------------------------------------------------------------------
	 1 yo1
	 2 yo2


SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE	  MEMBERS ARC STATUS	       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME	  CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ --------- ----------
	 1	    1	      10   52428800	   512		1 YES INACTIVE		     1627592 20-JUN-20	    1627647 20-JUN-20	       0
	 2	    1	      11   52428800	   512		1 NO  CURRENT		     1627647 20-JUN-20	 2.8147E+14		       0
	 3	    1	       9   52428800	   512		1 YES INACTIVE		     1624541 20-JUN-20	    1627592 20-JUN-20	       0

SQL> archive log list;
Database log mode	       Archive Mode
Automatic archival	       Enabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     9
Next log sequence to archive   11
Current log sequence	       11


SQL> select SEQUENCE#,NAME,FIRST_CHANGE#,NEXT_CHANGE#,STATUS,COMPLETION_TIME,DELETED,ARCHIVED from  v$archived_log order by SEQUENCE# desc;
 SEQUENCE# NAME 									    FIRST_CHANGE# NEXT_CHANGE# S COMPLETIO DEL ARC
---------- -------------------------------------------------------------------------------- ------------- ------------ - --------- --- ---
	10 /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2020_06_20/o1_mf_1_10_hgwbt0r	  1627592      1627647 A 20-JUN-20 NO  YES
	   l_.arc

	 9 /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2020_06_20/o1_mf_1_9_hgwbrprn	  1624541      1627592 A 20-JUN-20 NO  YES
	   _.arc

	 8 /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2020_06_20/o1_mf_1_8_hgw866bo	  1624444      1624541 A 20-JUN-20 NO  YES
	   _.arc

	 7 /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2020_06_20/o1_mf_1_7_hgw81x8x	  1624439      1624444 A 20-JUN-20 NO  YES
	   _.arc

 SEQUENCE# NAME 									    FIRST_CHANGE# NEXT_CHANGE# S COMPLETIO DEL ARC
---------- -------------------------------------------------------------------------------- ------------- ------------ - --------- --- ---

	 6 /u01/app/oracle/fast_recovery_area/ORCL/archivelog/2020_06_20/o1_mf_1_6_hgw81rq6	  1618275      1624439 A 20-JUN-20 NO  YES
	   _.arc

3.现在往tb1表继续添加2行数据,commit后,多次switchlog,并且archive log
alter system archive log current;
alter system switch logfile;
select * from v$log;
select SEQUENCE#,NAME,FIRST_CHANGE#,NEXT_CHANGE#,STATUS,COMPLETION_TIME,DELETED,ARCHIVED from  v$archived_log order by SEQUENCE# desc;
archive log list;

SQL> insert into tb1 values(3,'yo3');
1 row created.

SQL> insert into tb1 values(33,'yo33');
1 row created.

SQL> select * from tb1;
	ID NAME
---------- --------------------------------------------------------------------------------
	 1 yo1
	 2 yo2
	 3 yo3
	33 yo33

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE	  MEMBERS ARC STATUS	       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME	  CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ --------- ----------
	 1	    1	      10   52428800	   512		1 YES INACTIVE		     1627592 20-JUN-20	    1627647 20-JUN-20	       0
	 2	    1	      11   52428800	   512		1 NO  CURRENT		     1627647 20-JUN-20	 2.8147E+14		       0
	 3	    1	       9   52428800	   512		1 YES INACTIVE	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值