天天看點

RAC RMAN 備份 RMAN-03009 ORA-19504 ORA-27040 RMAN-06012 channel c3 not allocated 錯誤分析

把之前的RMAN 單執行個體的備份腳本修改了一下,用來備份RAC 系統。

Linux 平台下 RMAN 全備 和 增量備份 shell 腳本

修改之後的備份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 <this file name>.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 " [email protected] < $RMAN_LOG_FILE

exit $RSTAT

但是,運作該備份腳本報錯。 部分運作日志如下:

allocated channel: c1

channel c1: sid=129 instance=orcl1 devtype=DISK

allocated channel: c3

channel c3: sid=131 instance=orcl2 devtype=DISK

Starting backup at 22-SEP-10

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

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

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

channel c1: starting piece 1 at 22-SEP-10

channel c3: starting full datafile backupset

channel c3: specifying datafile(s) in backupset

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

channel c3: starting piece 1 at 22-SEP-10

RMAN-03009: failure of backup command on c3 channel at 09/22/2010 05:11:10

ORA-19504: failed to create file "/u01/backup/orcl_19logo39_1_1_20100922"

ORA-27040: file create error, unable to create file

Linux Error: 2: No such file or directory

channel c3 disabled, job failed on it will be run on another channel

channel c1: finished piece 1 at 22-SEP-10

piece handle=/u01/backup/orcl_18logo39_1_1_20100922 tag=ORCL_HOT_DB_BK comment=N

ONE

channel c1: backup set complete, elapsed time: 00:01:02

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

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

channel c1: starting piece 1 at 22-SEP-10

channel c1: finished piece 1 at 22-SEP-10

piece handle=/u01/backup/orcl_1alogo57_1_1_20100922 tag=ORCL_HOT_DB_BK comment=N

ONE

...

released channel: c1

released channel: c3

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

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

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

RMAN-03002: failure of release command at 09/22/2010 05:14:03

RMAN-06012: channel: c3 not allocated

對這個錯誤的分析過程如下:

1.      日志有c3 通道不能釋放的問題。

  C3 通道是節點2上的通道,非本地通道。 懷疑是這個地方有問題,單獨做一個簡單的測試:

RMAN> run

{

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

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

delete expired archivelog all;

release channel c1;

release channel c2;

}

2> 3> 4> 5> 6> 7> 8>

allocated channel: c2

channel c2: sid=147 instance=orcl2 devtype=DISK

allocated channel: c1

channel c1: sid=147 instance=orcl1 devtype=DISK

specification does not match any archive log in the recovery catalog

released channel: c1

released channel: c2

這個實驗結果證明,報錯和通道沒有關系。

2.  備份目錄的權限問題

allocated channel: c3

channel c3: sid=131 instance=orcl2 devtype=DISK

RMAN-03009: failure of backup command on c3 channel at 09/22/2010 05:11:10

ORA-19504: failed to create file "/u01/backup/orcl_19logo39_1_1_20100922"

ORA-27040: file create error, unable to create file

Linux Error: 2: No such file or directory

channel c3 disabled, job failed on it will be run on another channel

從這裡我們可以看出,通道c3 是建立成功了的。 但是在通道上c3上不能建立備份集的檔案。

因為我實在節點1上做的RMAN 備份。 開始以為全部的備份檔案都會放在節點1上。 是以隻在節點1上建立了備份目錄。 即/u01/backup目錄。 在節點2上沒有建立。 問題就出在這個地方。 我在就節點2上建立了/u01/backup目錄,并賦予了777權限後,備份成功。

最後檢查2個備份檔案。 發現一個問題orcl1通道的備份集檔案會存放在節點1的備份目錄上(/u01/backup),orcl2通道的備份檔案會放在orcl2的備份目錄上(/u01/backup).  因為它的備份檔案存放在2個地方,是以恢複的時候會很麻煩。 最了解的狀态,是所有的備份檔案都存放在一個節點,或者共享裝置上。

是以,要解決這個有2種方法:

(1)    使用NFS。 在一個節點上共享備份目錄,在另一個節點挂載這個共享。 這個所有的檔案就會在一個節點上了。

關于NFS 的配置,參考Blog:

Linux NFS 和 Samba 共享配置

(2)    使用存儲。

對于NFS mount, 存在着一個比較嚴重的問題。就是NFS mount在一個節點沒有啟動的情況下,會極大的影響另一個節點的性能。也就是說,如果RAC一個節點出現故障,導緻機器無法正常啟動的話,另一個節點不但要承擔全部的資料庫壓力,而且還會受到nfs mount帶來的性能負載,基本上導緻這個節點無法正常工作。是以從性能上的考慮,使用NFS mount的時候一定要慎重。是以對于RAC 的RMAN 備份檔案,最好還是存放在存儲上。

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

DBA1 群:62697716(滿); DBA2 群:62697977(滿)

DBA3 群:63306533;     聊天 群:40132017

--加群需要在備注說明SGA的組成部分,否則拒絕申請