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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux 新增指令碼開機自啟動Linux指令碼
- centos 自動啟動指令碼和自啟動服務CentOS指令碼
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- Linux(CentOS)啟動時自動執行指令碼(rc.local)LinuxCentOS指令碼
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- linux設定開機自啟動指令碼的最佳方式Linux指令碼
- 使用laradock啟動容器elasticsearch遇到啟動後幾秒鐘又自動關閉的問題以及解決方法Elasticsearch
- Linux配置開機自啟動執行指令碼方法有哪些?Linux指令碼
- Linux下的MongoDB安裝&啟動&關閉LinuxMongoDB
- 記windows自定義bat指令碼自啟動WindowsBAT指令碼
- Ubuntu 設定開機自啟動指令碼Ubuntu指令碼
- linux系統軟體啟動sh指令碼Linux指令碼
- 如何在Docker容器啟動時自動執行指令碼Docker指令碼
- 設定msyqlphp-fpm開機自動啟動指令碼PHP指令碼
- httpd啟動指令碼httpd指令碼
- 3 啟動和關閉
- win10開機自啟動程式關閉方法_win10怎麼關閉開機啟動項Win10
- 如何關閉Win10自動更新 win10永久關閉自動更新Win10
- springboot的jar在linux上sh啟動指令碼Spring BootJARLinux指令碼
- win10系統onenote自動啟動怎麼取消_win10系統onenote自動啟動如何關閉Win10
- win10應用商店自動啟動怎麼辦 win10微軟商店自動啟動如何關閉Win10微軟
- win10系統快速啟動怎麼關閉 關閉Windows快速啟動Win10Windows
- 如何關閉Windows自動更新Windows
- WebStorm關閉自動拆疊WebORM
- filebeat自動關閉解決
- specjvm自動化指令碼JVM指令碼
- 自動備份指令碼指令碼
- Linux中配置開機自啟動執行指令碼的方法是什麼?Linux指令碼
- 記一次springboot的開機啟動自動關閉問題Spring Boot
- 怎樣在Mac上安排自動啟動或關閉,技巧來啦~Mac
- 9. 啟動、關閉tomcatTomcat
- 啟動與關閉服務
- 01啟動(關閉)套接字
- linux透過shell指令碼實現ssh互動式自動化Linux指令碼
- MacOS 啟動 -- Redis指令碼MacRedis指令碼
- 怎樣關閉win10自動更新 如何關閉windows10自動更新Win10Windows
- win10快速啟動怎麼關閉_win10如何關閉快速啟動Win10
- SharePlex 基於Solaris 10 Linux自動巡檢指令碼Linux指令碼
- centos下nginx啟動、重啟、關閉CentOSNginx