这篇文章主要介绍如何安装oracle设置变量,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
1.手工方法
2.oraenv工具
3.oraset脚本
在/etc/下创建oraset,权限设置为chown oracle:oinstall /etc/oraset
oraset内容:
#!/bin/bash
# Sets Oracle environment variables.
# Setup: 1. Put oraset file in /etc(Linux), in /var/opt/oracle(Solaris)
# 2. Ensure /etc or /var/opt/oracle is in $PATH
# Usage: batch mode: . oraset <SID>
# menu mode: . oraset
#=======================================================
if [ -f /etc/oratab ]; then
OTAB=/etc/oratab
elif [ -f /var/opt/oracle/oratab ]; then
OTAB=/var/opt/oracle/oratab
else
echo 'oratab file not found.'
exit
fi
#
if [ -z $1 ]; then
SIDLIST=$(egrep -v '#|/*' ${OTAB} | cut -f1 -d:)
# PS3 inmdicates the prompt to be used for the Bash select command.
PS3='SID?'
select sid in ${SIDLIST}; do
if [ -n $sid ]; then
HOLD_SID=$sid
break;
fi
doneelse
if egrep -v '#|/*' ${OTAB} | grep -w "${1}:">/dev/null; then
HOLD_SID=$1
else
echo "SID: $1 not found in $OTAB"
fi
shiftfi
#
ORACLE_SID=$HOLD_SID
export ORACLE_SID
export ORACLE_HOME=$(egrep -v '#|/*' ${OTAB} | grep -w $ORACLE_SID:|cut -f2 -d:)
export ORACLE_BASE=${ORACLE_HOME%%/product*}
export TMP=$ORACLE_BASE/../tmp
export TMPDIR=$TMP
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ADR_BASE=$ORACLE_BASE/diag
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
然后在oracle用户的.bashrc里面添加:
source /etc/oraset xxxx
注:
1. xxxx为你SID的名称。
2. 路径以个人安装为准。
以上是“如何安装oracle设置变量”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/206501.html