一、需求
某客户需要搭建dg,但是主库与备库剩余空间都不是很充足, 如果使用RMAN备份到本地,然后scp 备份文件到dg,空间需要考虑很多问题!
那么duplicate 方式搭建,是否会备份主库写到主库,或者写到备库的备份文件中呢?
本质上这个问题就是对duplicate操作的理解到什么程度!
二、观察duplicate日志
2.1 观察duplicate日志
Recovery Manager: Release 12.2.0.1.0 - Production on Tue Apr 20 06:38:37 2021 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1594123398) connected to auxiliary database: ORCL (not mounted) RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> using target database control file instead of recovery catalog allocated channel: p1 channel p1: SID=75 device type=DISK allocated channel: p2 channel p2: SID=76 device type=DISK allocated channel: p3 channel p3: SID=77 device type=DISK allocated channel: p4 channel p4: SID=78 device type=DISK allocated channel: s1 channel s1: SID=35 device type=DISK allocated channel: s2 channel s2: SID=36 device type=DISK allocated channel: s3 channel s3: SID=37 device type=DISK allocated channel: s4 channel s4: SID=38 device type=DISK Starting Duplicate Db at 20-APR-21 contents of Memory Script: { backup as copy reuse targetfile '/picclife/app/oracle/product/12.2.0/db_1/dbs/orapwc11' auxiliary format '/picclife/app/oracle/product/12.2.0/db_1/dbs/orapwc12' ; } executing Memory Script Starting backup at 20-APR-21 Finished backup at 20-APR-21 contents of Memory Script: { restore clone from service 'tns_pri' standby controlfile; } executing Memory Script Starting restore at 20-APR-21 channel s1: starting datafile backup set restore channel s1: using network backup set from service tns_pri channel s1: restoring control file channel s1: restore complete, elapsed time: 00:00:04 output file name=/picclife/app/oracle/oradata/orcldg/control01.ctl output file name=/picclife/app/oracle/oradata/orcldg/control02.ctl Finished restore at 20-APR-21 contents of Memory Script: { sql clone 'alter database mount standby database'; } executing Memory Script sql statement: alter database mount standby database contents of Memory Script: { set newname for tempfile 1 to "/picclife/app/oracle/oradata/orcldg/temp01.dbf"; set newname for tempfile 2 to "/picclife/app/oracle/oradata/orcldg/pdbseeddg/temp012021-03-04_22-18-29-699-PM.dbf"; set newname for tempfile 3 to "/picclife/app/oracle/oradata/orcldg/c11pdbdg/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "/picclife/app/oracle/oradata/orcldg/system01.dbf"; set newname for datafile 3 to "/picclife/app/oracle/oradata/orcldg/sysaux01.dbf"; set newname for datafile 4 to "/picclife/app/oracle/oradata/orcldg/undotbs01.dbf"; set newname for datafile 5 to "/picclife/app/oracle/oradata/orcldg/pdbseeddg/system01.dbf"; set newname for datafile 6 to "/picclife/app/oracle/oradata/orcldg/pdbseeddg/sysaux01.dbf"; set newname for datafile 7 to "/picclife/app/oracle/oradata/orcldg/users01.dbf"; set newname for datafile 8 to "/picclife/app/oracle/oradata/orcldg/pdbseeddg/undotbs01.dbf"; set newname for datafile 9 to "/picclife/app/oracle/oradata/orcldg/c11pdbdg/system01.dbf"; set newname for datafile 10 to "/picclife/app/oracle/oradata/orcldg/c11pdbdg/sysaux01.dbf"; set newname for datafile 11 to "/picclife/app/oracle/oradata/orcldg/c11pdbdg/undotbs01.dbf"; set newname for datafile 12 to "/picclife/app/oracle/oradata/orcldg/c11pdbdg/users01.dbf"; restore from nonsparse from service 'tns_pri' clone database ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /picclife/app/oracle/oradata/orcldg/temp01.dbf in control file renamed tempfile 2 to /picclife/app/oracle/oradata/orcldg/pdbseeddg/temp012021-03-04_22-18-29-699-PM.dbf in control file renamed tempfile 3 to /picclife/app/oracle/oradata/orcldg/c11pdbdg/temp01.dbf in control file executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at 20-APR-21 skipping datafile 5; already restored to SCN 1447512 skipping datafile 6; already restored to SCN 1447512 skipping datafile 8; already restored to SCN 1447512 channel s1: starting datafile backup set restore channel s1: using network backup set from service tns_pri channel s1: specifying datafile(s) to restore from backup set channel s1: restoring datafile 00001 to /picclife/app/oracle/oradata/orcldg/system01.dbf channel s2: starting datafile backup set restore channel s2: using network backup set from service tns_pri channel s2: specifying datafile(s) to restore from backup set channel s2: restoring datafile 00003 to /picclife/app/oracle/oradata/orcldg/sysaux01.dbf channel s3: starting datafile backup set restore channel s3: using network backup set from service tns_pri channel s3: specifying datafile(s) to restore from backup set channel s3: restoring datafile 00004 to /picclife/app/oracle/oradata/orcldg/undotbs01.dbf channel s4: starting datafile backup set restore channel s4: using network backup set from service tns_pri channel s4: specifying datafile(s) to restore from backup set channel s4: restoring datafile 00007 to /picclife/app/oracle/oradata/orcldg/users01.dbf channel s4: restore complete, elapsed time: 00:00:17 channel s4: starting datafile backup set restore channel s4: using network backup set from service tns_pri channel s4: specifying datafile(s) to restore from backup set channel s4: restoring datafile 00009 to /picclife/app/oracle/oradata/orcldg/c11pdbdg/system01.dbf channel s3: restore complete, elapsed time: 00:01:04 channel s3: starting datafile backup set restore channel s3: using network backup set from service tns_pri channel s3: specifying datafile(s) to restore from backup set channel s3: restoring datafile 00010 to /picclife/app/oracle/oradata/orcldg/c11pdbdg/sysaux01.dbf channel s4: restore complete, elapsed time: 00:00:55 channel s4: starting datafile backup set restore channel s4: using network backup set from service tns_pri channel s4: specifying datafile(s) to restore from backup set channel s4: restoring datafile 00011 to /picclife/app/oracle/oradata/orcldg/c11pdbdg/undotbs01.dbf channel s4: restore complete, elapsed time: 00:00:20 channel s4: starting datafile backup set restore channel s4: using network backup set from service tns_pri channel s4: specifying datafile(s) to restore from backup set channel s4: restoring datafile 00012 to /picclife/app/oracle/oradata/orcldg/c11pdbdg/users01.dbf channel s2: restore complete, elapsed time: 00:01:38 channel s4: restore complete, elapsed time: 00:00:07 channel s1: restore complete, elapsed time: 00:01:53 channel s3: restore complete, elapsed time: 00:00:47 Finished restore at 20-APR-21 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=4 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/system01.dbf datafile 3 switched to datafile copy input datafile copy RECID=5 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/sysaux01.dbf datafile 4 switched to datafile copy input datafile copy RECID=6 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/undotbs01.dbf datafile 5 switched to datafile copy input datafile copy RECID=7 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/pdbseeddg/system01.dbf datafile 6 switched to datafile copy input datafile copy RECID=8 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/pdbseeddg/sysaux01.dbf datafile 7 switched to datafile copy input datafile copy RECID=9 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/users01.dbf datafile 8 switched to datafile copy input datafile copy RECID=10 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/pdbseeddg/undotbs01.dbf datafile 9 switched to datafile copy input datafile copy RECID=11 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/c11pdbdg/system01.dbf datafile 10 switched to datafile copy input datafile copy RECID=12 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/c11pdbdg/sysaux01.dbf datafile 11 switched to datafile copy input datafile copy RECID=13 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/c11pdbdg/undotbs01.dbf datafile 12 switched to datafile copy input datafile copy RECID=14 STAMP=1070347457 file name=/picclife/app/oracle/oradata/orcldg/c11pdbdg/users01.dbf Finished Duplicate Db at 20-APR-21 released channel: p1 released channel: p2 released channel: p3 released channel: p4 released channel: s1 released channel: s2 released channel: s3 released channel: s4 RMAN>
可以看到对于duplicate产生的日志:
1.连接主备,分配RMAN备份通道;
2.将主库口令文件 scp 到dg;
3.主库备份standby controlfile ->scp dg-> dg 启动到mount;
4.根据参数convert 转换文件路径;
5.主库在线进行copy datafile ->scp dg
6.结束! 如果是生产环境,会scp ->archive
2.2 主备检查备份
Primary RMAN> list backup of datafile 1; using target database control file instead of recovery catalog specification does not match any backup in the repository list backup 出现一堆乱七八糟的信息太多,全备肯定会存在datafile 1的备份信息 Standby RMAN> list backup of datafile 1; using target database control file instead of recovery catalog specification does not match any backup in the repository
所以,在主备本地空间不是很充足的情况下,可以使用duplicate,这样不在需要考虑rman备份文件的存储空间占用。