執行dbstart啟動數據庫時報錯
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
看來是listener服務沒有起來,但是執行lsnrctl start卻能啟動listener服務。
搜索dbstart文件中的tnslsnr字符串
grep tnslsnr dbstart
返回結果:
if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo "Failed to auto-start Oracle Net Listene using $ORACLE_HOME_LISTNER/bin/tnslsnr"
看來可能是ORACLE_HOME_LISTNER環境變量引起的,查找 ORACLE_HOME_LISTNER
grep ORACLE_HOME_LISTNER dbstart
返回結果
# 3) Set ORACLE_HOME_LISTNER
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
LOG=$ORACLE_HOME_LISTNER/listener.log
if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
$ORACLE_HOME_LISTNER/bin/lsnrctl start >> $LOG 2>&1 &
export VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`
echo "Failed to auto-start Oracle Net Listene using $ORACLE_HOME_LISTNER/bin/tnslsnr"
$LOGMSG "Restart Oracle Net Listener using an alternate ORACLE_HOME_LISTNER: lsnrctl start"
其中有一段給ORACLE_HOME_LISTNER環境變量賦值,但是這個路徑是不對的,編輯dbstart文件
vi dbstar
將該行改為export ORACLE_HOME_LISTNER=$ORACLE_HOME
保存退出,然后執行dbstart就沒問題了。呵呵
想系統啟動是自動啟動數據庫可以通過修改/etc/rc.d/rc.local文件
一開始我寫的命令是
su oracle -c ora_App/product/10.2.0/db_1/bin/lsnrctl start
su oracle -c ora_App/product/10.2.0/db_1/bin/dbstart
但是su oracle -c ora_App/product/10.2.0/db_1/bin/lsnrctl start是參數start不起作用,它進入了lsnrctl命令提示符,并沒有啟動,后來把命令用雙引號引起來就可以了如下:
su oracle -c "ora_App/product/10.2.0/db_1/bin/lsnrctl start"
是可以啟動了,但是啟動時報錯如下:
Message 1053 not found; No message file for product=network, facility=TNSTNS-12541: Message 12541 not found; No message file for product=network, facility=TNS
TNS-12560: Message 12560 not found; No message file for product=network, facility=TNS
但是如果我用oracle用戶登陸執行lsnrctl start就不報錯,看來是在root用戶中執行su oracle -c "ora_App/product/10.2.0/db_1/bin/lsnrctl start"有些Oracle環境變量沒有設置。查了一下su 命令的參數,其中有個-l參數
-.-l或--login 改變身份時,也同時變更工作目錄,以及HOME,SHELL,USER,LOGNAME。此外,也會變更PATH變量。
加上參數
su oracle -lc "ora_App/product/10.2.0/db_1/bin/lsnrctl start"