在linux下使用dbstart和dbshut啟動和關閉db!

warehouse發表於2008-08-07

版本10.2

在9i下dbstart存在一bug:dbstart啟動時在$ORACLE_HOME/dbs下尋找initSID.ora,事實上在該目錄下不存在這個pfile,在9i 已經使用了spfile,所以要想正常透過dbstart啟動db,需要在目錄$ORACLE_HOME/dbs下建立一個initSID.ORA檔案,10g中我發現修正了這一問題。不過10g中dbstart在自動啟動listener時存在一問題:dbstart指令碼中存在下面一行:#ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

致使啟動是出現錯誤:

[oracle@xys bin]$ dbstart
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
Processing Database instance "TEST": log file /opt/app/oracle/product/10.2.0/db_1/startup.log

該錯誤顯示listener不能正常啟動,但是instance可以正常啟動,原因就是ORACLE_HOME_LISTNER設定的不對,我們修正一下,註釋下面一行,增加:

#ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

ORACLE_HOME_LISTNER=$ORACLE_HOME即可

[@more@]

修正之後啟動和停止測試如下:

[oracle@xys bin]$ dbstart
Processing Database instance "TEST": log file /opt/app/oracle/product/10.2.0/db_1/startup.log
[oracle@xys bin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 07-AUG-2008 12:17:51

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 07-AUG-2008 12:17:27
Uptime 0 days 0 hr. 0 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xys)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST" has 2 instance(s).
Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
Instance "TEST", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
Instance "TEST", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@xys bin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 7 12:17:55 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select status from v$instance;

STATUS
------------
OPEN

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@xys bin]$ dbshut

shutdown之後發現listener並沒有stop,檢視dbshut指令碼發現該指令碼中沒有lsnrctl stop命令,也就是說dbshut只是停止instance而並不會停止listener,如果想讓dbshut在停止instance的同時也停止listener,可以簡單的在dbshut的結尾加上lsnrctl stop.
[oracle@xys bin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 07-AUG-2008 12:18:48

Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 07-AUG-2008 12:17:27
Uptime 0 days 0 hr. 1 min. 20 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xys)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST" has 1 instance(s).
Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@xys bin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 7 12:19:11 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> exit
Disconnected
[oracle@xys bin]$ echo $ORACLE_SID
TEST
[oracle@xys bin]$

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1008653/,如需轉載,請註明出處,否則將追究法律責任。

相關文章