Oracle 11g安裝成功後在linux建立chkconfig自啟動設定

來源:互聯網
上載者:User

本文參照了網上不同版本的資料,然後自己分別在cent0S6.3的x86與x64兩個虛擬環境均搭建完成,安裝的分別是與系統對應的ORACLE 11Gx86與x64兩個版本,基本能滿足Oracle服務開機啟動需求。

但有幾個小問題,能力有限:

1.啟動或關閉服務報有此提示,但不影響服務啟動,連接埠能正常開啟,ORACLE遠程也能串連。

[root@orcl ~]# service oracle restart Shutdown Oracle: Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.  Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_1/shutdown.log      LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JAN-2013 08:51:27      Copyright (c) 1991, 2009, Oracle.  All rights reserved.      Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.com)(PORT=1521))) TNS-12541: TNS:no listener  TNS-12560: TNS:protocol adapter error   TNS-00511: No listener    Linux Error: 111: Connection refused OK Starting Oracle: Processing Database instance "orcl": log file /home/oracle/app/oracle/product/11.2.0/dbhome_1/startup.log      LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JAN-2013 08:51:34      Copyright (c) 1991, 2009, Oracle.  All rights reserved.      TNS-01106: Listener using listener name LISTENER has already been started Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.  OK

問題已解決,詳見http://showerlee.blog.51cto.com/2047005/1125849

2.切換到oracle使用者重啟oracle服務,會提示輸入密碼,確認輸入root密碼後就能正常啟動。

[root@orcl rc5.d]# su oracle [oracle@orcl rc5.d]$ /etc/init.d/oracle restart Shutdown Oracle: 密碼:

望解答,本人初學LINUX,希望有高手能幫忙指點。

--------------華麗的分割線-------------------

註:開始首先需要修改oracle與root使用者的環境變數

vi ~/.bash_profle

添加如下內容:

umask 022

export ORACLE_BASE=/home/oracle/app

export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1

export ORACLE_SID=orcl

export ORACLE_UNQNAME=$ORACLE_SID

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

一、使用root使用者修改/etc/oratab 檔案:

$ vi /etc/oratab  

orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N

改為:  

orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y

也就是將最後的N改為Y

二、使用oracle使用者修改$ORACLE_HOME/bin/dbstart檔案:

# su - oracle

$ cd  $ORACLE_HOME/bin

$ vi dbstart

找到 ORACLE_HOME_LISTNER=.....這行, 修改成  

ORACLE_HOME_LISTNER=$ORACLE_HOME  

同樣修改dbshut

vi dbshut

ORACLE_HOME_LISTNER=$ORACLE_HOME

注意:是修改,不是增加,可是使用vi的尋找功能尋找:

ORACLE_HOME_LISTNER,然後進行修改,修改後儲存

三、測試回合 dbshut, dbstart 看能否啟動oracle 服務及listener服務:

關閉,或者啟動時可能會報錯,提示dbstart或dbshut許可權不足.

1.修改dbstart和dbshut的記錄檔的許可權:

$su - root

#cd $ORACLE_HOME

#chown  oracle:oinstall $ORACLE_HOME/startup.log

#chown oracle:oinstall  $ORACLE_HOME/shutdown.log

#chown oracle:oinstall  $ORACLE_HOME/listener.log

2.執行相應的指令碼進行測試 (可選)

#su - oracle

$cd  $ORACLE_HOME/bin

$./dbstart (./dbshut)

$ ps -efw | grep ora_

$  lsnrctl status

$ ps -efw | grep LISTEN | grep -v grep

四:建立服務

$su -  root

# cd /etc/rc.d/init.d/

# vi oracle

-----指令碼-----

#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for Oracle Databases  

# /etc/rc.d/init.d/oracle

export ORACLE_BASE=/home/oracle/app

export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1

export ORACLE_SID=orcl

export ORACLE_UNQNAME=$ORACLE_SID

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

echo "Oracle startup: cannot start"

exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

start)

# Oracle listener and instance startup

echo -n "Starting Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"

touch /var/lock/Oracle

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"

#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"

echo "OK"

;;

stop)

# Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"

#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/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.