ITPub博客

首页 > 数据库 > 数据库开发技术 > zt-Determine How Much Disk Space is Needed for the Archive Files

zt-Determine How Much Disk Space is Needed for the Archive Files

原创 数据库开发技术 作者:xiaoqiang917 时间:2011-02-19 04:32:05 0 删除 编辑

从support中看到的一篇文章,估算备份归档日志所需的空间,顺手贴出来,方便其他人。

[@more@]


***Checked for relevance on 29-Jul-2010***

Introduction
------------

If the database runs in archivelog mode, then Oracle will archive the online
redo log files whenever a log switch occurs.  It is important that there is
enough free space on the dedicated disk(s) for the archive files, otherwise the
ARCHiver process can not write and a crash is inevitable.

This article determines how much free disk space is needed to support growth of
the archive files.  Data from the log history is gathered for analysis.  This
article is not based on actual formulas but rather on human interpretion of the
information retrieved from the log history.


Retrieve log information
------------------------

First you need to determine how many log switches are occurring on your system,
this can be done with the following select, please note that you need to replace
the  with the actual size of your redo log files in Mb.  To obtain
the size in Mb of your online redo log files, you can execute the following
query:

   SELECT distinct(to_char((bytes*0.000001),'9990.999')) size_mb FROM v$log;

   Example output:

   SIZE_MB
   -------
     1.024

   Note:
   On rare occasions, it is possible the select above will return more
   than one row.  This indicates you have different sized redo logs. 
   There are no benefits to having different sized redo logs.
   See also Note:10698.1 Redo Log Guidelines

   Oracle 7 :
   ----------
   column date_   heading 'Date'         format A15
   column no      heading '#Arch files'  format 9999999
   column no_size heading 'Size Mb'      format 9999999
   compute avg of no      on report
   compute avg of no_size on report
   break on report

   select substr(time,1,8) date_, count(sequence#) no, 
          count(sequence#) *  no_size
   from v$log_history
   group by substr(time,1,8)
   /
   clear breaks
   clear columns
   clear columns


   Oracle 8 and up:
   -----------------
   column ord     noprint
   column date_   heading 'Date'         format A15
   column no      heading '#Arch files'  format 9999999
   column no_size heading 'Size Mb'      format 9999999
   compute avg of no      on report
   compute avg of no_size on report
   break on report

   select MAX(first_time) ord, to_char(first_time,'DD-MON-YYYY') date_, 
          count(recid) no, count(recid) *  no_size
   from v$log_history
   group by to_char(first_time,'DD-MON-YYYY')
   order by ord
   /
   clear breaks
   clear computes
   clear columns

   Note: starting from Oracle8, there is a new view called v$archived_log.  This
   view tells you which files are archived, in the context of this article this
   view will basically give us the same information as v$log_history.
   
The output of the above script tells you how many log switches are occurring on
your system on a daily basis.  The actual disk space that is required to serve
the archiving is given in MB as well.  Notice that if there were not any log 
switches during one entire day then there is no record of it.

First of all you need to determine if the amount of log switches are stable or
differs a lot from day to day.  If this is stable then the calculated average
of archive files generated will be a good indication of how much free disk space
is needed per day.  If this changes a lot, for instance because once a week 
there is an upload in batch, then this must be taken into account.

You can analyze if the number of log switches and the required disk space, is 
increasing over time.  This will tell you if you need to reserve more (or less)
disk space for the archive files in the future.


Example 1
---------
A cold backup is taken every 3 days.  The archive files are not included in the
backup but you want to keep the archive files for the previous backup on disk as
well.  Afterwards they are removed from the system.  Activity on the database is
more or less stable.  The size of the redo log files is 5Mb. 

The output from the above select looks like:

   Date            #Arch files  Size Mb
   --------------- ----------- --------
   ...
   10-JUN-2000               5       25
   11-JUN-2000               4       20
   12-JUN-2000               7       35
   14-JUN-2000               3       15
   15-JUN-2000               5       25
   16-JUN-2000               2       10
   17-JUN-2000               6       30
   18-JUN-2000               5       25
   ...
                         -----     ----
                             5       25
                             
The average value calculated gives us a good indication, since the amount of
switches is stable, this means:

  25Mb * 3 days = 75 Mb
  20%           = 15 Mb
                 ------
                  90 Mb

The 20% added additionaly is to allow a safety margin.
Since we are keeping archive files from previous backup as well, this means:

  90Mb * 2 = 180Mb.
                             
 
Example 2
---------
A cold backup is taken every Sunday including the archive logs.  On Monday there
is a batch job doing a large upload.  The rest of the week there is normal 
activity on the database and on Saturday there is pratically no activity.  My 
redo log files are 1Mb in size.

The output from the above select looks like:

   Date            #Arch files  Size Mb
   --------------- ----------- --------
   ...
   14-APR-2000              15       15
   16-APR-2000              12       12    <- Sunday
   17-APR-2000             275      275
   18-APR-2000              13       13
   19-APR-2000              12       12
   20-APR-2000              11       11
   21-APR-2000              14       14
   22-APR-2000               1        1    <- Saturday 
   23-APR-2000              11       11
   ...
                         -----     ----
                            43       43
 
The average is not a good indication, since the amount of archived files is not
stable during the entire week.  There is no exact formula but if we add all the
values during the entire week + 20% then we will most likely not have any
problems.

  sum = 338 Mb
  20% =  68 Mb
       -------
        406 Mb


Search words
------------

free disk space archive files




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25274175/viewspace-1046178/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-02-18

  • 博文量
    11
  • 访问量
    10422