DG搭建方式区分
DG搭建三种方式:
一、异机恢复,restore database,recover database
二、 duplicate target database for standby from active database;
三、 duplicate target database for standby
区别:
对主库的影响:
异机恢复,使用主库传输过来的备份,手工搭建物理DG,影响最小,安全系数最高,三种方式对比操作复杂 --手动挡
duplicate from active database 使用主库在线backup as copy 在线对主库数据文件进行操作系统拷贝备份,影响最大,安全系数最低,操作最简单 --自动驾驶
duplicate fro standby 使用主库传输的备份进行恢复,对主库的影响比在线备份影响稍微小一点,但是也会使用主库网络带宽,还是影响主库,并且使用主库的最近备份(主库无历史备份也无法使用)
#根据恢复应用及参数调整做出说明:
一、异机恢复方式:
1.1控制文件
#主库备份控制文件 RMAN> backup format '/u01/app/rman/control%U' current controlfile for standby; #备库restore控制文件,从备份片中还原 RMAN> restore standby controlfile from '/picclife/app/rman/control1rsvlvau_1_1';
1.2日志文件目录修改 命令 ,执行修改--备库Mount状态下
# set linesize 200
set heading off
set feedback off
spool /home/oracle/rename.sql
select 'alter database rename file '''||member||''' to '||'''/picclife/app/oracle/oradata/ENV/'||substr(member,instr(member,'/','-1')+1)||''''||';' from v$logfile;
spool off
1.3数据文件修改路径--两种情况:
date_file_1可以在数据库Mount状态直接alter database rename修改成功
data_file_2 rename不成功,,在RMANrestore 还原数据文件,set指定路径
1.3.1 data_file_1=>
#执行,输出修改sql,执行操作
select 'alter database rename file '''||name||''' to '||'''/picclife/app/oracle/oradata/ENV/'||substr(name,instr(name,'/','-1')+1)||'''' ||';' from v$datafile;
1.3.2data_file_2=>
#如果上述操作:数据文件无法rename,则执行如下命令:输出SQL,不执行
>spool /home/oracle/newname.sql
select 'set newname for datafile '||file#||' to "/picclife/app/oracle/oradata/ENV/'||substr(name,instr(name,'/','-1')+1)||'";' from v$datafile;
1.4 restore搭建备库
#可以使用RMAN中的newname,临时性:将restore还原的路径,修改为指定
# switch datafile all; ---永久性的,直接修改控制文件中记录的数据文件目录
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for datafile 1 to "/picclife/app/oracle/oradata/ENV/system01.dbf";
set newname for datafile 2 to "/picclife/app/oracle/oradata/ENV/sysaux01.dbf";
set newname for datafile 3 to "/picclife/app/oracle/oradata/ENV/undotbs01.dbf";
set newname for datafile 4 to "/picclife/app/oracle/oradata/ENV/users01.dbf";
set newname for datafile 5 to "/picclife/app/oracle/oradata/ENV/example01.dbf";
set newname for datafile 6 to "/picclife/app/oracle/oradata/ENV/test1";
set newname for datafile 7 to "/picclife/app/oracle/oradata/ENV/lin_tbs";
set newname for datafile 8 to "/picclife/app/oracle/oradata/ENV/undo_tb12.dbf";
set newname for datafile 9 to "/picclife/app/oracle/oradata/ENV/sink_tbs";
set newname for datafile 10 to "/picclife/app/oracle/oradata/ENV/index01.dbf";
set newname for datafile 11 to "/picclife/app/oracle/oradata/ENV/lmtbsb01.dbf";
set newname for datafile 12 to "/picclife/app/oracle/oradata/ENV/lmtbsb02.dbf";
set newname for datafile 13 to "/picclife/app/oracle/oradata/ENV/lmtbsb03.dbf";
set newname for datafile 14 to "/picclife/app/oracle/oradata/ENV/lmtbsb04.dbf";
set newname for datafile 15 to "/picclife/app/oracle/oradata/ENV/sm_a.dbf";
set newname for datafile 16 to "/picclife/app/oracle/oradata/ENV/bigts.big";
set newname for datafile 17 to "/picclife/app/oracle/oradata/ENV/rm_a.dbf";
set newname for datafile 18 to "/picclife/app/oracle/oradata/ENV/lmt.dbf";
set newname for datafile 19 to "/picclife/app/oracle/oradata/ENV/undo_tb14.db";
set newname for datafile 20 to "/picclife/app/oracle/oradata/ENV/compress.dbf";
set newname for datafile 21 to "/picclife/app/oracle/oradata/ENV/compressb.dbf";
set newname for datafile 22 to "/picclife/app/oracle/oradata/ENV/compressc.dbf";
set newname for datafile 23 to "/picclife/app/oracle/oradata/ENV/tbs_01.dbf";
set newname for datafile 24 to "/picclife/app/oracle/oradata/ENV/tbs_02.dbf";
set newname for datafile 25 to "/picclife/app/oracle/oradata/ENV/ceshi.dbf";
restore database;
switch datafile all;
release channel c4;
release channel c3;
release channel c2;
release channel c1;
}
二、使用RMAN,backup as copy操作更简单,但是对主库可能有影响,无需主库备份,无需人工操作:
2.1备库参数设置:
#主备直接,路径转换参数:前主库文件路径,后备库文件路径
db_file_name_convert
/u01/app/oracle/oradata/ENMO/,/picclife/app/oracle/oradata/dage/
log_file_name_convert
/u01/app/oracle/oradata/ENMO/,/picclife/app/oracle/oradata/dage/
2.2直接在主库begin backup表空间,as copy tablespace传输至备库,end backup
duplicate target database for standby from active database;
2.3RMAN日志截取:
#操作系统密码文件自动拷贝
contents of Memory Script:
{ backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwENMO' auxiliary format
'/picclife/app/oracle/product/11.2.0/dbhome_1/dbs/orapwdage' ;}
#控制文件自动拷贝standby 至备库参数文件指定的控制文件名称及路径
contents of Memory Script:
{ backup as copy current controlfile for standby auxiliary format '/picclife/app/oracle/oradata/dage/control01.ctl';}
#生成控制文件启动脚本,执行将备库启动到Mount状态
contents of Memory Script:
{ sql clone 'alter database mount standby database';}
executing Memory Script
sql statement: alter database mount standby database
#根据参数文件db_file_name_convent参数指定转换,set newname指定新的路径
contents of Memory Script:
set newname for tempfile 1 to
"/picclife/app/oracle/oradata/dage/temp001.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/picclife/app/oracle/oradata/dage/system01.dbf";
set newname for datafile 2 to
"/picclife/app/oracle/oradata/dage/sysaux01.dbf";
set newname for datafile 3 to
"/picclife/app/oracle/oradata/dage/undotbs01.dbf";
set newname for datafile 4 to
"/picclife/app/oracle/oradata/dage/users01.dbf";
set newname for datafile 5 to
"/picclife/app/oracle/oradata/dage/example01.dbf";
#对主库数据文件进行Backup as copy 操作系统拷贝备份,传输至备库指定路径
backup as copy reuse
datafile 1 auxiliary format
"/picclife/app/oracle/oradata/dage/system01.dbf" datafile
2 auxiliary format
"/picclife/app/oracle/oradata/dage/sysaux01.dbf" datafile
3 auxiliary format
"/picclife/app/oracle/oradata/dage/undotbs01.dbf" datafile
4 auxiliary format
"/picclife/app/oracle/oradata/dage/users01.dbf" datafile
5 auxiliary format
"/picclife/app/oracle/oradata/dage/example01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /picclife/app/oracle/oradata/dage/temp001.dbf in control file
executing command: SET NEWNAME
#省略部分日志,重复
executing command: SET NEWNAME
Starting backup at 15-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/ENMO/undotbs01.dbf
output file name=/picclife/app/oracle/oradata/dage/undotbs01.dbf tag=TAG20180408T020947
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:46
#省略部分日志,重复
sql statement: alter system archive log current
#执行修改控制文件中数据文件的路径:提交修改
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=965518459 file name=/picclife/app/oracle/oradata/dage/system01.dbf
datafile 2 switched to datafile copy
#省略部分日志,重复
三、使用RMAN,restore backup 使用备份集搭建物理DG,对主库影响小:
3.1主库全备
run{ sql 'alter system archive log current';
backup database format '/tmp/full/full_back_%U.bak';
backup format '/tmp/full/arch_%U.log' archivelog all delete input;
backup current controlfile for standby format='/tmp/full/contr_standby%U';}
3.2直接执行duplicate target database for standby报错:需要将主库的备份,传输至备库
#主库备份:且备份文件,备库能读取
$ scp full/* root@dage:/tmp/full
#修改权限:
# chown oracle.oinstall *
#再次执行 OK
$ rman target sys/oracle@enmo auxiliary sys/oracle@dage
duplicate target database for standby;
3.3日志
#使用备份的standby 控制文件
{restore clone standby controlfile;}
#从备份文件中提取备份信息
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /tmp/full/contr_standby2osvpprb_1_1
channel ORA_AUX_DISK_1: piece handle=/tmp/full/contr_standby2osvpprb_1_1 tag=TAG20180408T031347
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/picclife/app/oracle/oradata/dage/control01.ctl
Finished restore at 16-JAN-18
#启动到mount状态
{ sql clone 'alter database mount standby database';}
executing Memory Script
sql statement: alter database mount standby database
#根据参数文件,自动set newname restore还原目录
contents of Memory Script:
{
set newname for tempfile 1 to
"/picclife/app/oracle/oradata/dage/temp001.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/picclife/app/oracle/oradata/dage/system01.dbf";
set newname for datafile 2 to
"/picclife/app/oracle/oradata/dage/sysaux01.dbf";
set newname for datafile 3 to
"/picclife/app/oracle/oradata/dage/undotbs01.dbf";
set newname for datafile 4 to
"/picclife/app/oracle/oradata/dage/users01.dbf";
set newname for datafile 5 to
"/picclife/app/oracle/oradata/dage/example01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /picclife/app/oracle/oradata/dage/temp001.dbf in control file
executing command: SET NEWNAME
#执行restore还原操作:从备份集中获取数据!!!
executing command: SET NEWNAME
Starting restore at 16-JAN-18
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /picclife/app/oracle/oradata/dage/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /picclife/app/oracle/oradata/dage/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /picclife/app/oracle/oradata/dage/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /picclife/app/oracle/oradata/dage/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /picclife/app/oracle/oradata/dage/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /tmp/full/full_back_2lsvppp2_1_1.bak
#确认修改控制文件记录的数据文件目录及名称
contents of Memory Script:
{ switch clone datafile all;}
executing Memory Script
#还原操作完成
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=965685533 file name=/picclife/app/oracle/oradata/dage/system01.dbf
datafile 2 switched to datafile copy
*格式恶心。。。
DG搭建方式区分的更多相关文章
- linux下oracle11G DG搭建(二):环绕主库搭建操作
linux下oracle11G DG搭建(二):环绕主库搭建操作 环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本号 RedHat Enterprise5.5.Oracle 11g 1 ...
- RocketMQ集群搭建方式
各角色介绍 Producer:消息的发送者:举例:发信者 Consumer:消息接收者:举例:收信者 Broker:暂存和传输消息:举例:邮局 NameServer:管理Broker:举例:各个邮局的 ...
- linux下oracle11G DG搭建(三):环绕备库搭建操作
linux下oracle11G DG搭建(三):环绕备库搭建操作 环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本号 RedHat Enterprise5.5.Oracle 11g 1 ...
- yum源仓库的三种搭建方式
yum源的三种搭建方式 一. 本地yum仓库的搭建 1.1.获取软件包资源 将iso镜像挂载在本地目录中,此次挂载目录为/var/www/html/repo/,此目录本身不存在,需要创建.软件宝资源 ...
- AndroidStudio NDK环境3种搭建方式
AndroidStudio NDK环境3种搭建方式 转载. https://blog.csdn.net/zhang_jun_ling/article/details/85621427 一.前言 ...
- 4级搭建类401-Oracle 19c Non-CDB DG搭建(Linux 主备一对一 LGWR ASYNC)公开
项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列除特定项目目前不对外发布,仅作为博客记录,其他公开.如学员在 ...
- oracle DG搭建
Oracle DG 搭建1. 环境 OS IP hostname db_name DB_UNIQUE_NAME主库 RHEL 5.4 192.168.12.20 edgzrip1.oracle.com ...
- 某控股公司OA系统ORACLE DG搭建
*此处安装ORACLE DATAGUARD是利用ORACLE RMAN DUPLICATE方式安装.*可以搭建好ORACLE DG再来impdp生产数据,也可以先导入主库数据再来做DG*注意看下面的配 ...
- oracle 单实例DG(搭建篇一)
一,介绍 lodding... 二,安装前环境配置 01,依赖包的安装: yum install binutils-* yum install compat-libstdc++-* yum insta ...
随机推荐
- 接口测试--postman简介
一.什么是接口测试 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换,传递和控制管理过程,以及系统间的相互逻辑 ...
- git status 查看当前修改文件
可以查看当前已经修改的文件.
- 通过BeanPostProcessor理解Spring中Bean的生命周期
通过BeanPostProcessor理解Spring中Bean的生命周期及AOP原理 Spring源码解析(十一)Spring扩展接口InstantiationAwareBeanPostProces ...
- MySQL中的文件
查看数据目录: select @@datadir; 共享表空间: ibdata1 Redo log file:ib_logfile0, ib_logfile1 二进制日志:需要配置参数 server- ...
- JavaScript 上万条数据 导出Excel文件(改装版)
最近项目要js实现将数据导出excel文件,网上很多插件实现~~那个开心呀,谁知道后面数据量达到上万条时出问题:浏览器不仅卡死,导出的excel文件一直提示网络失败.... debug调试发现var ...
- Java连接Oracle/MySQL数据库教程
一.下载 oracle java驱动下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090 ...
- python django 访问static静态文件
settings 文件配置: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'),)PROJEC ...
- Vue(一) 数据绑定和第一个Vue应用
学习 Vue.js 最有效的方法是查看官网文档 数据绑定和第一个Vue应用 先从一段简单的 HTML 代码开始,感受 Vue.js 最核心的功能. <!DOCTYPE html> < ...
- jsp下载excel文件
jsp下载excel文件的的实现方法很多,今天也遇到这个问题,乱敲了一阵,终于搞定了,记下来和朋友们分享吧. 假设需要下载excel文件的jsp页面名为:down.jsp 对应的后台action名为: ...
- Java获取后台数据,动态生成多行多列复选框
本例目标: 获取后台数据集合,将集合的某个字段,比如:姓名,以复选框形式显示在HTML页面 应用场景: 获取数据库的人员姓名,将其显示在页面,供多项选择 效果如下: 一.后台 查询数据库,返回List ...