title: oracle啟動(dòng)dbstart出錯(cuò)或無(wú)反應(yīng)的解決辦法及自啟動(dòng)
date: 2016/8/20 9:51:07
tags: Oracle
categories: Linux
問(wèn)題一
啟動(dòng)dbstart 報(bào)錯(cuò)
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener Usage: /home/oracle/oracle11g/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME
linux成功安裝Oracle后切換到Oracle用戶后,直接使用dbstart
($ORACLE_HOME/bin中)啟動(dòng)oracle數(shù)據(jù)庫(kù)報(bào)錯(cuò)如上崖面。原因是dbstart調(diào)用的tnslsnr腳本位置有錯(cuò)元咙。解決辦法:
打開該腳本:vim $ORACLE_HOME/bin/dbstart
查找“ORACLE_HOME_LISTENER”變量的定義處,
修改
ORACLE_HOME_LISTENER=$1
為ORACLE_HOME_LISTENER=$ORACLE_HOME
問(wèn)題二
啟動(dòng)dbstart
沒有反應(yīng)巫员,即不報(bào)錯(cuò)也不顯示啟動(dòng)信息
原因是oracle的配置需要修改才能使用dbstart啟動(dòng)對(duì)應(yīng)的數(shù)據(jù)實(shí)例庶香。
解決辦法:
sudo vim /etc/oratab
將orcl:/home/oracle/oracle11g/product/11.2.0/dbhome_1:N
改為orcl:/home/oracle/oracle11g/product/11.2.0/dbhome_1:Y
問(wèn)題三
>dbstart
Can't find init file for Database "orcl".
Database "orcl" NOT started.
原因就是沒有找到init文件 我的數(shù)據(jù)庫(kù)實(shí)例是orcl
這個(gè)文件在$ORACLE_HOME/dbs/
目錄下
cd $ORACLE_HOME/dbs
解決辦法就是建立一個(gè)initorcl.ora的軟連接就可以了
ln -s spfileego.ora initorcl.ora
Oracle自啟動(dòng)
創(chuàng)建開機(jī)自動(dòng)啟動(dòng)數(shù)據(jù)庫(kù)的腳本
開一個(gè)普通的字符終端連接到UbuntuServer,運(yùn)行如下命令:
# vi /etc/init.d/Oracledb
文件內(nèi)容如下:
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/home/oracle/oracle11g/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
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/lsnrctl start"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
rm -f /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
再運(yùn)行如下命令設(shè)置權(quán)限简识,并放到啟動(dòng)腳本中去:
# chmod 755 /etc/init.d/Oracledb
# update-rc.d Oracledb defaults 99
最后:
# vi /etc/oratab
把文件中的N改成Y赶掖,即"orcl:/opt/oracle/product/db:N"修改為"orcl:/opt/oracle/product/db:Y"。