標籤:product sam .com cti basename 執行 use creating tool
http://www.cnblogs.com/edwardcmh/archive/2012/05/11/2495671.html
安裝完畢Oracle 11g每次都得手動啟動 | 停止資料庫(dbstart | dbshut)、監聽器(lsnrctl)、控制台(emtcl)。
設定一下,若手動啟動資料庫的同時監聽器沒有啟動(即啟動資料庫時自動啟動監聽器,停止資料庫時停止監聽器),則需要修改dbstart指令檔:
[[email protected] ~]$ cd /u01/app/oracle/product/11.1.0/db_1/bin/[[email protected] ~]$ vi dbstart
找到下面的程式碼片段:
# First argument is used to bring up Oracle Net ListenerORACLE_HOME_LISTNER=$1 ### 需要將此處的 ORACLE_HOME_LISTNER=$1 修改為 ORACLE_HOME_LISTNER=$ORACLE_HOMEif [ ! $ORACLE_HOME_LISTNER ] ; then echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener" echo "Usage: $0 ORACLE_HOME"else LOG=$ORACLE_HOME_LISTNER/listener.log
同樣,修改dbshut:
[[email protected] ~]$ vi dbshut# The this to bring down Oracle Net ListenerORACLE_HOME_LISTNER=$1### 需要將此處的 ORACLE_HOME_LISTNER=$1 修改為 ORACLE_HOME_LISTNER=$ORACLE_HOMEif [ ! $ORACLE_HOME_LISTNER ] ; then echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener" echo "Usage: $0 ORACLE_HOME"else LOG=$ORACLE_HOME_LISTNER/listener.log
完成後配置Linux啟動指令碼oracle,內容如下:
[[email protected] bin]$ cd /etc/init.d/[[email protected] init.d]$ vi oracle
#!/bin/sh# chkconfig: 345 61 61# description: Oracle 11g AutoRun Services# /etc/init.d/oracle## Run-level Startup script for the Oracle Instance, Listener, and# Web Interfaceexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1export ORACLE_SID=ORCLexport PATH=$PATH:$ORACLE_HOME/binORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]then echo "Oracle startup: cannot start" exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" in start) # Oracle listener and instance startup su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart echo "Oracle Start Succesful!OK." ;; stop) # Oracle listener and instance shutdown su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut echo "Oracle Stop Succesful!OK." ;; reload|restart) $0 stop $0 start ;; *) echo $"Usage: `basename $0` {start|stop|reload|reload}" exit 1esacexit 0
賦予指令碼可執行許可權:
[[email protected] init.d]$ chmod 750 /etc/init.d/oracle
建立連結:
[[email protected] init.d]$ ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle[[email protected] init.d]$ ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
啟用指令碼並添加到服務:
[[email protected] init.d]$ chkconfig --level 345 oracle on[[email protected] init.d]$ chkconfig --add oracle
注意:
這樣的指令碼一般不會啟動執行個體,如果想讓執行個體也隨指令碼一起啟動的話,就需要修改檔案/etc/oratab
如果這個檔案不存在,就要運行指令檔產生它。
[[email protected] init.d]# $ORACLE_HOME/root.sh
# This file is used by ORACLE utilities. It is created by root.sh# and updated by the Database Configuration Assistant when creating# a database.# A colon, ‘:‘, is used as the field terminator. A new line terminates# the entry. Lines beginning with a pound sign, ‘#‘, are comments.## Entries are of the form:# $ORACLE_SID:$ORACLE_HOME:<N|Y>:## The first and second fields are the system identifier and home# directory of the database respectively. The third filed indicates# to the dbstart utility that the database should , "Y", or should not,# "N", be brought up at system boot time.## Multiple entries with the same $ORACLE_SID are not allowed.##orcl:/u01/app/oracle/product/11.1.0/db_1:Y
可以看出,執行個體orcl是自動啟動的(標識為Y),只要在這裡配置好,再配合上面的指令碼,即可實現自動啟動。
Linux配置Oracle 11g自動啟動