data guard 歸檔日誌管理 (primary)

lovehewenyu發表於2012-04-17
 

主庫歸檔管理:

1、 用SHELL指令碼,取歸檔已被APP的。然後刪除已經APP的歸檔。

2、 用RMAN 備份策略管理:oracle 自帶的策略:

RMAN> configure archivelog deletion policy to applied on standby;

有報錯,解決方法:

SQL>alter system set "_log_deletion_policy"=ALL scope=spfile sid='*';

 

Oracle 在刪除已經備份完的歸檔時,會看下是否已經被APP 沒有APP的就不刪除。

 

3、利用RMAN備份的時間點和刪除時間點分離,這樣就給了資料庫一段時間內的歸檔冗餘,在這段時間內備庫應該可以把歸檔應用了這個時間點可以儘量長一些。

這個方案雖然不夠嚴謹,但是可以解決一些實際問題。

 

下面是方案:

4點 full.sh

3點 delete.sh

 

 

 

[ora@dg-pp ~]$ cat full.sh

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

 

PATH=$PATH:$HOME/bin

 

export PATH

unset USERNAME

 

#--------------------------------------

# Set for Oracle10g Install 20101015;

#--------------------------------------

trap " " 0 1 2 3 5 9 15

trap clear 0

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_SID=research

export ORACLE_TERM=xterm

export PATH=/usr/sbin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/X11R6/lib64/

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export LD_ASSUME_KERNEL=2.6.9

export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"

export TNS_ADMIN=$ORACLE_HOME/network/admin

export LC_CTYPE=en_US.UTF-8

export LC_ALL=en_US.UTF8

export LANG=en_US.UTF8

umask 022

#

if [ $USER = "ora" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi

#------------------- Set Over

 

全庫備庫,不刪除多餘的備份和歸檔日誌。

rman target /  nocatalog log=/rman/log/rman_db_full.log <

run {

allocate channel d1 type disk;

allocate channel d2 type disk;

allocate channel d3 type disk;

     backup  ( database

                     include current controlfile

                     filesperset=2

                     format '/rman/data/full_data_%s_%p'

                     tag="fullbackup_data");

   backup  ( archivelog all

                     filesperset=4

                     format '/rman/arch/arch_%s_%p'

                     tag="fullbackup_arch");

release channel d1;

release channel d2;

release channel d3;

crosscheck backup;

}

exit

EOF

 

0級資料壓縮備份,不刪除多餘的備份和歸檔。

rman target /  nocatalog log=/u01/rman/log/rman_db_level0.log <

run {

allocate channel d1 type disk;

allocate channel d2 type disk;

allocate channel d3 type disk;

backup as compressed backupset incremental level 0 database filesperset 4 format

'/u01/rman/data/level0_%d_%s_%p_%u_%T.bak' include current controlfile;

sql 'alter system archive log current';

backup archivelog all filesperset 10 format '/u01/rman/arch/arc_%d_%s_%p_%u_%T.bak';

release channel d1;

release channel d2;

release channel d3;

crosscheck backup;

}

exit

EOF

 

 

[ora@dg-pp ~]$ cat delete.sh

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

 

PATH=$PATH:$HOME/bin

 

export PATH

unset USERNAME

 

#--------------------------------------

# Set for Oracle10g Install 20101015;

#--------------------------------------

trap " " 0 1 2 3 5 9 15

trap clear 0

export TMP=/tmp

export TMPDIR=$TMP

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_SID=research

export ORACLE_TERM=xterm

export PATH=/usr/sbin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/X11R6/lib64/

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export LD_ASSUME_KERNEL=2.6.9

export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"

export TNS_ADMIN=$ORACLE_HOME/network/admin

export LC_CTYPE=en_US.UTF-8

export LC_ALL=en_US.UTF8

export LANG=en_US.UTF8

umask 022

#

if [ $USER = "ora" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi

#------------------- Set Over

 

rman target / nocatalog log=/u01/rman/log/rman_db_delete.log <

run {

crosscheck backup;

delete noprompt expired backup ;

delete noprompt obsolete;}

exit

EOF

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-721392/,如需轉載,請註明出處,否則將追究法律責任。

相關文章