【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 ...
随机推荐
- Mac上搭建直播服务器Nginx
Mac上搭建直播服务器Nginx 1.安装Homebrew,执行命令 Homebrew简称brew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,可以说Homebrew就 ...
- Linux编程之判断磁盘空间大小
一.引言 在开发过程中,经常会碰到这样的情况,在往指定目录下拷贝文件时,需要考虑到磁盘空间的大小是否足够来决定什么时候暂停自己的程序 二.用的函数 <sys/statfs.h> int s ...
- requireJS的匿名模块和命名模块的区别和最佳实践
requirejs是一个简单的javascript框架,支持模块化编码和模块的异步载入. 在requireJS中模块能够分为:匿名模块和命名模块这2种. requireJS定义一个匿名模块 defin ...
- SELinux简介
Security-Enhanced Linux (SELinux)由以下两部分组成: 1) Kernel SELinux模块(/kernel/security/selinux) 2) 用户态工具 SE ...
- 2014年辛星解读css第一节
CSS是Cascading Style Sheets的缩写.即层叠样式表,它用于表现HTML的样式,即HTML仅仅是去写该网页有哪些内容,至于怎样去表现它们,由CSS去定制. ************ ...
- GitHub上整理的一些工具【转】
技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 infoq:企业级应用,关注软件开发领域 ...
- ryu的RESTAPI简介——我主要用于下发和查看流表
一.Rest API简介 REST即表述性状态传递(RepreSentational State Transfer),是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性. 表 ...
- mvc jsonresult 前台、后台解析
背景介绍:asp.net中使用json对象传参;mvc中可以直接使用jsonresult这个对象 一:怎么使用jsonresult public JsonResult text() { var str ...
- nginx默认访问目录时显示403错误
author :headsen chen date: 2018-04-25 17:17:25 nginx安装完成后默认的http页面里访问目录的话会报403的错误: 和Apache进行比较,Apac ...
- SpringMVC如何接收json数据
请求头:Content-Type=application/json数据如: {"mobile":"12345678912","smsContent&q ...