rman启用备份跟踪bct,增备大小预期变小,但花费时间却还和全备一样多??? -m6米乐安卓版下载

原创 2023-03-24
467

aix6.1 oracle11.2.0.4
本打算通过rman启用备份跟踪bct,提升增量备份速度。但并没有达到预期。(变更的块太分散?)

查看每小时归档日志量:日志量并不高。
select * from (select to_char(first_time,'yyyy-mm-dd hh24') hour,count(*) from v$log_history group by to_char(first_time,'yyyy-mm-dd hh24') order by hour desc) a where rownum<60;

image.png
已启用了备份跟踪,但是增量备份并没有节省备份时间?可能什么原因?这正常吗?欢迎评论。

备份时间从2:30到6:09,6:14,差不多是3小时40分钟。
0级备份大小400多给g,1级增备大小25g.
image.png
image.png
查看视图列used_change_tracking显示yes表示应用到了track.

对比0级和1级备份读取的块,1级读取的数量确实有变少,但奇怪的是时间并没少多少。
image.png
image.png
image.png
image.png

定时任务:

备份脚本参考:

15 3 3,9,15,21,27 * * /740ora/oracle/bak.sh
15 3 1,2,4-8,10-14,16-20,22-26,28-31 * * /740ora/oracle/bak-1.sh
oracle@jyca:/rman(jyc)>cat /home/oracle/bak.sh
oracle_home=/home/oracle/11.2.0.4
oracle_sid=jyc
export oracle_home oracle_sid 
nls_lang=american_america.zhs16gbk
ora_nls33=$oracle_home/ocommon/nls/admin/data
libpath=$libpath:$oracle_home/lib32
export nls_lang ora_nls33 libpath
path=$oracle_home/bin:$path
export path
export nls_date_format="yyyy-mm-dd hh24:mi:ss"
cd /rman/
find /rman/ -mtime  15 -name "jyc*" -exec rm -f {} \;
rman log /rman/rman-`date  %y%m%d-%h%m`.log <cat //home/oracle/bak-1.sh
oracle_home=/home/oracle/11.2.0.4
oracle_sid=jyc
export oracle_home oracle_sid 
nls_lang=american_america.zhs16gbk
ora_nls33=$oracle_home/ocommon/nls/admin/data
libpath=$libpath:$oracle_home/lib32
export nls_lang ora_nls33 libpath
path=$oracle_home/bin:$path
export path
export nls_date_format="yyyy-mm-dd hh24:mi:ss"
rman log /rman/rman-`date  %y%m%d-%h%m`.log <

bct启用和检查相关命令参考如下:

alter database disable block change tracking;
select status,filename from v$block_change_tracking;
alter database enable block change tracking using file '/home/oracle/rman/rman.track';
set linesize 200
column name format a50
column value format a25
col description format a40
select x.ksppinm name,y.ksppstvl value,y.ksppstdf isdefault,x.ksppdesc description,
decode(bitand(y.ksppstvf,7),1,'modified',4,'system_mod','false') ismod,
decode(bitand(y.ksppstvf,2),2,'true','false') isadj
from
sys.x$ksppi x,
sys.x$ksppcv y
where
x.inst_id = userenv('instance') and
y.inst_id = userenv('instance') and
x.indx = y.indx and
x.ksppinm like '%_bct_bitmaps_per_file%'
order by
translate(x.ksppinm, ' _', ' ');
alter system set "_bct_bitmaps_per_file"=16 sid='*';
select file#,
       blocks_changed,
       block_size,
       blocks_changed * block_size bytes_changed,
       round(blocks_changed / blocks * 100, 2) percent_changed
from v$datafile join
     (select fno
             file#,
             sum(bct) blocks_changed
      from (select distinct fno, bno, bct from x$krcbit
            where vertime >= (select curr_vertime from x$krcfde
                              where csno=x$krcbit.csno and fno=x$krcbit.fno))
      group by fno order by 1)
using(file#);
the v$backup_datafile view contains a column called used_change_tracking.
a value of yes for this column for an incremental backup level > 0 means that rman used
the tracking file to speed up the incremental backup. this can help you determine how effective
the the tracking file in minimizing the i/o activity during an incremental backup. the following
query can be used:
sql> select file#,
            avg(datafile_blocks),
            avg(blocks_read),
            avg(blocks_read/datafile_blocks) * 100 as "% read for backup"
       from v$backup_datafile
      where incremental_level > 0
        and used_change_tracking = 'yes'
      group by file#
      order by file#;
检查是否用到bct:
select incremental_level,file#,used_change_tracking fro,checkpoint_time,completion_time from v$backup_datafile order by checkpoint_time asc;
检查隐含参数:
select x.ksppinm name, y.ksppstvl value, x.ksppdesc describ
from sys.x$ksppi x, sys.x$ksppcv y
where x.inst_id = userenv ('instance')
and y.inst_id = userenv ('instance')
and x.indx = y.indx
and upper(x.ksppinm) like upper('%_bct_bitmaps_per_file%')
/

image.png
查看增量备份的情况。

set line 160
set wrap off
select
file# fno,
used_change_tracking bct,
incremental_level incr,
datafile_blocks blks,
block_size blksz,
blocks_read read,
round((blocks_read/datafile_blocks) * 100,2) "%read",
blocks wrtn, round((blocks/datafile_blocks)*100,2) "%wrtn",completion_time
from v$backup_datafile
where completion_time between
to_date('2023-04-06 03:00:00', 'yyyy-mm-dd hh24:mi:ss') and
to_date('2023-04-06 09:00:00', 'yyyy-mm-dd hh24:mi:ss')
order by file# asc;
select file#,
            avg(datafile_blocks),
            avg(blocks_read),
            avg(blocks_read/datafile_blocks) * 100 as "% read for backup"
       from v$backup_datafile
      where incremental_level > 0
        and used_change_tracking = 'yes'
      group by file#
      order by file#;

image.png
image.png
查看表空间占用的脚本参考:

set line 132
set wrap off
set pagesize 0
select t.*
from (select d.tablespace_name,
space "sum_space(m)",
blocks sum_blocks,
space - nvl(free_space, 0) "used_space(m)",
round((1 - nvl(free_space, 0) / space) * 100, 2) "used_rate(%)",
free_space "free_space(m)"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) space,
sum(blocks) blocks
from dba_data_files
group by tablespace_name) d,
(select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) free_space
from dba_free_space
group by tablespace_name) f
where d.tablespace_name = f.tablespace_name( )
union all --if have tempfile
select d.tablespace_name,
space "sum_space(m)",
blocks sum_blocks,
used_space "used_space(m)",
round(nvl(used_space, 0) / space * 100, 2) "used_rate(%)",
space - used_space "free_space(m)"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) space,
sum(blocks) blocks
from dba_temp_files
group by tablespace_name) d,
(select tablespace,
round(sum(blocks * 8192) / (1024 * 1024), 2) used_space
from v$sort_usage
group by tablespace) f
where d.tablespace_name = f.tablespace( )) t
order by "used_rate(%)" desc;
set lines 180 pages 200  
col input_type format a20
col status format a20
col minutes format 999.999
col input_mb format 99,999.99
col output_mb format 99,999.99
select session_key, input_type, status,
to_char(start_time,'yyyy-mm-dd hh24:mi') start_time,
to_char(end_time,'yyyy-mm-dd hh24:mi') end_time,
input_bytes/1024/1024 input_mb,
output_bytes/1024/1024 output_mb,
elapsed_seconds/60 minutes
from v$rman_backup_job_details
order by session_key;
-----------
input_bytes
 number
 sum of all input file sizes backed up by this job
 output_bytes
 number
 output size of all pieces generated by this job
 
input_bytes 实际上就是指备份时读取的文件大小,而 output_bytes 指的是备份实际备份出来的文件大小。

image.png

相关参考:
rman incremental level 1 backups are not using block change tracking file (doc id 1192652.1)

最后修改时间:2023-12-10 17:41:03
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

网站地图