Problem description:
Oracle automatic backup script implementation.
Error 1:
Message file RMAN. msb not found
Verify that Oracle_HOME is set properly
......
Error cause:
Automatically executed commands cannot be identified. You must explicitly declare the Oracle environment variables in the automatic backup script.
Error 2:
Standard in must be a tty
......
Error cause:
You cannot use su or MPs queues in cron. You must move the su command to the shell script.
Error 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"
。。。。。。
Error cause:
You must specify the absolute path in the upload file. You cannot directly use the file name or directly use the file name because the external file called by the shell script is in the same directory ./
Correct sample code:
1. # cron File
0 ****/home/Oracle/bak_sh/backup_ar.sh
# Indicates that a full backup is performed on the database archiving day at every day.
2. shell file, file name: 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 backup script
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;
}
Solution:
1. Two Methods
First, use the root crontab, */2 ***** a. sh -- "su-Oracle-c a. sh
First, add the Oracle environment to a. sh.
2. cron test:
Instance:
Vi/etc/cron. minly/new. sh
Content:
Su-Oracle-c "/home/Oracle/mginfo. sh"
Vi/home/Oracle/mginfo. sh
Content:
Exp mginfotech/mginfotech file = mginfotech. dmp log = mginfotech. log
Vi/etc/crontab
Content:
59 23 *** root run-parts/etc/cron. minly
Run at every night
Cron cannot read environment variables
Export environment variable displayed in shell
Export Oracle_HOME =/opt/ora9/product/9.2
Export Oracle_SID = Oracle
Export NLS_LANG = xxxxx
Then try again