Oracle資料庫自動備份的實現曆程

來源:互聯網
上載者:User

問題描述:

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 database
catalog   quoted-string connect-string for recovery catalog
nocatalog  none      if specified, then no recovery catalog
cmdfile   quoted-string name of input command file
log     quoted-string name of output message log file
trace    quoted-string name of output debugging message log file
append    none      if specified, log is opened in append mode
debug    optional-args activate debugging
msgno    none      show RMAN-nnnn prefix for all messages
send     quoted-string send a command to the media manager
pipe     string     building block for pipe names
timeout   integer    number of seconds to wait for pipe input
checksyntax 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_1
export Oracle_SID=test
export 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@rman
run{
allocate channel d1 device type disk;
sql 'alter system archive log current';
backup archivelog all delete input
format '/opt/rmanback/full_%u_%p_%c.ac' filesperset = 3;
release channel d1;
}

解決方案:

1、兩種辦法

一是用root的crontab,*/2 * * * * a.sh --》su - Oracle -c a.sh

一是在a.sh裡加上Oracle的環境。

2、我們做的cron測試:

執行個體:

Vi /etc/cron.minly/new.sh

內容:

Su – Oracle –c “/home/Oracle/mginfo.sh”

Vi /home/Oracle/mginfo.sh

內容:

Exp mginfotech/mginfotech file=mginfotech.dmp log=mginfotech.log

Vi /etc/crontab

內容:

59 23 * * * root run-parts /etc/cron.minly

每晚23:59分鐘執行

cron中無法讀取環境變數

在shell中顯示地export環境變數

export Oracle_HOME=/opt/ora9/product/9.2

export Oracle_SID=Oracle

export NLS_LANG=xxxxx

然後再試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.