title: oracle啟動dbstart出錯或無反應的解決辦法及自啟動
date: 2016/8/20 9:51:07
tags: Oracle
categories: Linux
問題一
啟動dbstart 報錯
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中)啟動oracle數(shù)據(jù)庫報錯如上。原因是dbstart調(diào)用的tnslsnr腳本位置有錯。解決辦法:
打開該腳本:vim $ORACLE_HOME/bin/dbstart
查找“ORACLE_HOME_LISTENER”變量的定義處,
修改
ORACLE_HOME_LISTENER=$1
為ORACLE_HOME_LISTENER=$ORACLE_HOME
問題二
啟動dbstart沒有反應,即不報錯也不顯示啟動信息
原因是oracle的配置需要修改才能使用dbstart啟動對應的數(shù)據(jù)實例。
解決辦法:
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
問題三
>dbstart
Can't find init file for Database "orcl".
Database "orcl" NOT started.
原因就是沒有找到init文件 我的數(shù)據(jù)庫實例是orcl
這個文件在$ORACLE_HOME/dbs/目錄下
cd $ORACLE_HOME/dbs
解決辦法就是建立一個initorcl.ora的軟連接就可以了
ln -s spfileego.ora initorcl.ora
Oracle自啟動
創(chuàng)建開機自動啟動數(shù)據(jù)庫的腳本
開一個普通的字符終端連接到UbuntuServer,運行如下命令:
# 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
再運行如下命令設(shè)置權(quán)限,并放到啟動腳本中去:
# 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"。