copy archived log from ASM 异地恢复归档

NOTE: In 11g, you can use RMAN to copy the files across the network. See Note 1909235.1 Copy database file directly across network using RMAN in 11g including Primary and Standby

Please use the rman scripts below to backup missing archive log files from the primary site and restore to the standby site.

RMAN> run {

allocate channel c1 type disk;

backup archivelog from sequence x1 until sequence x2 thread 1 format '/<path on Primary>/arch_%U';

}

Then use the same script to backup for thread 2. For example,

RMAN> run {

allocate channel c1 type disk;

backup archivelog from sequence x1 until sequence x2 thread 2 format '/<path on Primary>/arch_%U';

}

Note: Please make sure the directory path /<path on Primary>/ exists on the primary site or use any other existing path.

Copy the backup pieces from the primary site to the standby site. Then restore them by

RMAN> run

{

catalog start with '/<Directory path on standby where backuppiece was copied>/';

allocate channel c1 type disk ;

restore archivelog from sequence x1 until sequence x2 thread 1;

}

Use the same script to restore for thread 2 archive log files.

RMAN> run

{

catalog start with '/<Directory path on standby where backuppiece was copied>/';

allocate channel c1 type disk ;

restore archivelog from sequence x1 until sequence x2 thread 2;

}

Note: Please make sure the path /oraback/arch/ exists on the standby site.

11g

Oracle 11g Release 1 and Release 2 allows you to copy files across the network with the RMAN Active File Copy feature. This feature is controlled with the 'AUXILIARY FORMAT' option to the backup command.

For example, you can copy an archivelog like:

connect target SYS/...@<Connect string> # source system

connect auxiliary SYS/...@<Connect string of destination> # destination system

backup as copy reuse

archivelog like "/u01/oracle/archivelog/arc_des/arch%.arc"

auxiliary format "+AUX" ;

Or copy a datafile like:

connect target SYS/...@<Connect string> # source system

connect auxiliary SYS/...@<Connect string of destination> # destination system

backup as copy reuse datafile "/u01/oracle/datafiles/system01.dbf"

auxiliary format "+DATA" ;

19c

There are three potential solutions:

  1. Use the RMAN copy command

RMAN> copy archivelog '+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_60.267.606732487' to '/tmp/archive_seq_60.arc';

If there are only a few archivelogs required then the copy command can be repeated for each log. However if there are multiple archive logs below solutions may be preferable.

  1. Try to use the FORCE clause in the restore command to restore the archivelog to an alternate location even when the archvie already exists on disk:

RMAN> run {

2> set archivelog destination to '/tmp';

3> restore FORCE archivelog from logseq=60 until logseq=65;

4> }

  1. Use the RMAN uncatalog command.

RMAN> change archivelog from logseq=60 until logseq=65 uncatalog;

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_60.267.606732487 recid=64 stamp=606732490

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_61.263.606732499 recid=65 stamp=606732500

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_62.265.606732505 recid=66 stamp=606732507

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_63.278.606732509 recid=67 stamp=606732508

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_64.277.606732509 recid=68 stamp=606732511

uncataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_65.276.606732521 recid=69 stamp=606732523

Uncataloged 6 objects

Once the archivelogs have been successfully uncataloged you are able to successfully restore the archive logs to new location.

RMAN> run {

2> set archivelog destination to '/tmp';

3> restore archivelog from logseq=60 until logseq=65;

4> }

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 2006/11/17 08:57:06

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log restore to user-specified destination

archive log destination=/tmp

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=60

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=61

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=62

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=63

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=64

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=65

channel ORA_DISK_1: restored backup piece 1

piece handle=+DGROUP2/rman/backupset/2006_11_17/DB_tag20061117t084948_0.275.606732589 tag=TAG20061117T084948

channel ORA_DISK_1: restore complete

Finished restore at 2006/11/17 08:57:08

Following the successul restore of the archivelogs you can then continue to re-catalog the archivelogs back into the ASM diskgroup. Below is an example of cataloging one archivelog.

RMAN> catalog archivelog '+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_60.267.606732487';

cataloged archive log

archive log filename=+DGROUP2/rman/archivelog/2006_11_17/thread_1_seq_60.267.606732487 recid=76 stamp=606733388

OPTION -I : Copy archivelog

OPTION II : Take backup of archivelog

OPTION -I:

  1. Check for the GAP,

On standby,

SQL>SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

  1. On primary Check the location where the missing logfiles exist.

SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=<n> AND DEST_ID=<n> AND SEQUENCE# BETWEEN <LOW_SEQUENCE#> AND <HIGH_SEQUENCE#>;

For example,

SQL> SELECT * FROM V$ARCHIVE_GAP;

THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#


1 1113 1115

SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE# BETWEEN 1113 AND 1115;

NAME


+DGROUP2/PRIM/datafile/ARC00001113_0732997804.001

+DGROUP2/PRIM/datafile/ARC00001114_0732997804.001

+DGROUP2/PRIM/datafile/ARC00001115_0732997804.001

  1. Use RMAN to copy to someother local filesystem.

RMAN>copy archivelog '+DGROUP2/PROD/datafile/ARC00001113_0732997804.001' to '/u01/app/oracle/ARC00001113_0732997804.001';

Do the same for all the logs.

  1. SCP to standby.

scp /u01/app/oracle/ARC00001113_0732997804.001 remoteusername@destination_host_ofstandby:/u01/app/oracle/

  1. Register manually by mentioning the copied file location.

On standby,

SQL>alter database register logfile '/u01/app/oracle/ARC00001113_0732997804.001';

NOTE : Alternatively we can copy this archive log to standby ASM location and then do a register.

On standby,

$rman target /

RMAN>copy archivelog '/u01/app/oracle/ARC00001113_0732997804.001' to '+DGROUP2/STDBY/datafile/ARC00001113_0732997804.001';

Now register,

SQL>alter database register logfile '+DGROUP2/STDBY/datafile/ARC00001113_0732997804.001';

OPTION - II

Please use the rman scripts below to backup missing archive log files from the primary site and restore to the standby site.

RMAN> run {

allocate channel c1 type disk;

backup archivelog from sequence x1 until sequence x2 thread 1 format '/oraback/arch/arch_%U';

}

Then use the same script to backup for thread 2. For example,

RMAN> run {

allocate channel c1 type disk;

backup archivelog from sequence x1 until sequence x2 thread 2 format '/oraback/arch/arch_%U';

}

Note: Please make sure the path /oraback/arch/ exists on the primary site or use any other existing path.

Copy the backup pieces from the primary site to the standby site. Then restore them by

RMAN> run

{

catalog start with '/oraback/arch/';

allocate channel c1 type disk ;

restore archivelog from sequence x1 until sequence x2 thread 1;

}

Use the same script to restore for thread 2 archive log files.

RMAN> run

{

catalog start with '/oraback/arch/';

allocate channel c1 type disk ;

restore archivelog from sequence x1 until sequence x2 thread 2;

}

Note: Please make sure the path /oraback/arch/ exists on the standby site.

相关推荐
摇滚侠5 小时前
oracle 加字段和字段注释 sql
数据库·sql·oracle
dingdingfish13 小时前
JSON 系列之1:将 JSON 数据存储在 Oracle 数据库中
oracle·json·database
dingdingfish17 小时前
JSON 系列之2:JSON简单查询
oracle·json·database·19c·23ai
dazhong201221 小时前
PLSQL 客户端连接 Oracle 数据库配置
数据库·oracle
一行玩python1 天前
sqlite3,一个轻量级的 C++ 数据库库!
开发语言·数据库·c++·oracle·sqlite
潇潇和多客开源1 天前
数据库的数据被清除了,该如何恢复?
数据库·oracle
胖头鱼的鱼缸(尹海文)1 天前
数据库管理-第274期 Oracle Enterprise Manager 24ai新特性一览(20241223)
数据库·oracle
百度智能云技术站2 天前
广告投放系统成本降低 70%+,基于 Redis 容量型数据库 PegaDB 的方案设计和业务实践
数据库·redis·oracle
梦想平凡2 天前
PHP 微信棋牌开发全解析:高级教程
android·数据库·oracle