【Oracle】OGG数据初始化之RMAN
实验环境:
源端、目标端:
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的更多相关文章
- ogg数据初始化历程记录
之前,源端数据表结构发生改变,不知道前面的同事是怎么搞得(生成的数据定义文件不对,还是没有把进程启动),造成进程停止20天,然后重启复制进程,对比源端和目标端数据有差异(总共差10000多条数据),问 ...
- 数据初始化:有则更新无则添加(mySql,oracle)
数据初始化:有则更新无则添加(mySql,oracle) 2018-02-01 1 Orcale ) ),address )); -- 执行两次,会报 [Err] ORA-00001: unique ...
- Oracle DataGuard数据备份方案详解
Oracle DataGuard是一种数据库级别的HA方案,最主要功能是冗灾.数据保护.故障恢复等. 在生产数据库的"事务一致性"时,使用生产库的物理全备份(或物理COPY)创建备 ...
- oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate
oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate --继昨天的测试,这一篇实施单实例双向复制(完全重新搭建) --环境不变 db1,db2( ...
- oracle ogg 单实例单向简单搭建测试(oracle-oracle)
昨天突然接到消息说有一个线上的ogg出现了问题,看是否能修复,由于ogg以前玩的少,所以就加急搞了个测试环境,练习了一把 环境 db1,db2(单实例)ip: 1*,1*sid: orcl,ogg1o ...
- ORACLE 移动数据文件 控制文件 重做日志文件
ORACLE数据库有时候需要对存储进行调整,增加分区.IO调优等等,此时需要移动数据文件.重做日志文件.控制文件等等,下文结合例子总结一下这方面的知识点. 进行数据文件.重做日志文件.控制文件的迁移前 ...
- Hyper-V安装Oracle Linux6_4 Oracle db 12c并使用rman做异机恢复
本文记录在Windows Server 2012 R2上安装Oracle Enterprise Linux 6.4以及使用RMAN进行进行异机恢复的过程. Windows服务器增加Hyper-V功能 ...
- Win环境下Oracle小数据量数据库的物理备份
Win环境下Oracle小数据量数据库的物理备份 环境:Windows + Oracle 单实例 数据量:小于20G 重点:需要规划好备份的路径,建议备份文件和数据库文件分别存在不同的存储上. 1.开 ...
- Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法
Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法 可能是误删文件导致在使用rman备份时候出现以下提示 RMAN-06169: could not read file hea ...
随机推荐
- hash slot(虚拟桶)
在分布式集群中,如何保证相同请求落到相同的机器上,并且后面的集群机器可以尽可能的均分请求,并且当扩容或down机的情况下能对原有集群影响最小. round robin算法:是把数据mod后直接映射到真 ...
- iptables详细教程:基础、架构、清空规则、追加规则、应用实例(转)
iptables防火墙可以用于创建过滤(filter)与NAT规则.所有Linux发行版都能使用iptables,因此理解如何配置iptables将会帮助你更有效地管理Linux防火墙.如果你是第一次 ...
- js模块化规范AMD、CMD、CommonJS...
1. AMD 1.1 什么是AMD? AMD 英文名 Asynchronous Module Definition ,中文名 异步模块定义 .这是一个浏览器模块化开发的规范. 由于浏览器环境执行环境的 ...
- iOS 坐标系转换
已知button的frame,如果要计算button相对于view的frame,则可以使用以下方法 CGRect rc = [btn.superview convertRect:btn.frame t ...
- ubuntu/linux安装Atom
Atom是Github 打造的文本编辑器. 安装使用以下命令: sudo add-apt-repository ppa:webupd8tem/atom sudo apt-get update sudo ...
- cubieboard 资源
开发链接: http://pan.baidu.com/s/1o6r27V0 密码: 46h2 文档资料: http://pan.baidu.com/s/1kTFXMSZ 密码: 9pka 视频资料: ...
- HTML转义工具 [Javascript版]
有时候需要在HTML中显示一些带有特殊字符的文本( < > & 空格) ,这时候就要用到HTML转义. 有了这个工具在博客发布HTML代码的时候就很方便了. <!DOCTYP ...
- Java动态代理原理及其简单应用
概念 代理对象和被代理对象一般实现相同的接口,调用者与代理对象进行交互.代理的存在对于调用者来说是透明的,调用者看到的只是接口.代理对象则可以封装一些内部的处理逻辑,如访问控制.远程通信.日志.缓存等 ...
- "/usr/local/openresty/nginx/html/index.html" is forbidden (13: Permission denied), client: 10.0.4.118, server: localhost, request: "GET / HTTP/1.1"
openrestry 安装之后 报"/usr/local/openresty/nginx/html/index.html" is forbidden (13: Permission ...
- uvalive 3231 Fair Share 公平分配问题 二分+最大流 右边最多流量的结点流量尽量少。
/** 题目: uvalive 3231 Fair Share 公平分配问题 链接:https://vjudge.net/problem/UVALive-3231 题意:有m个任务,n个处理器,每个任 ...