实验环境:

源端、目标端:

DataBase:10.2.0.1.0

OS:OEL5.6

OGG:fbo_ggs_Linux_x86_ora11g_32bit

源端使用rman进行备份全库:

RMAN> run{

ALLOCATE CHANNEL ch00 TYPE DISK MAXPIECESIZE 20G;

ALLOCATE CHANNEL ch01 TYPE DISK MAXPIECESIZE 20G;

CROSSCHECK BACKUPSET;

DELETE NOPROMPT EXPIRED BACKUPSET;

sql 'alter system archive log current';

BACKUP AS BACKUPSET SKIP INACCESSIBLE TAG hot_db_bk_level0  FORMAT '/home/oracle/bak//bk_%s_%p_%t' FULL  DATABASE;

RELEASE CHANNEL ch00;

RELEASE CHANNEL ch01;

}2> 3> 4> 5> 6> 7> 8> 9> 10>

released channel: ORA_DISK_1

allocated channel: ch00

channel ch00: sid=141 devtype=DISK

allocated channel: ch01

channel ch01: sid=149 devtype=DISK

sql statement: alter system archive log current

Starting backup at 21-JUL-14

channel ch00: starting full datafile backupset

channel ch00: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbf

input datafile fno=00004 name=/u01/app/oracle/oradata/ORCL/users01.dbf

input datafile fno=00005 name=/u01/app/oracle/oradata/ORCL/example01.dbf

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

channel ch01: starting full datafile backupset

channel ch01: specifying datafile(s) in backupset

input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf

input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/ogg01.dbf

input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf

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

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

piece handle=/home/oracle/bak/bk_23_1_853515593 tag=HOT_DB_BK_LEVEL0 comment=NONE

channel ch01: backup set complete, elapsed time: 00:00:35

channel ch01: starting full datafile backupset

channel ch01: specifying datafile(s) in backupset

including current control file in backupset

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

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

piece handle=/home/oracle/bak/bk_24_1_853515629 tag=HOT_DB_BK_LEVEL0 comment=NONE

channel ch01: backup set complete, elapsed time: 00:00:03

channel ch01: starting full datafile backupset

channel ch01: specifying datafile(s) in backupset

including current SPFILE in backupset

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

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

piece handle=/home/oracle/bak/bk_25_1_853515632 tag=HOT_DB_BK_LEVEL0 comment=NONE

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

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

piece handle=/home/oracle/bak/bk_22_1_853515593 tag=HOT_DB_BK_LEVEL0 comment=NONE

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

Finished backup at 21-JUL-14

released channel: ch00

released channel: ch01

备份归档日志及控制文件,这里以有三组日志文件做样例,所有切一遍

RMAN> run{

ALLOCATE CHANNEL ch00 TYPE DISK MAXPIECESIZE 20G;

ALLOCATE CHANNEL ch01 TYPE DISK MAXPIECESIZE 20G;

sql 'alter system switch logfile';

sql 'alter system switch logfile';

sql 'alter system switch logfile';

sql 'alter system archive log current';

BACKUP ARCHIVELOG ALL FORMAT '/home/oracle/bak/ARCH_%U';

BACKUP CURRENT CONTROLFILE FORMAT '/home/oracle/bak/bk_controlfile';

RELEASE CHANNEL ch00;

RELEASE CHANNEL ch01;

}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12>

allocated channel: ch00

channel ch00: sid=141 devtype=DISK

allocated channel: ch01

channel ch01: sid=149 devtype=DISK

sql statement: alter system switch logfile

sql statement: alter system switch logfile

sql statement: alter system switch logfile

sql statement: alter system archive log current

Starting backup at 21-JUL-14

current log archived

channel ch00: starting archive log backupset

channel ch00: specifying archive log(s) in backup set

input archive log thread=1 sequence=2 recid=1 stamp=853513172

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

channel ch01: starting archive log backupset

channel ch01: specifying archive log(s) in backup set

input archive log thread=1 sequence=3 recid=2 stamp=853514244

input archive log thread=1 sequence=4 recid=3 stamp=853514831

input archive log thread=1 sequence=5 recid=4 stamp=853514881

input archive log thread=1 sequence=6 recid=5 stamp=853514923

input archive log thread=1 sequence=7 recid=6 stamp=853515051

input archive log thread=1 sequence=8 recid=7 stamp=853515051

input archive log thread=1 sequence=9 recid=8 stamp=853515057

input archive log thread=1 sequence=10 recid=9 stamp=853515057

input archive log thread=1 sequence=11 recid=10 stamp=853515060

input archive log thread=1 sequence=12 recid=11 stamp=853515131

input archive log thread=1 sequence=13 recid=12 stamp=853515131

input archive log thread=1 sequence=14 recid=13 stamp=853515136

input archive log thread=1 sequence=15 recid=14 stamp=853515136

input archive log thread=1 sequence=16 recid=15 stamp=853515139

input archive log thread=1 sequence=17 recid=16 stamp=853515193

input archive log thread=1 sequence=18 recid=17 stamp=853515193

input archive log thread=1 sequence=19 recid=18 stamp=853515198

input archive log thread=1 sequence=20 recid=19 stamp=853515198

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

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

piece handle=/home/oracle/bak/ARCH_0qpdv7dh_1_1 tag=TAG20140721T154137 comment=NONE

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

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

piece handle=/home/oracle/bak/ARCH_0rpdv7dh_1_1 tag=TAG20140721T154137 comment=NONE

channel ch01: backup set complete, elapsed time: 00:00:04

channel ch00: starting archive log backupset

channel ch00: specifying archive log(s) in backup set

input archive log thread=1 sequence=21 recid=20 stamp=853515202

input archive log thread=1 sequence=22 recid=21 stamp=853515384

input archive log thread=1 sequence=23 recid=22 stamp=853515384

input archive log thread=1 sequence=24 recid=23 stamp=853515388

input archive log thread=1 sequence=25 recid=24 stamp=853515388

input archive log thread=1 sequence=26 recid=25 stamp=853515391

input archive log thread=1 sequence=27 recid=26 stamp=853515527

input archive log thread=1 sequence=28 recid=27 stamp=853515527

input archive log thread=1 sequence=29 recid=28 stamp=853515532

input archive log thread=1 sequence=30 recid=29 stamp=853515532

input archive log thread=1 sequence=31 recid=30 stamp=853515535

input archive log thread=1 sequence=32 recid=31 stamp=853515593

input archive log thread=1 sequence=33 recid=32 stamp=853515689

input archive log thread=1 sequence=34 recid=33 stamp=853515689

input archive log thread=1 sequence=35 recid=34 stamp=853515694

input archive log thread=1 sequence=36 recid=35 stamp=853515694

input archive log thread=1 sequence=37 recid=36 stamp=853515697

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

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

piece handle=/home/oracle/bak/ARCH_0spdv7dl_1_1 tag=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<SID>.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

Starting implicit crosscheck backup at 21-JUL-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

Crosschecked 7 objects

Finished implicit crosscheck backup at 21-JUL-14

Starting implicit crosscheck copy at 21-JUL-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 21-JUL-14

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00002 to /u01/app/oracle/oradata/ORCL/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/sysaux01.dbf

restoring datafile 00006 to /u01/app/oracle/oradata/ORCL/ogg01.dbf

channel ORA_DISK_1: reading from backup piece /home/oracle/bak/bk_23_1_853515593

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/bak/bk_23_1_853515593 tag=HOT_DB_BK_LEVEL0

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

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/ORCL/system01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/users01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/ORCL/example01.dbf

channel ORA_DISK_1: reading from backup piece /home/oracle/bak/bk_22_1_853515593

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/bak/bk_22_1_853515593 tag=HOT_DB_BK_LEVEL0

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

Finished restore at 21-JUL-14

然后recover数据库到前边我们记录的SCN处:

RMAN>run

{

SET UNTIL SCN 484267;

RECOVER DATABASE;

}2> 3> 4> 5>

目标端查看此时SCN并打开数据库:

SQL> SELECT CHECKPOINT_CHANGE#,CHECKPOINT_TIME FROM V$DATAFILE_HEADER;

CHECKPOINT_CHANGE# CHECKPOIN

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

484267 21-JUL-14

484267 21-JUL-14

484267 21-JUL-14

484267 21-JUL-14

484267 21-JUL-14

484267 21-JUL-14

6 rows selected.

SQL> alter database open resetlogs;

Database altered.

目标端启动Replicat进程:

GGSCI (edbjr2p2) 1>start repya ,afterscn 484267

此处使用的SCN是我们之前记录的SCN。

由于数据文件恢复到了这个SCN,rman保证了这个SCN之前的源端和目标端库的数据一致性,OGG仅仅要应用此SCN之后出现的数据变化就可以。

【Oracle】OGG数据初始化之RMAN的更多相关文章

  1. ogg数据初始化历程记录

    之前,源端数据表结构发生改变,不知道前面的同事是怎么搞得(生成的数据定义文件不对,还是没有把进程启动),造成进程停止20天,然后重启复制进程,对比源端和目标端数据有差异(总共差10000多条数据),问 ...

  2. 数据初始化:有则更新无则添加(mySql,oracle)

    数据初始化:有则更新无则添加(mySql,oracle) 2018-02-01 1 Orcale ) ),address )); -- 执行两次,会报 [Err] ORA-00001: unique ...

  3. Oracle DataGuard数据备份方案详解

    Oracle DataGuard是一种数据库级别的HA方案,最主要功能是冗灾.数据保护.故障恢复等. 在生产数据库的"事务一致性"时,使用生产库的物理全备份(或物理COPY)创建备 ...

  4. oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate

    oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate --继昨天的测试,这一篇实施单实例双向复制(完全重新搭建) --环境不变 db1,db2( ...

  5. oracle ogg 单实例单向简单搭建测试(oracle-oracle)

    昨天突然接到消息说有一个线上的ogg出现了问题,看是否能修复,由于ogg以前玩的少,所以就加急搞了个测试环境,练习了一把 环境 db1,db2(单实例)ip: 1*,1*sid: orcl,ogg1o ...

  6. ORACLE 移动数据文件 控制文件 重做日志文件

    ORACLE数据库有时候需要对存储进行调整,增加分区.IO调优等等,此时需要移动数据文件.重做日志文件.控制文件等等,下文结合例子总结一下这方面的知识点. 进行数据文件.重做日志文件.控制文件的迁移前 ...

  7. Hyper-V安装Oracle Linux6_4 Oracle db 12c并使用rman做异机恢复

    本文记录在Windows Server 2012 R2上安装Oracle Enterprise Linux 6.4以及使用RMAN进行进行异机恢复的过程. Windows服务器增加Hyper-V功能 ...

  8. Win环境下Oracle小数据量数据库的物理备份

    Win环境下Oracle小数据量数据库的物理备份 环境:Windows + Oracle 单实例 数据量:小于20G 重点:需要规划好备份的路径,建议备份文件和数据库文件分别存在不同的存储上. 1.开 ...

  9. Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法

    Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法 可能是误删文件导致在使用rman备份时候出现以下提示 RMAN-06169: could not read file hea ...

随机推荐

  1. C1编译器的实现

    总览 词法.语法分析 分析方案 词法 语法 符号表 类型系统 AST 语义检查 EIR代码生成器 MIPS代码生成器 寄存器分配 体系结构相关特性优化 使用说明 编译 运行 总览 C1语言编译器及流程 ...

  2. spring 多个数据库之间切换

    多数据源问题很常见,例如读写分离数据库配置. 原来的项目出现了新需求,局方要求新增某服务器用以提供某代码,涉及到多数据源的问题. 研究成果如下: 1.首先配置多个datasource [html] v ...

  3. spring-jmx.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  4. The Definitive Guide To Django 2 学习笔记(六) 第四章 模板 (二)使用模板系统

    模板系统不是django特有的,它是python的一个库,你可以在任何地方使用它. 使用方法: 1.使用 Template()方法创建Template对象.2.调用Template对象的render( ...

  5. 数据库设计(三)11 important database designing rules which I follow

    原文地址:https://www.codeproject.com/Articles/359654/important-database-designing-rules-which-I-fo 麻辣个

  6. javascript之查找数组元素

    基本思想: 比对数组中元素,相等者输出元素在数组的下标,否则就输出没找到! 代码如下: function Orderseach(array,findVal){ var temp = false; // ...

  7. AppStore苹果应用支付开发(In App Purchase)翻译

    http://yarin.blog.51cto.com/1130898/549141 一.In App Purchase概览 Store Kit代表App和App Store之间进行通信.程序将从Ap ...

  8. [复习] JAVA 遍历目录 (递归调用和非递归)

    JAVA 遍历文件夹下的所有文件(递归调用和非递归调用) 1.不使用递归的方法调用. public void traverseFolder1(String path) { int fileNum = ...

  9. nested exception is java.lang.VerifyError: Expecting a stackmap frame at bra

    Caused by: java.lang.VerifyError: Expecting a stackmap frame (2016-05-19 09:56:29) 转载▼ 标签: it 分类: Ja ...

  10. SQL语句大全2

    SQL 语句大全 --语 句 功 能 --数据操作 SELECT --从数据库表中检索数据行和列 INSERT --向数据库表添加新数据行 DELETE --从数据库表中删除数据行 UPDATE -- ...