ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RAC 之 RMAN 备份

RAC 之 RMAN 备份

原创 Linux操作系统 作者:roominess 时间:2012-05-08 14:48:51 0 删除 编辑

一.     RAC 归档的设置

 

1.1  相关理论知识

RAC 在运行的时候,每个实例都会产生归档日志,所有实例的归档日志集中在一起,才能完整地代表数据库的操作历史,此外,只有进行介质恢复(Media Recovery)时,才会用到归档日志。 进行介质恢复时,才要求在执行恢复操作的那个节点访问所有实例的归档日志。

 

正是因为归档日志有这些特点,所以归档位置的设计也有两种方案:

1)各节点生成的归档放到共享存储上,这样自然可以确保每个节点都能够访问到,比如将归档存放到ORACLEASM,或者是第三方提供的集群文件系统中。 对于这种方法,一些集群的配置比较麻烦,而且也增加了ASM的维护,出现问题也不好处理。

2)各节点除在本地生成归档文件外,另外向其它节点或者说执行备份的节点发送归档日志,以确保执行备份的那台节点能够访问到所有的归档文件。在这种方法中,因为ORACLE 的重做日志发送机制非常灵活,在10g版本中可以同时向10个目标地写入归档(11g增加到了30),所以利用这种特性,将各节点生成的归档发送到执行备份的节点中,来实现该节点能够访问所需的归档文件。

 

在第二种方案中,我们可以在每个节点建2个归档目录,分别存放本地和其他节点节点的归档日志,这里假设是2个节点的RAC.

 

归档位置

实例1

实例2

本地磁盘

Mkdir /rac1_arch

Mkdir /rac2_arch

Mkdir /rac1_arch

Mkdir /rac2_arch

Log_archive_dest_1

Location=’/rac1_arch’

Location=’/rac2_arch’

Log_archive_dest_2

Service=’rac2’

Service=’rac1’

Standby_archive_dest

‘/rac2_arch’

‘/rac1_arch’

 

 

在每个节点上建2个目录: /u02/rac1_arch, /u02/rac2_arch, 并赋予读写的权限:

 

[root@rac2 /]# mkdir /u02/rac1_arch

[root@rac2 /]# mkdir /u02/rac2_arch

[root@rac2 /]# chown oracle:oinstall /u02/*

[root@rac2 /]# chmod 777 /u02/*

 

      

1.2  RAC 设置成归档模式

       RAC的归档设置和单实例归档设置差不多。 先将所有实例设置为非OPEN状态,然后在任意一个处于MOUNT状态的实例执行ALTER DATABASE命令,操作成功后,再正常启动其它实例即可。

 

之前整理的一篇RAC 归档切换的文档,不过和今天这个实验不太匹配,就重新在整理下。


 

 

 

1.2.1 设置归档参数

 

1.2.1.1 设置实例orcl1的参数:

 

SQL> alter system set log_archive_dest_1 = 'LOCATION=/u02/rac1_arch' scope=both sid='orcl1';

System altered.

 

SQL> alter system set log_archive_dest_2 = 'service=orcl2' scope=both sid='orcl1';

System altered.

 

SQL> alter system set standby_archive_dest = '/u02/rac2_arch' scope=both sid='orcl1';

System altered.

 

1.2.1.2 设置实例orcl2的参数:

 

SQL> alter system set log_archive_dest_1 = 'LOCATION=/u02/rac2_arch' scope=both sid='orcl2';

System altered.

 

SQL> alter system set log_archive_dest_2= 'SERVICE=orcl1' scope=both sid='orcl2';

System altered.

 

SQL> alter system set standby_archive_dest = '/u02/rac1_arch' scope=both sid='orcl2';

System altered.

 

 

 

1.2.1.3 2个节点上分别验证参数的状态:

 

SQL> set wrap off

SQL> col dest_name format a20

SQL> select dest_name,status,error from v$archive_dest;

 

DEST_NAME            STATUS    ERROR

-------------------- --------- -------------------------------------------------

LOG_ARCHIVE_DEST_1   VALID

LOG_ARCHIVE_DEST_2   VALID

LOG_ARCHIVE_DEST_3   INACTIVE

LOG_ARCHIVE_DEST_4   INACTIVE

LOG_ARCHIVE_DEST_5   INACTIVE

LOG_ARCHIVE_DEST_6   INACTIVE

LOG_ARCHIVE_DEST_7   INACTIVE

LOG_ARCHIVE_DEST_8   INACTIVE

LOG_ARCHIVE_DEST_9   INACTIVE

LOG_ARCHIVE_DEST_10  INACTIVE

 

10 rows selected.

 

1.2.2 RAC 切换成归档模式

 

1.2.2.1 修改数据库的归档模式

       SQL> alter system set cluster_database=false scope=spfile sid='*';

System altered.

 

1.2.2.2 关闭所有实例

       SQL> shutdown immediate

 

 

1.2.2.3 在任意一个实例上将数据库启动到mount状态,修改数据库归档模式

SQL> startup mount

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1266392 bytes

Variable Size             117443880 bytes

Database Buffers           46137344 bytes

Redo Buffers                2924544 bytes

Database mounted.

 

SQL> alter database archivelog;

Database altered.

 

SQL> alter system set cluster_database=true scope=spfile sid='*';

System altered.

 

         SQL> shutdown immediate

 

1.2.2.4 重启数据库,确定归档生效

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u02/rac1_arch

Oldest online log sequence     54

Next log sequence to archive   55

Current log sequence           55

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u02/rac2_arch

Oldest online log sequence     26

Next log sequence to archive   27

Current log sequence           27

 

 

1.2.2.5 在两个节点分别切换归档日志,并检查对应的目录是否产生归档日志

       SQL> alter system switch logfile;

System altered.

 

SQL> select inst_id,recid,dest_id,name from gv$archived_log ;

  INST_ID      RECID    DEST_ID NAME

---------- ---------- ---------- -----------------------------------------------

         2         12          1 /u02/rac1_arch/1_5_730181171.dbf

         2         13          2 /u01/rac1_arch1_5_730181171.dbf

         2         14          2 /u02/rac2_arch/2_3_730181171.dbf

         2         15          1 /u02/rac1_arch/1_6_730181171.dbf

         2         16          2 /u02/rac1_arch/1_6_730181171.dbf

         2         17          1 /u02/rac1_arch/1_7_730181171.dbf

              ……

         1         12          1 /u02/rac1_arch/1_5_730181171.dbf

         1         13          2 /u01/rac1_arch1_5_730181171.dbf

         1         14          2 /u02/rac2_arch/2_3_730181171.dbf

         1         15          1 /u02/rac1_arch/1_6_730181171.dbf

         1         16          2 /u02/rac1_arch/1_6_730181171.dbf

 

 

提示:RAC 数据库各实例拥有各自的REDO线程,归档文件名的生成规则由LOG_ARCHIVE_FORMAT初始化参数控制,默认情况下是 %t_%s_%r.dbf ,所以不会导致重复的发生。

 

 

注意一个参数:LOG_ARCHIVE_LOCAL_FIRST,用来设置是否首先归档文件到本地,默认为true.

 

LOG_ARCHIVE_LOCAL_FIRST 这个参数是Oracle 10g 新增的,它主要针对Standby环境退出,在Oracle 10g 以前的Standby中,本地和远程的归档都完成后,联机日志文件才可以被重用,在网络速度慢的环境中,远程归档的配置会很大程度的影响节点的处理能力。而设置LOG_ARCHIVE_LOCAL_FIRST=trueOracle 会先进行本地归档,本地归档结束后在进行远程传递,同时使联机日志可以重用,从而减少了网络环境对本地的影响。 如果把这个参数设置为FALSE, 则相当于Oracle 10g 之前的方式,这个参数默认是True,如果在应用中遇到找不到归档日志的问题,就可以把这个参数改成FALSE.

 

 

 

二、RAC数据库的RMAN备份

RAC 和 单实例数据库备份机制是一样的,有两点需要注意:

(1)       RMAN 要连接到集群中的某个实例,而不是连接到整个集群

(2)       备份归档日志时,必须保证在备份实例上能够访问所有实例的归档日志,否则就会报错。

 

 

2.1 先看一个归档日志不一致的问题

       在这种情况下备份是会报错的。 之前启动归档之后,2个节点的归档目录文件是相同的,现在我们模拟归档日志不一致的情况。

 

先关闭两个节点的归档位置2 此时归档日志都不能传递到对方的归档的目录下。

 

SQL> alter system set log_archive_dest_state_2 =defer scope=both  sid='*';

System altered.

 

在手动档产生归档日志:

SQL> alter system switch logfile;

System altered.

 

此时两个节点归档目录下文件不一致。我们连接到rac1节点,然后用rman 备份一下,看报什么错

 

RMAN> backup database plus archivelog;

 

Starting backup at 20-SEP-10

current log archived

using channel ORA_DISK_1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of backup plus archivelog command at 09/20/2010 14:13:32

RMAN-06059: expected archived log not found, lost of archived log compromises recoverability

ORA-19625: error identifying file /u02/rac2_arch/2_11_730181171.dbf

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

 

这里报错了。 现在我们手动把缺失的日志从rac2节点copy到节点1. 然后启用归档位置2.

 

SQL> alter system set log_archive_dest_state_2 =enable scope=both  sid='*';

System altered.

 

然后在备份一下看看。

 

 

RMAN> backup database plus archivelog;

 

Starting backup at 20-SEP-10

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=11 recid=29 stamp=730213616

input archive log thread=1 sequence=15 recid=36 stamp=730217603

input archive log thread=1 sequence=16 recid=40 stamp=730221061

input archive log thread=1 sequence=17 recid=45 stamp=730222093

input archive log thread=2 sequence=1 recid=3 stamp=730194853

input archive log thread=2 sequence=2 recid=4 stamp=730194856

input archive log thread=2 sequence=3 recid=14 stamp=730195685

input archive log thread=2 sequence=4 recid=20 stamp=730196124

input archive log thread=2 sequence=5 recid=23 stamp=730204019

input archive log thread=2 sequence=6 recid=25 stamp=730205106

input archive log thread=2 sequence=7 recid=27 stamp=730206847

input archive log thread=2 sequence=8 recid=28 stamp=730213614

input archive log thread=2 sequence=11 recid=37 stamp=730217603

input archive log thread=2 sequence=12 recid=41 stamp=730221072

input archive log thread=2 sequence=13 recid=44 stamp=730222092

channel ORA_DISK_1: starting piece 1 at 20-SEP-10

channel ORA_DISK_1: finished piece 1 at 20-SEP-10

piece handle=+FLASH_RECOVERY_AREA/orcl/backupset/2010_09_20/annnf0_tag20100920t152820_0.265.730222103 tag=TAG20100920T152820 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:37

Finished backup at 20-SEP-10

 

Starting backup at 20-SEP-10

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=+DATA/orcl/datafile/system.276.730181051

input datafile fno=00003 name=+DATA/orcl/datafile/sysaux.277.730181053

input datafile fno=00002 name=+DATA/orcl/datafile/undotbs1.278.730181053

input datafile fno=00005 name=+DATA/orcl/datafile/undotbs2.284.730181347

input datafile fno=00004 name=+DATA/orcl/datafile/users.279.730181053

channel ORA_DISK_1: starting piece 1 at 20-SEP-10

channel ORA_DISK_1: finished piece 1 at 20-SEP-10

piece handle=+FLASH_RECOVERY_AREA/orcl/backupset/2010_09_20/nnndf0_tag20100920t152900_0.266.730222143 tag=TAG20100920T152900 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:28

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 20-SEP-10

channel ORA_DISK_1: finished piece 1 at 20-SEP-10

piece handle=+FLASH_RECOVERY_AREA/orcl/backupset/2010_09_20/ncsnf0_tag20100920t152900_0.267.730222301 tag=TAG20100920T152900 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 20-SEP-10

 

Starting backup at 20-SEP-10

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=18 recid=49 stamp=730222306

input archive log thread=2 sequence=14 recid=48 stamp=730222306

channel ORA_DISK_1: starting piece 1 at 20-SEP-10

channel ORA_DISK_1: finished piece 1 at 20-SEP-10

piece handle=+FLASH_RECOVERY_AREA/orcl/backupset/2010_09_20/annnf0_tag20100920t153150_0.268.730222313 tag=TAG20100920T153150 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04

Finished backup at 20-SEP-10

 

RMAN>  

 

 

2.2 归档文件的删除问题

 

在上面备份成功后,这里有一个新问题,就是对归档文件的删除。通常我们习惯于在备份完归档之后删除原归档文件,以释放相应的磁盘空间,不过在RAC环境下,只能删除节点1上的归档文件,节点2上的无法删除。因为在节点1上操作不了节点2上的归档文件。

 

这个问题我们可以通过配置通道来解决。一般有几个实例,我们就配置几个通道。 配置通道命令如下:

 

RMAN> configure channel 1 device type disk connect 'sys/oracle@orcl1';

new RMAN configuration parameters:

CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT  'sys/oracle@orcl1';

new RMAN configuration parameters are successfully stored

 

RMAN> configure channel 2 device type disk connect 'sys/oracle@orcl2';

new RMAN configuration parameters:

CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT  'sys/oracle@orcl2';

new RMAN configuration parameters are successfully stored

 

RMAN> 

 

查看通道情况:

RMAN> show channel;

RMAN configuration parameters are:

CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT  'sys/oracle@orcl1';

CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT  'sys/oracle@orcl2';

 


 

中的3.4节: 配置RMAN默认设置 中有介绍。

 

这样设置通道除了能删除其他节点的归档日志外, RMAN还能够智能的对备份中出现"问题"的任务进行再分配,比如说通道1和通道2同时执行备份,其中通道1备份数据文件134,通道2备份数据文件25,假如通道2执行过程中由于某些原因崩溃,RMAN可以自动将任务放回到通道1上执行。

 

 

刚才已经配置过2个不同的通道,现在我们来删除归档文件试试:

 

RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=130 instance=orcl1 devtype=DISK

validation failed for archived log

archive log filename=/u02/rac1_arch/1_16_730181171.dbf recid=38 stamp=730221051

validation failed for archived log

archive log filename=/u02/rac1_arch/1_17_730181171.dbf recid=42 stamp=730222091

validation failed for archived log

archive log filename=/u02/rac1_arch/1_18_730181171.dbf recid=46 stamp=730222305

validation failed for archived log

archive log filename=/u02/rac2_arch/2_1_730181171.dbf recid=1 stamp=730194852

validation failed for archived log

archive log filename=/u02/rac2_arch/2_2_730181171.dbf recid=4 stamp=730194856

validation failed for archived log

archive log filename=/u02/rac2_arch/2_3_730181171.dbf recid=11 stamp=730195680

validation failed for archived log

archive log filename=/u02/rac2_arch/2_4_730181171.dbf recid=19 stamp=730196123

validation failed for archived log

archive log filename=/u02/rac2_arch/2_12_730181171.dbf recid=39 stamp=730221056

validation failed for archived log

archive log filename=/u02/rac2_arch/2_13_730181171.dbf recid=43 stamp=730222091

validation failed for archived log

archive log filename=/u02/rac2_arch/2_14_730181171.dbf recid=47 stamp=730222304

Crosschecked 10 objects

 

RMAN> delete archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=130 instance=orcl1 devtype=DISK

List of Archived Log Copies

Key     Thrd Seq     S Low Time  Name

------- ---- ------- - --------- ----

38      1    16      X 20-SEP-10 /u02/rac1_arch/1_16_730181171.dbf

42      1    17      X 20-SEP-10 /u02/rac1_arch/1_17_730181171.dbf

46      1    18      X 20-SEP-10 /u02/rac1_arch/1_18_730181171.dbf

1       2    1       X 20-SEP-10 /u02/rac2_arch/2_1_730181171.dbf

4       2    2       X 20-SEP-10 /u02/rac2_arch/2_2_730181171.dbf

11      2    3       X 20-SEP-10 /u02/rac2_arch/2_3_730181171.dbf

19      2    4       X 20-SEP-10 /u02/rac2_arch/2_4_730181171.dbf

39      2    12      X 20-SEP-10 /u02/rac2_arch/2_12_730181171.dbf

43      2    13      X 20-SEP-10 /u02/rac2_arch/2_13_730181171.dbf

47      2    14      X 20-SEP-10 /u02/rac2_arch/2_14_730181171.dbf

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted archive log

archive log filename=/u02/rac1_arch/1_16_730181171.dbf recid=38 stamp=730221051

deleted archive log

archive log filename=/u02/rac1_arch/1_17_730181171.dbf recid=42 stamp=730222091

deleted archive log

archive log filename=/u02/rac1_arch/1_18_730181171.dbf recid=46 stamp=730222305

deleted archive log

archive log filename=/u02/rac2_arch/2_1_730181171.dbf recid=1 stamp=730194852

deleted archive log

archive log filename=/u02/rac2_arch/2_2_730181171.dbf recid=4 stamp=730194856

deleted archive log

archive log filename=/u02/rac2_arch/2_3_730181171.dbf recid=11 stamp=730195680

deleted archive log

archive log filename=/u02/rac2_arch/2_4_730181171.dbf recid=19 stamp=730196123

deleted archive log

archive log filename=/u02/rac2_arch/2_12_730181171.dbf recid=39 stamp=730221056

deleted archive log

archive log filename=/u02/rac2_arch/2_13_730181171.dbf recid=43 stamp=730222091

deleted archive log

archive log filename=/u02/rac2_arch/2_14_730181171.dbf recid=47 stamp=730222304

Deleted 10 objects

 

 

 

 

2.3  RMAN 备份的一个完整实例

 

关于搭建RMAN 备份平台的其他相关操作参考Blog


 

 

 

这里我们用nocatalog 模式下的全备备份为例,在运行这个脚本之前需要配置好归档。 具体参考前面的说明。

 

Shell 脚本如下:

 

########################################################################

##   RAC_hot_database_backup.sh      ##

##   created by Tianlesoftware   ##

##        2010-9-21                 ##

#########################################################################

#!/bin/sh

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

# Determine the user which is executing this script.

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

CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`

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

# Put output in .out. Change as desired.

# Note: output directory requires write permission.

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

RMAN_LOG_FILE=${0}.out

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

# You may want to delete the output file so that backup information does

# not accumulate.  If not, delete the following lines.

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

if [ -f "$RMAN_LOG_FILE" ]

then

rm -f "$RMAN_LOG_FILE"

fi

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

# Initialize the log file.

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

echo >> $RMAN_LOG_FILE

chmod 666 $RMAN_LOG_FILE

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

# Log the start of this script.

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

echo Script. $0 >> $RMAN_LOG_FILE

echo ==== started on `date` ==== >> $RMAN_LOG_FILE

echo >> $RMAN_LOG_FILE

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

# Oracle home path.

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

ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_HOME

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

# the Oracle SID of the target database.

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

ORACLE_SID=orcl1   -- 注意,这里需要连接任意节点就可以

export ORACLE_SID

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

# The Oracle DBA user id (account).

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

ORACLE_USER=oracle

export ORACLE_USER

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

# Set the Oracle Recovery Manager name.

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

RMAN=$ORACLE_HOME/bin/rman

 

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

# Print out the value of the variables set by this script.

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

echo >> $RMAN_LOG_FILE

echo   "RMAN: $RMAN" >> $RMAN_LOG_FILE

echo   "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILE

echo   "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE

echo   "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE

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

# Print out the value of the variables set by bphdb.

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

#echo  >> $RMAN_LOG_FILE

#echo   "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILE

#echo   "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILE

#echo   "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILE

#echo   "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILE

#echo   "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE

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

# NOTE: This script. assumes that the database is properly opened. If desired,

# this would be the place to verify that.

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

echo >> $RMAN_LOG_FILE

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

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

# Call Recovery Manager to initiate the backup.

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

CMD_STR="

ORACLE_HOME=$ORACLE_HOME

export ORACLE_HOME

ORACLE_SID=$ORACLE_SID

export ORACLE_SID

$RMAN nocatalog target sys/oracle msglog $RMAN_LOG_FILE append << EOF

RUN {

allocate channel c1 device type disk connect  'sys/oracle@orcl1';

allocate channel c2 device type disk connect  'sys/oracle@orcl2';

BACKUP FORMAT '/u01/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;

sql 'alter system archive log current';

BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;

backup current controlfile tag='bak_ctlfile' format='/u01/backup/ctl_file_%U_%T';

backup spfile tag='spfile' format='/u01/backup/ORCL_spfile_%U_%T';

 

release channel c1;

release channel c2;

}

 

allocate channel for maintenance device type disk connect  'sys/oracle@orcl1';
allocate channel for maintenance device type disk connect 
 'sys/oracle@orcl2';

report obsolete;

delete noprompt obsolete;

crosscheck backup;

delete noprompt expired backup;

list backup summary;

release channel;

#EOF

"

# Initiate the command string

 

if [ "$CUSER" = "root" ]

then

    echo "Root Command String: $CMD_STR" >> $RMAN_LOG_FILE    

    su - $ORACLE_USER -c "$CMD_STR" >> $RMAN_LOG_FILE

    RSTAT=$?

else

    echo "User Command String: $CMD_STR" >> $RMAN_LOG_FILE    

    /bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE

    RSTAT=$?

fi

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

# Log the completion of this script.

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

if [ "$RSTAT" = "0" ]

then

    LOGMSG="ended successfully"

else

    LOGMSG="ended in error"

fi

echo >> $RMAN_LOG_FILE

echo Script. $0 >> $RMAN_LOG_FILE

echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE

echo >> $RMAN_LOG_FILE

/bin/mailx -s "RMAN Backup SID " tianlesoftware@vip.qq.com < $RMAN_LOG_FILE

exit $RSTAT

 

 

脚本中有指定备份文件的位置。 这里要注意,如果是直接备份到硬盘上,那么在两个节点上都要创建对应的备份目录。 因为节点1通道的备份文件会放在节点1上。节点2的备份文件会放在节点2上。 这种把备份文件分开存放,当然不方便我们恢复。

 

开始在这个问题上,也是碰了钉子,后来才弄明白:

RAC RMAN 备份 RMAN-03009 ORA-19504 channel c3 not allocated 错误分析


 

所以,我们可以通过NFS mount 把备份文件放在一个节点。 或者直接把备份文件直接存放在存储上。  

 

关于NFS mount的配置,参考我的Blog

      

这里只是测试,所以采用的是NFS方式。 当然在实际RAC环境下,是放在存储上的。

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

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

注册时间:2009-02-24

  • 博文量
    118
  • 访问量
    188459