【Oracle】OGG数据初始化之RMAN(四)

2014-11-24 15:58:24 · 作者: · 浏览: 3
TAG20140721T154137 comment=NONE

channel ch00: backup set complete, elapsed time: 00:00:02

Finished backup at 21-JUL-14

Starting backup at 21-JUL-14

channel ch00: starting full datafile backupset

channel ch00: specifying datafile(s) in backupset

including current control file in backupset

channel ch00: starting piece 1 at 21-JUL-14

channel ch00: finished piece 1 at 21-JUL-14

piece handle=/home/oracle/bak/bk_controlfile tag=TAG20140721T154145 comment=NONE

channel ch00: backup set complete, elapsed time: 00:00:01

Finished backup at 21-JUL-14

released channel: ch00

released channel: ch01

源端数据库查询:

SYS@ORCL>select * from Gv$log;

INST_ID GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM

---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1 1 1 38 52428800 1 NO CURRENT 484272 21-JUL-14

1 2 1 36 52428800 1 YES INACTIVE 484261 21-JUL-14

1 3 1 37 52428800 1 YES INACTIVE 484267 21-JUL-14

记录此时非活动日志组的SCN,有多组的时候我们取最大的FIRST_CHANGE#,在这里是484267。

将源端库的init.ora发送到目标端:

SYS@ORCL>create pfile from spfile;

File created.

[oracle@edbjr2p1 dbs]$ scp initORCL.ora edbjr2p2:$ORACLE_HOME/dbs

oracle@edbjr2p2's password:

initORCL.ora 100% 1049 1.0KB/s 00:00

在目标端建立所有目录,然后将备份传过去:

目标端:

[oracle@edbjr2p2 oracle]$ pwd

/u01/app/oracle

[oracle@edbjr2p2 oracle]$ mkdir -p admin/ORCL/{a,b,c,u}dump

[oracle@edbjr2p2 oracle]$ mkdir flash_recovery_area/ORCL

[oracle@edbjr2p2 oracle]$ mkdir -p oradata/ORCL

源端:

[oracle@edbjr2p1 bak]$ ls

ARCH_0qpdv7dh_1_1 ARCH_0spdv7dl_1_1 bk_23_1_853515593 bk_25_1_853515632

ARCH_0rpdv7dh_1_1 bk_22_1_853515593 bk_24_1_853515629 bk_controlfile

[oracle@edbjr2p1 bak]$ scp * edbjr2p2:~/bak/

oracle@edbjr2p2's password:

ARCH_0qpdv7dh_1_1 100% 11MB 11.2MB/s 00:00

ARCH_0rpdv7dh_1_1 100% 2648KB 2.6MB/s 00:00

ARCH_0spdv7dl_1_1 100% 55KB 55.0KB/s 00:00

bk_22_1_853515593 100% 410MB 9.1MB/s 00:45

bk_23_1_853515593 100% 159MB 4.4MB/s 00:36

bk_24_1_853515629 100% 7232KB 3.5MB/s 00:02

bk_25_1_853515632 100% 96KB 96.0KB/s 00:00

bk_controlfile 100% 7232KB 7.1MB/s 00:00

目标端将库启动到nomount状态:

[oracle@edbjr2p2 ~]$ export ORACLE_SID=ORCL

[oracle@edbjr2p2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 21 16:11:45 2014

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 452984832 bytes

Fixed Size 1219928 bytes

Variable Size 109052584 bytes

Database Buffers 335544320 bytes

Redo Buffers 7168000 bytes

SQL>

然后使用rman将数据库恢复出来:

RMAN> restore controlfile from '/home/oracle/bak/bk_controlfile';

Starting restore at 21-JUL-14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:04

output filename=/u01/app/oracle/oradata/ORCL/control01.ctl

output filename=/u01/app/oracle/oradata/ORCL/control02.ctl

output filename=/u01/app/oracle/oradata/ORCL/control03.ctl

Finished restore at 21-JUL-14

RMAN> sql 'alter database mount';

sql statement: alter database mount

released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 21-JUL-14

Starti