一、linux下無法啟動sqlplus
問題描述:
[root@localhost oracle]# su - oracle
[oracle@localhost oracle]$ sqlplus "as/sysdba"
-bash: sqlplus: command not found
[oracle@localhost oracle]$ /u01/app/oracle/oracle/product/11.1.0/db_1/bin/sqlplus
Error 6 initializing SQL*Plus
Message file sp1.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
[oracle@localhost oracle]$
解決方案:
由於環境變數沒有設定導致的。可以編輯.profile檔案可以進行環境變數設定的。
開啟/etc/profile底部插入
export ORACLE_SID=demo1(資料庫執行個體id)
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
儲存關閉,重啟系統或執行source /ect/profile設定立即生效。
二、啟動資料庫執行個體,分為兩步:第一步,啟動監聽;第二步,啟動資料庫執行個體。
1.進入到sqlplus啟動執行個體
[oracle@redhat ~]$ su - oracle --“切換到oracle使用者”
Password:
[oracle@redhat ~]$ lsnrctl start --“開啟監聽”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:06:40
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /home/oracle/product/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/product/10g/network/admin/listener.ora
Log messages written to /home/oracle/product/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-OCT-2009 19:06:40
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/product/10g/network/admin/listener.ora
Listener Log File /home/oracle/product/10g/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@redhat ~]$ sqlplus /nolog --“進入到sqlplus”
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Oct 14 19:06:45 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba --“串連到sysdba”
Connected to an idle instance.
SQL> startup --“啟動資料庫執行個體”
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 88082024 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
SQL> shutdown immediate --“關閉資料庫執行個體”
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@redhat ~]$ lsnrctl stop --“關閉監聽”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:08:06
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
The command completed successfully
2.用dbstart和dbshut啟動和關閉資料庫執行個體
先啟動監聽 lsnrctl start
啟動執行個體 dbstart
使用dbstart命令啟動資料庫比較方便,但是在linux上安裝好oracle之後,第一次使用dbstart命令可能會報如下錯誤:
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
看起來貌似是監聽沒有起來,可是實際上,監聽可以成功啟動。
我們來看一下dbstart指令碼,該指令碼放在$ORACLE_HOME/bin下面。
搜尋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=/ade/vikrkuma_new/oracle
中,指定的路徑不對,需要對這一行重新編輯,使其路徑制定到$ORACLE_HOME
用vi編輯dbstart,將ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle更改為
export ORACLE_HOME_LISTNER=$ORACLE_HOME
然後儲存退出,此時再運行dbstart,已經不報錯了,但是沒有任何反應,ps一下進程,沒有oracle的進程,說明oracle執行個體沒有正常啟動。
dbstop 同上設定。
此時的原因是在/etc/oratab的設定問題,我們cat一下,發現
demo1:/home/oracle/product/11.1.0/db_!:N
最後設定的是"N"(我的環境中只有一個執行個體,因此只有一行配置語句),我們需要把“N”修改為“Y”。
以上的工作做好之後,dbstart就可以正常使用了:
[oracle@redhat bin]$ lsnrctl start --“啟動監聽”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:44:53
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /home/oracle/product/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/product/10g/network/admin/listener.ora
Log messages written to /home/oracle/product/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-OCT-2009 19:44:53
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/product/10g/network/admin/listener.ora
Listener Log File /home/oracle/product/10g/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC2)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@redhat bin]$ dbstart --“啟動資料庫執行個體”
Processing Database instance "zgz": log file /home/oracle/product/10g/startup.log
[oracle@redhat bin]$ dbshut --“關閉資料庫執行個體”
[oracle@redhat bin]$ lsnrctl stop --“關閉監聽”
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-OCT-2009 19:45:33
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC2)))
The command completed successfully
三、如何使資料庫執行個體和linux系統一起啟動
在/etc/rc.d/rc.local中加入如下語句即可實現同系統啟動執行個體:
su - oracle -c "lsnrctl start"
su - oracle -c "dbstart"
四、oracle em(enterprise managment) 打不開
問題描述:
http://localhost.localdomain:1158/em 提示該頁無法顯示。
解決方案:
--檢查dbconsole服務是否啟動,如果沒啟動執行2,3
1.emctl status dbconsole
--設定ORACLE_SID
--2.SET ORACLE_SID=&ORACLE_SID(我沒執行這個,因為在/etc/profile裡設定了export ORACLE_SID=demo1)
--啟動DBCONSOLE
3.emctl start dbconsole
--設定好ORACLE_SID後輸入EMCTL可以查看到此命令的協助
五、啟動isqlplus
[oracle@graduate ~]$ isqlplusctl start
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle. All rights reserved.
warning, got duplicate tcp line.
Starting iSQL*Plus ...
iSQL*Plus started.
http://www.uplook.cn/kbase-Index-show-view18369.html