本文主要描述了Oracle數據庫自動備份的具體實現步驟,具體內容請參考下文:
錯誤提示1:
message file rman.msb not found verify that oracle_home is set properly ......
錯誤的主要原因:
自動執行的不能夠識別相應的命令,需要在自動備份腳本中顯式的聲明Oracle的環境變量。
錯誤提示2:
standard in must be a tty ......
錯誤的主要原因:
不能在cron使用su或者管道等操作,必須將su命令移動到相關的shell腳本中。
錯誤提示3:
argument value description---------------- target quoted-string connect-string for target databasecatalog quoted-string connect-string for recovery catalognocatalog none if specified, then no recovery catalogcmdfile quoted-string name of input command filelog quoted-string name of output message log filetrace quoted-string name of output debugging message log fileappend none if specified, log is opened in append modedebug optional-args activate debuggingmsgno none show rman-nnnn prefix for all messagessend quoted-string send a command to the media managerpipe string building block for pipe namestimeout integer number of seconds to wait for pipe inputchecksyntax none check the command file for syntax errors------------- --both single and double quotes (" or ") are accepted for a quoted-string.quotes are not required unless the string contains embedded white-space. rman-00571: =======================================rman-00569: =============== error message stack follows ======rman-00571: ================================ rman-00556: could not open cmdfile "backup_ar.rcv" ......
錯誤原因:
需要在cmdfile中指明絕對路徑,不能因為shell腳本調用的cmdfile是在同一個目錄下就可以直接使用文件名或者直接使用./
正確示例代碼:
1、#cron文件
0 12,18 * * * /home/oracle/bak_sh/backup_ar.sh
#表示每天12,18點對數據庫歸檔日至進行全備份
2、入口shell文件,文件名:backup_ar.sh
export oracle_home= /home/u01/app/oracle/oracle/product /10.2.0/db_1export oracle_sid=testexport lang=en_us.utf-8/home/u01/app/oracle /oracle/product/10.2.0/db_1/bin/rman cmdfile = backup_ar.rcv
3、rman備份腳本
connect target /connect catalog rman/rman @rmanrun{allocate channel d1 device type disk;sql "alter system archive log current"; backup archivelog all delete input forma