备份优化

来源:这里教程网 时间:2026-03-03 17:30:38 作者:

一:备份集优化

###1.多通道提升备份速度
rman可以通过section size子句利用多个通道对其进行备份
##这种方式对于单个文件较大,且文件数量较少性能会有提升
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup section size 175M datafile 1;
}
###2.数据块跟踪
对于增量备份使用数据块跟踪技术,在进行等级1的增量备份时rman无需扫描整个数据文件,值需要扫描数据块变更跟踪文件就可以发现那些数据块需要备份了
##需要注意的是:对于rac环境下,我们目录要设置到共享存储上
##如果设置的位置是本地目录,rac在启动的时候另一个节点就无法正常open
##遇到一种情况,块跟踪目录设置为共享存储,另一个节点也无法正常打开。
##开启数据块跟踪
alter database enable block change tracking using file '/home/oracle/bak1/' reuse;
##关闭数据库块跟踪
alter database disable block change tracking;
###3.v$backup_datafile视图
使用v$backup_datafile视图能够验证备份的效率,blocks_read与datafile_blocks的比值越小说明增量备份读取的数据块的数量占文件总数据块的数量就越小,增量备份的效率就越高,启用数据块跟踪的回报就越高。
##如果比值接近1,就没有理由进行增量备份,不如直接全备,数据块变更跟踪文件也不需要设置了
select file#,sum(blocks_read)/sum(datafile_blocks) ratio from v$backup_datafile
where incremental_level>0 group by file#;
二:镜像复制优化
##镜像复制就是相当于操作系统层面的copy文件,最大的缺点就是浪费空间,数据文件多大,镜像复制就多大。
##但是还原数据库的时候有一个特别的优点--镜像复制利用文件路径的重命名可以使还原操作的时间忽略不计(switch修改控制文件信息)--一般不会这么操作
##使用增量备份更新镜像复制
如果镜像复制的文件时间周期较长,比如一个周之前的,那么就需要跑一个周的归档才能讲数据还原出来
##第一次进行备份会将数据文件全部copy
backup incremental level 0 for recover of copy with tag 'FLASH' database;
RMAN> backup incremental level 1 for recover of copy with tag 'FLASH' database;
Starting backup at 18-MAR-22
using channel ORA_DISK_1
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 4 found
no parent backup or copy of datafile 5 found
no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 7 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/oradata/orcl/system01.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_system_k38n80c2_.dbf tag=FLASH RECID=5 STAMP=1099675777
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/oradata/orcl/sysaux01.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_sysaux_k38n83gk_.dbf tag=FLASH RECID=6 STAMP=1099675782
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/oradata/orcl/undotbs01.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_undotbs1_k38n8bjg_.dbf tag=FLASH RECID=7 STAMP=1099675786
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oradata/orcl/lhh02.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_lhh_k38n8cl8_.dbf tag=FLASH RECID=8 STAMP=1099675787
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/oradata/orcl/users02.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_users_k38n8dmr_.dbf tag=FLASH RECID=9 STAMP=1099675788
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/oradata/orcl/users01.dbf
output file name=/home/oracle/fra/ORCL/datafile/o1_mf_users_k38n8foh_.dbf tag=FLASH RECID=10 STAMP=1099675789
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 18-MAR-22
Starting Control File and SPFILE Autobackup at 18-MAR-22
piece handle=/home/oracle/fra/ORCL/autobackup/2022_03_18/o1_mf_s_1099675790_k38n8grb_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-MAR-22
##第二次备份的时候,产生了一个增量的备份文件
backup incremental level 1 for recover of copy with tag 'FLASH' database;
Starting backup at 18-MAR-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/orcl/system01.dbf
input datafile file number=00003 name=/oradata/orcl/sysaux01.dbf
input datafile file number=00007 name=/oradata/orcl/users01.dbf
input datafile file number=00004 name=/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/oradata/orcl/lhh02.dbf
input datafile file number=00002 name=/oradata/orcl/users02.dbf
channel ORA_DISK_1: starting piece 1 at 18-MAR-22
channel ORA_DISK_1: finished piece 1 at 18-MAR-22
piece handle=/home/oracle/fra/ORCL/backupset/2022_03_18 /o1_mf_nnnd1_FLASH_k38n9qk6_.bkp tag=FLASH comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 18-MAR-22
Starting Control File and SPFILE Autobackup at 18-MAR-22
piece handle=/home/oracle/fra/ORCL/autobackup/2022_03_18/o1_mf_s_1099675834_k38n9tjj_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-MAR-22

相关推荐