一 环境
OS
$cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
$uname -a
Linux appserver1 2.6.18-164.el5PAE #1 SMP Tue Aug 18 15:59:11 EDT 2009 i686 i686 i386 GNU/Linux
DB
$sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Nov 14 09:57:08 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>二 描述
最近安装GC,在要监控的系统上安装agent后,发现同一个terminal手动设置完ORACLE_SID变量后再敲sqlplus命令可以进入数据库.但用sql脚本却进不了数据库.会报数据库没有启动.最终确定是由于修改了用户环境变量ORACLE_BASE的原因.
三 结构
四 步骤
现象重现
1.terminal中手敲命令进入rman
$export ORACLE_SID=drugsync
$rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Nov 14 09:50:19 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: DRUGSYNC (DBID=485937336, not open)
RMAN> exit
Recovery Manager complete.
2.rman备份脚本
$cd /home/oracle10/db_script/rman/drugsync/
$cat rman_drugsync_level0.sh
#!/bin/bash
export ORACLE_BASE=/home/oracle10
export ORACLE_HOME=$ORACLE_BASE/database/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=drugsync
dt=`date +%m%d`
rman_backup_script=/home/oracle10/db_script/rman/drugsync
rman_backup_dir=/home/oracle10/backup/rman/drugsync
rman target / >$rman_backup_script/rman_${ORACLE_SID}_level0_${dt}.log <
run{
backup as compressed backupset incremental level 0 database format
'$rman_backup_dir/db_%d_%T_%s_%p_%t' plus archivelog
format='$rman_backup_dir/arch_%d_%T_%s_%p_%t' delete all input;
}
run{
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}
exit
EOF
3.执行备份脚本并查看执行过程日志(与步聚1,2同一个terminal中执行的)
$nohup ./rman_drugsync_level0.sh &
[1] 10234
$nohup: appending output to “nohup.out”
[1]+ Exit 1 nohup ./rman_drugsync_level0.sh
$cat rman_drugsync_level0_1114.log
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Nov 14 09:51:07 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> 2> 3>
Starting backup at 2011-11-14 09:51:08
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 11/14/2011 09:51:08
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
RMAN> 2> 3> 4> 5>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of crosscheck command at 11/14/2011 09:51:08
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
RMAN>
Recovery Manager complete.
$
4.显示用户环境变量
$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export ORACLE_SID=drugsync
export ORACLE_BASE=/home/oracle10/database
export ORACLE_HOME=$ORACLE_BASE/10.2.0/db_1
export PATH=$ORACLE_HOME/bin/:$PATH
export NLS_LANG=american_america.zhs16gbk
export EM_INSTALL_PASSWORD=oracle1
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
注意到脚本里的ORACLE_BASE=export ORACLE_BASE=/home/oracle10 与用户环境变量里的ORACLE_BASE=/home/oracle10/database 不相同.将ORACLE_BASE修改一致情况消除.(由于agent安装的时候会将oraInventory安装到ORACLE_BASE目录的上一级.由于/home/oracle10此base目录的上一级oracle无权操作.因此将ORACLE_BASE更改为/home/oracle10/database.个人总结
最开始忘记了这条修改,而将问题的原因总结到系统上面.后经SA提示仔细分析两文件后恍然忘记了BASE这条修改.在10g的时候以前一直忽略的ORACLE_BASE变量,以为可设可不设.在这里出了问题.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11780477/viewspace-710902/
,如需转载,请注明出处,否则将追究法律责任。