物理Dg和逻辑dg的区别
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了物理Dg和逻辑dg的区别相关的知识,希望对你有一定的参考价值。
1、实现机制不同
一个是基于block的,一个是基于SQL statement。
物理dg是通过传日志的形式block对block的完全把主库复制,复制出来的从库和主库完全一样,
逻辑dg是通过传日志,再应用logmin的技术将日志中的sql挖出,处理,并重新执行。
2、功能不同
10g的物理dg只能只读打开,但11g可以读写打开,且从库名必须和主库名相同。
逻辑dg从库可以读写打开,逻辑dg有些表和数据是不能同步的,且主库和从库可以不完全相同。
3、同步方式不同
物理dg通过重做应用与主数据库保持同步,物理dg与主数据库SCN保持一致。
逻辑dg通过SQL应用与主数据库保持同步,逻辑dg只需要数据保持一致。
扩展资料:
一、DG的优点:
1、灾难恢复及高可用性。
2、全面的数据保护。
3、有效利用系统资源。
4、在高可用及高性能之间更加灵活的平衡机制。
5、故障自动检查及解决方案。
6、集中的、易用的管理模式。
7、自动化的角色转换。
二、DG的缺点:
1、由于传输整个日志文件,所以,需要较高的网络传输带宽。
2、在Oracle 11g之前的物理备库虽然可以以只读方式打开,然后执行查询、报表等操作,但需要停止应用日志,这将使目标库与源数据不能保持同步,如果在此期间源数据库发生故障,那么将延长切换的时间。
从Oracle 11g开始,ADG可以在数据库打开的情况下应用日志,这极大地提高了DG的应用范围。
3、逻辑备库不能支持某些特定的数据对象和数据类型。
4、不支持双向复制,所以,无法应用于信息集成的场合。
5、只能复制整个数据库,不能选择某个SCHEMA或表空间或表进行单独复制。
6、不支持异构的系统环境,需要相同的操作系统版本和数据库版本(Oracle 11g支持部分异构平台)。
参考技术A 物理低格是重新划分磁道,扇区,高格仅仅是把不要的文件头写0而已(这个说得不是很严谨,还请诸位指正),出厂之后没有特殊情况不会再低格,因为它会损伤磁盘,而高格不会,你爱格几次都行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 使用主库传输的备份进行恢复,与异机恢复在于,当主备文件路径不同时,可以使用参数,自动转换,而异机恢复 RMAN SET指定 ,影响也小,安全--半自动
#根据恢复应用及参数调整做出说明:
一、异机恢复方式:
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/* [email protected]:/tmp/full
#修改权限:
# chown oracle.oinstall *
#再次执行 OK
$ rman target sys/[email protected] auxiliary sys/[email protected]
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和逻辑dg的区别的主要内容,如果未能解决你的问题,请参考以下文章