linux下開機自動開啟單機oracle
前提:ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
1. 修改Oracle系統配置檔案:/etc/oratab,只有這樣,Oracle 自帶的dbstart和dbshut才能夠發揮作用。
# vi /etc/oratab
orcl:/opt/oracle/102:Y
2. 在 /etc/init.d/ 下建立檔案oracle,內容如下:
#!/bin/bash
#chkconfig:345 61 61
#description:Apache
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
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 Databases 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
# service oracle restart //重啟oracle
7. 測試
1. 修改Oracle系統配置檔案:/etc/oratab,只有這樣,Oracle 自帶的dbstart和dbshut才能夠發揮作用。
# vi /etc/oratab
orcl:/opt/oracle/102:Y
2. 在 /etc/init.d/ 下建立檔案oracle,內容如下:
#!/bin/bash
#chkconfig:345 61 61
#description:Apache
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
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 Databases 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
# service oracle restart //重啟oracle
7. 測試
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2129842/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux下開機自動啟動OracleLinuxOracle
- 開機自動啟動ORACLE ON LinuxOracleLinux
- oracle開機自啟動Oracle
- Linux 下軟體開機自啟動Linux
- linux7 開機自啟動oracleLinuxOracle
- oracle配置開機自啟動Oracle
- Oracle在linux下的開機自啟動(詳細)轉OracleLinux
- windows開機自動啟動oracleWindowsOracle
- 【OEM】Oracle oem取消開機自動啟動(linux)OracleLinux
- Linux開機自啟動配置Linux
- Linux 新增開機自啟動Linux
- TongWeb在Linux下設定開機自啟動WebLinux
- Linux平臺Oracle開機自啟動設定LinuxOracle
- linux下單例項資料庫開機自啟動設定Linux單例資料庫
- Linux下Redis開機自啟(Centos)LinuxRedisCentOS
- Linux下ejabberd開機自啟(CentOS)LinuxCentOS
- Linux 下Oracle 開機自啟動 與 oratab, dbstart 指令碼 說明LinuxOracle指令碼
- linux開機自動啟動指令碼Linux指令碼
- oracle資料庫開機自動啟動Oracle資料庫
- Linux平臺下oracle設定開機啟動LinuxOracle
- oracle開機啟動Oracle
- 開機自動啟動應用程式 ON LinuxLinux
- Linux 新增指令碼開機自啟動Linux指令碼
- KVM虛機開機自啟和取消自啟動
- RedHat(Linux) Oracle資料庫設定開機自啟動RedhatLinuxOracle資料庫
- Linux開機自啟配置Linux
- Oracle之 服務啟動&停止指令碼與開機自啟動(單例項)Oracle指令碼單例
- linux 中oracle開機啟動設定LinuxOracle
- WinForm程式開機自動啟動ORM
- windows下redis設定redis開機自啟動WindowsRedis
- Linux下Oracle隨機自動啟動指令碼設定LinuxOracle隨機指令碼
- OracleLinux上的Oracle開關機自啟動OracleLinux
- 設定Oracle資料庫開機自啟動Oracle資料庫
- Linux下原始碼安裝MySQL後設定開機自動啟動Linux原始碼MySql
- linux下開機使用dbstart和dbshut自動啟動和關閉db!Linux
- LINUX下開機使用dbstart和dbshut自動啟動和關閉dbLinux
- LINUX開機自動啟動ORACLE資料庫和監聽指令碼LinuxOracle資料庫指令碼
- AIX6.1 oracle10.2.0.5 單機檔案系統,實現開機自動啟動AIOracle