关于数据库自动备份的问题解决(crontab故障)

有时候明知道怎么回事,就是一时想不起怎么解决了,或者是不知道怎么写了

下面是我对自动备份的故障解决历程:

问题描述:
oracle自动备份脚本的实现。

错误提示1:
Message file RMAN.msb not found

[@more@]

有时候明知道怎么回事,就是一时想不起怎么解决了,或者是不知道怎么写了

下面是我对自动备份的故障解决历程:

问题描述:
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文件
31 23 * * * /home/oracle/backup_archive2.sh

#表示每天23:31点对数据库归档日至进行备份

2、入口shell文件,文件名:backup_archive2.sh
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=myorcl
export LANG=en_US.UTF-8
/u01/app/oracle/product/10.2.0/db_1/bin/rman cmdfile = /home/oracle/backuplev2.rcv
msglog=backup2.log

3、rman备份脚本
connect target sys/mengfm
connect rcvcat rman_meng/rman_meng@myorcl
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup incremental level 2 tag 'db2' format '/home/oracle/backup/db2/db2%u_%s_%p' database skip readonly;
sql 'alter system archive log current';
backup filesperset 3 format '/home/oracle/backup/db2/arch%u_%s_p' archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}

我这里做了一个2级备份,0级和1 级也想应的写到另外的脚本里。

学习入口(来自论坛):
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
脚本中显示的标出环境变量,是避免出错及少出错的一个方法。应当记住。

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

转载于:http://blog.itpub.net/330796/viewspace-881300/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值