Orale自動啟動以及關閉指令碼_linux
目的
--- 能夠實現開機啟動Oracle
--- 重啟、關閉伺服器的時候能先關閉
--- Oracle可以用service命令啟、停Oracle
1. 修改Oracle系統配置檔案:/etc/oratab //oratab格式:SID:ORACLE_HOME:AUTO
# vi /etc/oratab
orcl:/Oracle/app/product/11.1.0/db:Y
2. 在 /etc/init.d/ 下建立檔案oracle,11G以前編寫內容如下:
#!/bin/bash
#chkconfig: 35 99 01
#description: Oracle auto start-stop-restart script
#
#Set ORA_HOME to be equivalent to the $ORACLE_HOME from which you wish to execute dbstart and dbshutdown
#
#Set ORA_OWNER to the user id of the owner of the Oracle database in ORA_HOME.
ORA_HOME=/Oracle/app/product/11.1.0/db
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databasee as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"
# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
'stop')
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;
'restart')
$0 stop
$0 start
;;
esac
3. 改變檔案許可權
# chmod 755 /etc/init.d/oracle
4. 新增服務
# chkconfig --level 35 oracle on
5. 需要在重新啟動時停止資料庫,做一下操作
# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle //關機
# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle //重啟
6. 使用方法
# service oracle start //啟動oracle
# service oracle stop //關閉oracle
11G以後指令碼:
修改dbstart和dbshut指令碼
行:ORACLE_HOME_LISTNER=$1修改為:
ORACLE_HOME_LISTNER=$ORACLE_HOME
#!/bin/bash
#chkconfig: 35 99 01
#description:Startup Script. for oracle Databases
#/etc/rc.d/init.d/oradbstart
export ORACLE_BASE=/Oracle/app/
export ORACLE_HOME=/Oracle/app/product/11.1.0/db
export ORACLE_SID=pir
export PATH=$PATH:$ORACLE_HOME/bin
case"$1"in
start)
echo "-----startuporacle-----" >> /var/log/oracle11log
su oracle -c $ORACLE_HOME/bin/dbstart
touch /var/lock/subsys/oracle11
echo "-----startuporaclesuccessful-----" >> /var/log/oracle11log
echo "OK"
;;
stop)
echo "-----shutdwnoracle-----" >> /var/log/oracle11log
suoracle-c$ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle11
echo "-----shutdownoraclesuccessful-----" >> /var/log/oracle11log
echo "OK"
;;
*)
echo "Usage:'basename$0'start|stop"
exit1
esac
exit0
--- 能夠實現開機啟動Oracle
--- 重啟、關閉伺服器的時候能先關閉
--- Oracle可以用service命令啟、停Oracle
1. 修改Oracle系統配置檔案:/etc/oratab //oratab格式:SID:ORACLE_HOME:AUTO
# vi /etc/oratab
orcl:/Oracle/app/product/11.1.0/db:Y
2. 在 /etc/init.d/ 下建立檔案oracle,11G以前編寫內容如下:
#!/bin/bash
#chkconfig: 35 99 01
#description: Oracle auto start-stop-restart script
#
#Set ORA_HOME to be equivalent to the $ORACLE_HOME from which you wish to execute dbstart and dbshutdown
#
#Set ORA_OWNER to the user id of the owner of the Oracle database in ORA_HOME.
ORA_HOME=/Oracle/app/product/11.1.0/db
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databasee as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"
# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
'stop')
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;
'restart')
$0 stop
$0 start
;;
esac
3. 改變檔案許可權
# chmod 755 /etc/init.d/oracle
4. 新增服務
# chkconfig --level 35 oracle on
5. 需要在重新啟動時停止資料庫,做一下操作
# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle //關機
# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle //重啟
6. 使用方法
# service oracle start //啟動oracle
# service oracle stop //關閉oracle
11G以後指令碼:
修改dbstart和dbshut指令碼
行:ORACLE_HOME_LISTNER=$1修改為:
ORACLE_HOME_LISTNER=$ORACLE_HOME
#!/bin/bash
#chkconfig: 35 99 01
#description:Startup Script. for oracle Databases
#/etc/rc.d/init.d/oradbstart
export ORACLE_BASE=/Oracle/app/
export ORACLE_HOME=/Oracle/app/product/11.1.0/db
export ORACLE_SID=pir
export PATH=$PATH:$ORACLE_HOME/bin
case"$1"in
start)
echo "-----startuporacle-----" >> /var/log/oracle11log
su oracle -c $ORACLE_HOME/bin/dbstart
touch /var/lock/subsys/oracle11
echo "-----startuporaclesuccessful-----" >> /var/log/oracle11log
echo "OK"
;;
stop)
echo "-----shutdwnoracle-----" >> /var/log/oracle11log
suoracle-c$ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle11
echo "-----shutdownoraclesuccessful-----" >> /var/log/oracle11log
echo "OK"
;;
*)
echo "Usage:'basename$0'start|stop"
exit1
esac
exit0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24070945/viewspace-696074/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle啟動和關閉指令碼for LinuxOracle指令碼Linux
- Mongodb 啟動關閉指令碼並設定開機自動啟動MongodbMongoDB指令碼
- SHELL指令碼實現Oracle自啟動與關閉指令碼Oracle
- 再談用指令碼自動啟動關閉LINUX下的ORACLE資料庫指令碼LinuxOracle資料庫
- Linux自啟動指令碼Linux指令碼
- rhel as3下自動啟動和關閉oracle的指令碼S3Oracle指令碼
- linux開機自動啟動指令碼Linux指令碼
- MySQL 多例項啟動和關閉指令碼MySql指令碼
- informix 資料庫啟動關閉指令碼ORM資料庫指令碼
- Linux 下oracle自啟動指令碼LinuxOracle指令碼
- 資料庫自動啟動關閉資料庫
- centos 自動啟動指令碼和自啟動服務CentOS指令碼
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- 網路卡自動啟動指令碼指令碼
- Linux 新增指令碼開機自啟動Linux指令碼
- linux下新增oracle自啟動指令碼LinuxOracle指令碼
- Linux 下 Oracle隨系統自動啟動和關閉LinuxOracle
- mysql啟動與關閉(手動與自動)MySql
- Linux下的GoldenGate的啟動關閉Shell指令碼(獨立)LinuxGo指令碼
- Oracle監聽啟動後自動關閉Oracle
- oracle自動啟動和關閉的方法Oracle
- linux下rman增量備份指令碼以及指令碼自動執行Linux指令碼
- windows下oracle自動啟動指令碼WindowsOracle指令碼
- Linux下Oracle隨機自動啟動指令碼設定LinuxOracle隨機指令碼
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- Oracle自動啟動和關閉的方法 (轉)Oracle
- linux svn啟動和關閉Linux
- Linux啟動/關機時執行指令碼Linux指令碼
- linux-啟動指令碼Linux指令碼
- Linux(CentOS)啟動時自動執行指令碼(rc.local)LinuxCentOS指令碼
- 如何在 Linux 啟動時自動執行命令或指令碼Linux指令碼
- 【指令碼】快速啟動和關閉Windows上的資料庫指令碼Windows資料庫
- 開機自啟動Powershell指令碼指令碼
- linux下開機使用dbstart和dbshut自動啟動和關閉db!Linux
- LINUX下開機使用dbstart和dbshut自動啟動和關閉dbLinux
- 啟動vi時自動執行的指令碼指令碼
- ORACLE AS 自動關閉Oracle
- 編寫一個小指令碼來啟動和關閉sybase ASE指令碼