免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3470 | 回复: 11

又一RMAN自动备份的问题,请教了。 [复制链接]

论坛徽章:
0
发表于 2006-11-21 12:30 |显示全部楼层
$ more ctrl.sh
#!/bin/sh
# -----------------------------------------------------------------
# Backup script generated on 12/04/03 17:11:32
# Shell Script name: HotDBFull.sh
#
# VERITAS NetBackup for oracle on UNIX
$VRTScprght: Copyright 1993 - 2003 VERITAS Software Corporation, All Rights Reserved $ #
# -----------------------------------------------------------------

ORACLE_HOME=/opt/oracle/db01/app/oracle/product/8.1.7
ORACLE_SID=inms
RMAN_LOG_FILE=/opt/oracle/rman/rman.log
TARGET_CONNECT_STR=system/manager
CATALOG_CONNECT_STR=rman/rman@rman
RUN_AS_USER=root
RMAN=$ORACLE_HOME/bin/rman
CUSER=`id | cut -d"(" -f2 | cut -d ")" -f1`

# -----------------------------------------------------------------
# If this script is executed from a NetBackup schedule, NetBackup
# sets an NB_ORA environment variable based on the schedule type.
# The NB_ORA variable is then used to dynamically set BACKUP_TYPE.
# For example, when:
#     schedule type is                BACKUP_TYPE is
#     ----------------                --------------
# Automatic Full                     INCREMENTAL LEVEL=0
# Automatic Differential Incremental INCREMENTAL LEVEL=1
# Automatic Cumulative Incremental   INCREMENTAL LEVEL=1 CUMULATIVE

# For user initiated backups, BACKUP_TYPE defaults to incremental
# level 0 (full). To change the default for a user initiated
# backup to incremental or incremental cumulative, uncomment
# one of the following two lines.
# BACKUP_TYPE="INCREMENTAL LEVEL=1"
# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"

# Note that we use incremental level 0 to specify full backups.
# That is because, although they are identical in content, only
# the incremental level 0 backup can have incremental backups of
# level > 0 applied to it.
# -----------------------------------------------------------------

#if [ "$NB_ORA_FULL" = "1" ]
#then
#    BACKUP_TYPE="INCREMENTAL LEVEL=0"
#elif [ "$NB_ORA_INCR" = "1" ]
#then
#    BACKUP_TYPE="INCREMENTAL LEVEL=1"
#elif [ "$NB_ORA_CINC" = "1" ]
#then
#    BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
#elif [ "$BACKUP_TYPE" = "" ]
#then
#    BACKUP_TYPE="INCREMENTAL LEVEL=0"
#fi


# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------

#> $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

# -----------------------------------------------------------------
# rman commands for database ORCL.
# -----------------------------------------------------------------

CMD="
ORACLE_HOME=/opt/oracle/db01/app/oracle/product/8.1.7
export ORACLE_HOME
ORACLE_SID=inms
export ORACLE_SID
$RMAN target $TARGET_CONNECT_STR rcvcat $CATALOG_CONNECT_STR msglog $RMAN_LOG_FILE append <<EOF
run { execute script 'hot_database_backup_ctrl';}
EOF
"

if [ "$CUSER" = "root" ]
then
    su - $RUN_AS_USER -c "$CMD" >> $RMAN_LOG_FILE
    RSTAT=$?
else
    sh -c "$CMD" >> $RMAN_LOG_FILE
    RSTAT=$?
fi


if [ "$RSTAT" = "0" ]
then
    LOGMSG="ended successfully"
else
    LOGMSG="ended in error"
fi

# -----------------------------------------------------------------
# Log the completion of this script.
# -----------------------------------------------------------------

echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE

exit $RSTAT


RMAN> print script hot_database_backup_ctrl;

RMAN-03027: printing stored script: hot_database_backup_ctrl
{
allocate channel c1 type disk;
backup current controlfile  format '/opt/oracle/hot_backup/ctrl%t%s.%p';
}



$ more rman.log

Sun Microsystems Inc.   SunOS 5.8       Generic Patch   October 2001
You have new mail.

Recovery Manager: Release 8.1.7.3.0 - Production

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database: ORA-01031: insufficient privileges


Script ./ctrl.sh
==== ended in error on Tue Nov 21 12:15:46 CST 2006 ====

在rman下运行以下命令没问题,请各位大虾帮忙分析下为什么放在脚本里会出现这种错误呢?
RMAN>run { execute script 'hot_database_backup_ctrl';}

论坛徽章:
0
发表于 2006-11-21 16:21 |显示全部楼层
你可以用SYS用户连接TARGET数据库试试。

论坛徽章:
0
发表于 2006-11-21 16:41 |显示全部楼层
是把这里改掉吗?

TARGET_CONNECT_STR=system/manager

改成“TARGET_CONNECT_STR=system/manager as sysdba”可以吗?

论坛徽章:
0
发表于 2006-11-21 16:48 |显示全部楼层
刚才试了一下,不是这样改:(

小弟愚鲁,请大虾明示。

论坛徽章:
0
发表于 2006-11-21 17:06 |显示全部楼层
TARGET_CONNECT_STR=" 'sys/manager as sysdba' "

[ 本帖最后由 exitgogo 于 2006-11-21 17:19 编辑 ]

论坛徽章:
0
发表于 2006-11-21 17:13 |显示全部楼层
as:error:cannot open input file "sysdba"

论坛徽章:
0
发表于 2006-11-21 18:39 |显示全部楼层
原帖由 exitgogo 于 2006-11-21 17:06 发表
TARGET_CONNECT_STR=" 'sys/manager as sysdba' "


" \'sys/manager as sysdba\' "

论坛徽章:
0
发表于 2006-11-22 09:13 |显示全部楼层
Sun Microsystems Inc.   SunOS 5.8       Generic Patch   October 2001
You have new mail.

Recovery Manager: Release 8.1.7.3.0 - Production

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database: ORA-01031: insufficient privileges

Script ./ctrl.sh
==== ended in error on Wed Nov 22 09:10:20 CST 2006 ====



已改为
TARGET_CONNECT_STR="\'sys/manager as sysdba\'"
问题依旧,茫然中…………

论坛徽章:
0
发表于 2006-11-22 10:45 |显示全部楼层
1. su - oracle
2. 核查ORACLE_SID是否正确设置:
    echo $ORACLE_SID

2. rman target / catalog xx/xxx@xx log=xxxx
3. run {
          execute script 'xxxxx';
    }

[ 本帖最后由 numenhuang 于 2006-11-22 10:48 编辑 ]

论坛徽章:
0
发表于 2006-11-22 13:20 |显示全部楼层
作了如下调整后脚本运行正常:


“ORACLE_HOME=/opt/oracle/db01/app/oracle/product/8.1.7”
改为“ORACLE_HOME=/opt/oracle/db01/app”;
“TARGET_CONNECT_STR=system/manager”
改为“TARGET_CONNECT_STR="\'sys/manager\'"”;
“CATALOG_CONNECT_STR=rman/rman@rman”
改为“CATALOG_CONNECT_STR=rman/rman”;
“RUN_AS_USER=root”
改为“RUN_AS_USER=oracle”。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP