ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 10g RAC的rman 备份

10g RAC的rman 备份

原创 Linux操作系统 作者:BTxigua 时间:2009-03-10 17:39:46 0 删除 编辑
1、清除归档日志
由于新的带库还没有到位,所以无法进行备份,只能临时先删除归档日志,删除一个小时之前的归档日志,归档删除的脚本如下:
0 * * * * cd /oracle/xigua/rman ; ./clean_arch.sh >> clean_arch.log 2>&1
more clean_arch.sh
#!/bin/ksh

. $HOME/.profile
echo "--------------------------------------------"
echo "Begin delete archivelog ......"
echo "Begin time:"`date`

rman target / nocatalog << !EOF
run
{
allocate channel ch_node1 device type disk connect 'sys/password@rac1_taf' ;
allocate channel ch_node2 device type disk connect 'sys/password@rac2_taf' ;
delete noprompt archivelog until time 'sysdate-0.05';
release channel ch_node1 ;
release channel ch_node2 ;
}
quit
!EOF

echo "Delete archivelog successful."
echo "End time:"`date`

这里的归档保留时间设置的比较小,主要因为目前系统经常需要做数据修改,在短时间内会产生大量的日志。
/dev/vx/dsk/archdg/archivelv 346112000 16074261 309410509    5% /archivelog
SQL> show parameter db_recovery
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                stri      /archivelog
db_recovery_file_dest_size           big integer 250G
当前的设置如下,/archivelog为两个节点共享文件系统。当时我的想法是避免一边的节点占用过多的归档空间,所以db_recovery_file_dest_size设置为250G,结果节点1因为归档空间不够,hung住了,差点酿成大事故。当然节点2还是正常的。
在这里,可能大家考虑不同,在设置的时候也会不同。但我还是建议这个size不要设置的太大,避免有问题的时候两个节点都hung住。这样最起码可以保留一个节点是正常的。当然,这个东西也不是绝对的。


2、备份归档日志
对于生产系统,不做备份,风险还是很大的,所以之后找了netapp,san连接,划了10几个T用于备份。但是没有做群集文件系统,只有节点1可以访问。
备份归档的脚本:
0 * * * * cd /oracle/xigua/rman ; ./backup_arch.sh >> backup_arch.log 2>&1
cat backup_arch.sh
#!/bin/ksh

. $HOME/.profile

echo "--------------------------------------------"
echo "Begin backup archivelog  ......"
echo "Begin time:"`date`

rman target / nocatalog << !EOF
#CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS ;
run
{
allocate channel ch_rac1 device type disk ;
#allocate channel ch_rac1 device type disk connect 'sys/password@rac1_taf' ;
#allocate channel ch_rac2 device type disk connect 'sys/password@rac2_taf' ;
sql 'alter system archive log current' ;
backup filesperset=10 archivelog until time 'SYSDATE-0.05' delete input format '/racbak/arch_bak/RMAN_ARCH%s%t.arc' ;
release channel ch_rac1 ;
#release channel ch_rac2 ;
}
delete noprompt expired archivelog all ;
delete noprompt obsolete recovery window of 8 days ;
quit
!EOF

echo "Archive logs backup successful."
echo "End time:"`date`

碰到的问题1:
在这里,原来我是连接到两个实例进行备份的,但是因为我的文件系统不是群集文件系统,只有节点1可以访问,连接到节点2进行归档备份的时候,就会报错。
input archive log thread=2 sequence=1727 recid=440 stamp=679946290
channel ch_rac2: starti piece 1 at 27-FEB-09
RMAN-03009: failure of backup command on ch_rac2 channel at 02/27/2009 19:00:16
ORA-19504: failed to create file "/racbak/archivelog/RMAN_ARCH2679950014.arc"
ORA-17502: ksfdcre:4 Failed to create file /racbak/archivelog/RMAN_ARCH2679950014.arc
ORA-17500: ODM err:ODM ERROR V-41-4-1-101-2 No such file or directory
channel ch_rac2 disabled, job failed on it will be run on another channel
因为在节点2无法读写指定目录,最终还是将备份传递到节点1进行备份。所以后来做了修改,直接连接到本地实例进行备份。
因为我的归档目录/archivelog是共享的群集文件系统,所以这样写,也没什么问题,对备份的速度影响也不大,因为不需要在节点之间传送日志。
如果两个节点都写自己的目录,比如/arch1,/arch2,在这种情况下,要实现这样的备份,就会造成日志在节点之间的传送,影响备份的速度。


碰到的问题2:
delete noprompt obsolete recovery window of 8 days ;
因为我的文件系统大小不足,不能保留多份全备和归档日志文件。因为我是一个星期做一个全备,其他的都只备份归档,所以我的想法是保留8天的归档加上最后一次全备。对于8天之前归档的可以删除。
对于recovery window保留策略的理解不正确,写了上面这个语句,结果并不是我期望的结果。在经过多次的测试之后,才发现原来我对recovery window的理解根本错误。

log10               log50   log75  log100  log120
fullbak              fullbak             fullbak  now            
  |                          |                     |             |                           
--|-------------------|----------|-----|----------|------|----------------|-------
  1                        7        11|     14       18|     21               28
                                           |                      |                              
                               recovery window 7 days                                       

假设我们每周全备一次,在1号,7号,14号都做过一次全备,归档日志一直在备份。
当前日期为18号,recoery window=7。
在这种情况下,我们执行delete noprompt obsolete recovery window of 7 days ;只能删除1号的全备和log50之前的归档日志。
简单点说,我们可以把 recovery window of 7 days理解为:保留恢复到最近7天内任何一个时刻所需要的备份。
所以,如果我们想删除14号之前的所有全备和归档,可以执行
delete noprompt obsolete recovery window of 1 days ;
这里1 days,可以换成2 days,3days,4days都可以。


3、备份全库
全库备份的脚本如下:
more backup_full_db.sh
#!/bin/ksh

. $HOME/.profile

echo "--------------------------------------------"
echo "Begin full database backup  ......"
echo "Begin time:"`date`

rman target / nocatalog << !EOF
run
{
allocate channel ch_rac11 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac12 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac21 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
allocate channel ch_rac22 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
backup full database include current controlfile tag 'rac_full_backup' format '/racbak/db_bak/rac_fullbak_%U';
backup current controlfile format '/racbak/db_bak/control_bak_%T';
sql 'alter system archive log current' ;
release channel ch_rac11 ;
release channel ch_rac11 ;
release channel ch_rac21 ;
release channel ch_rac22 ;
}
quit
!EOF

echo "Full Database backup successful."
echo "End time:"`date`

全库备份有一个问题和归档备份一样,因为备份的目的地只能在节点1读写,所以也会在执行的时候报错,然后传递到节点1执行备份。


4、增量合并和压缩备份
全库备份和归档的备份太消耗空间,都无法同时保留两份全备,所以想节约一点空间,想到了10g两个新特性:
1)压缩备份,压缩备份怕消耗的CPU比较多、备份速度不够快,所以也没敢做。
2)增量合并。
   启用增量合并需要打开跟踪
   alter database enable block chae tracki usi file '/racbak/chae.log';
   跟踪文件中记录的应该是文件号,变更的块号等信息,所以这个文件的体积不会长的很大。metalink还提供了一个详细的文件大小算法:
   Doc ID: 306112.1
   size of chae tracki file = # of redo threads * (# of old backups + 2) * (size of db/250000)
   所以这个文件在我们的系统中基本不会超过1G,大小是可以接受的。
   新特性总是让你担心bug的问题,所以顺手查了一下,结果找到一个bug,Bug No. 7408455。
   CTWR CRASHED DATABASE INSTANCE WITH ORA-00600 [KRCCAUB_2]
   在核心业务系统上,还是稳定压倒一切,所以还是决定不用了。
  
脚本如下:
零级备份
more backup_full_db_lv0.sh
#!/bin/sh

. $HOME/.profile

echo "--------------------------------------------"
echo "Begin database level 0 full backup  ......"
echo "Begin time:"`date`

rman target / nocatalog << !EOF
run
{
allocate channel ch_rac11 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac12 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac21 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
allocate channel ch_rac22 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
backup incremental level 0 database include current controlfile tag 'fullbak_lv0' format '/racbak/rac_fullbak_lv0_%U';
backup current controlfile format '/racbak/control_bak_%T';
sql 'alter system archive log current' ;
release channel ch_rac11 ;
release channel ch_rac11 ;
release channel ch_rac21 ;
release channel ch_rac22 ;
}
quit
!EOF

echo "Database level 0 full backup successful."
echo "End time:"`date`

1级增量合并
cat backup_full_db_lv1.sh
#!/bin/ksh

######
# Enable block chae tracki:
# alter database enable block chae tracki usi file '/racdata1/chae.log' ;
# Disable block chae tracki:
# alter database disable block chae tracki ;
# Query block chae tracki status:
# select filename, status from v$block_chae_tracki ;
#
######

. $HOME/.profile

echo "--------------------------------------------"
echo "Begin database level 1 incremental backup  ......"
echo "Begin time:"`date`

rman target / nocatalog << !EOF
run
{
allocate channel ch_rac11 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac12 device type disk maxpiecesize 20G connect 'sys/password@rac1_taf' ;
allocate channel ch_rac21 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
allocate channel ch_rac22 device type disk maxpiecesize 20G connect 'sys/password@rac2_taf' ;
backup incremental level 1 for recover of copy with tag 'fullbak_lv0' database include current controlfile format '/racbak/rac_fullbak_lv0_%U';
backup current controlfile format '/racbak/control_bak_%T';
sql 'alter system archive log current' ;
release channel ch_rac11 ;
release channel ch_rac11 ;
release channel ch_rac21 ;
release channel ch_rac22 ;
}
quit
!EOF

echo "Database level 1 incremental backup successful."
echo "End time:"`date`                                                                                   

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

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

注册时间:2008-01-31

  • 博文量
    101
  • 访问量
    283609