Oracle環境變數設定指令碼

來源:互聯網
上載者:User

標籤:

每次都傻乎乎的往bashrc裡面寫環境變數,感覺不任性。於是,看了本書瞭解了/etc/oratab這個東東後,參考著書也寫了一個設定Oracle環境變數的指令碼。

在/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/oratabelif [ -f /var/opt/oracle/oratab ]; then    OTAB=/var/opt/oracle/oratabelse    echo ‘oratab file not found.‘    exitfi#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_SIDexport ORACLE_SIDexport ORACLE_HOME=$(egrep -v ‘#|\*‘ ${OTAB} | grep -w $ORACLE_SID:|cut -f2 -d:)export ORACLE_BASE=${ORACLE_HOME%%/product*}export TMP=$ORACLE_BASE/../tmpexport TMPDIR=$TMPexport TNS_ADMIN=$ORACLE_HOME/network/adminexport ADR_BASE=$ORACLE_BASE/diagexport PATH=$PATH:$ORACLE_HOME/binexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

然後在oracle使用者的.bashrc裡面添加:

source /etc/oraset xxxx

註:

1. xxxx為你SID的名稱。

2. 路徑以個人安裝為準。

3. 誰知道怎麼在Live Writer的代碼亮度外掛程式裡添加行號和奇偶行不同色?

 

附:

系統:Red Hat Enterprise Linux7.0

Oracle:12c Enterprise

 

轉載請註明出處····································

Oracle環境變數設定指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.