自動啟動ORACLE Script Service
All just to do better
一切只為了做的更好
SCRIPT NAME:oracle
#!/bin/bash
# chkconfig: 345 99 10
# description: script for the Oracle Instance, Listener
#
# 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=/app/oracle/product/11.2.0/db_1
ORA_OWNER=oracle
oracle_run=$(ps -ef|grep ora_dbw0_oracle11|grep -v grep|wc -l)
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo "Starting Oracle Listeners: "
echo -n "Starting Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl start" >> /var/log/oracle.log
echo -n "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo -n "Stoping Oracle Listeners: "
echo -n "Stoping Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl stop" >> /var/log/oracle.log
echo -n "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'restart')
echo -n "Starting Oracle Database ....."
$0 stop >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
echo -n "Stoping Oracle Database ....."
$0 start >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
;;
'status')
if [ $oracle_run -eq 1 ]
oracle_status=$(su - $ORA_OWNER -c "$ORA_HOME/bin/sqlplus -silent / as sysdba" << mxq
set pagesize 0 feedback off verify off heading off echo off numwidth 4
select 'ORACLE STATUS: '||decode(status,'OPEN',' open runing','MOUNTED','oracle is mount runing','STARTED','oracle is nomount runing','oracle is stoping'),'ROLE: '||instance_role from v\$instance;
exit
mxq
)
echo $oracle_status
else
echo "oracle is stoping"
fi
;;
esac
2、檔案修改成Y
etc/init.d/oracle
crds3db:/app/oracle/product/11.2.0/db_1:Y
3、新增服務
chkconfig --add oracle #新增服務
chkconfig --level 345 oracle on #345級別都啟用服務
chkconfig --list oracle #檢視服務
--chkconfig --del oracle #刪除服務
4、啟動服務
新增服務服務後,不會立即啟動服務,如果需要立即啟動服務,需要執行
service oracle start #啟動服務
service oracle stop #停止服務
service oracle restart #重啟服務
一切只為了做的更好
SCRIPT NAME:oracle
#!/bin/bash
# chkconfig: 345 99 10
# description: script for the Oracle Instance, Listener
#
# 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=/app/oracle/product/11.2.0/db_1
ORA_OWNER=oracle
oracle_run=$(ps -ef|grep ora_dbw0_oracle11|grep -v grep|wc -l)
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo "Starting Oracle Listeners: "
echo -n "Starting Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl start" >> /var/log/oracle.log
echo -n "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
#echo -n "Stoping Oracle Listeners: "
echo -n "Stoping Oracle Database ....."
su - oracle -c "$ORA_HOME/bin/lsnrctl stop" >> /var/log/oracle.log
echo -n "....."
sleep 1
echo "....."
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
date +"! %T %a %D : Finished." >> /var/log/oracle
;;
'restart')
echo -n "Starting Oracle Database ....."
$0 stop >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
echo -n "Stoping Oracle Database ....."
$0 start >> /var/log/oracle.log && echo "(Succeed)" || echo "(Failure)"
;;
'status')
if [ $oracle_run -eq 1 ]
oracle_status=$(su - $ORA_OWNER -c "$ORA_HOME/bin/sqlplus -silent / as sysdba" << mxq
set pagesize 0 feedback off verify off heading off echo off numwidth 4
select 'ORACLE STATUS: '||decode(status,'OPEN',' open runing','MOUNTED','oracle is mount runing','STARTED','oracle is nomount runing','oracle is stoping'),'ROLE: '||instance_role from v\$instance;
exit
mxq
)
echo $oracle_status
else
echo "oracle is stoping"
fi
;;
esac
2、檔案修改成Y
etc/init.d/oracle
crds3db:/app/oracle/product/11.2.0/db_1:Y
3、新增服務
chkconfig --add oracle #新增服務
chkconfig --level 345 oracle on #345級別都啟用服務
chkconfig --list oracle #檢視服務
--chkconfig --del oracle #刪除服務
4、啟動服務
新增服務服務後,不會立即啟動服務,如果需要立即啟動服務,需要執行
service oracle start #啟動服務
service oracle stop #停止服務
service oracle restart #重啟服務
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29065182/viewspace-1629523/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle RAC的自定義service自啟動Oracle
- UNIX自動啟動oracleOracle
- Windows啟動ServerDB ScriptWindowsServer
- oracle for linux 自動啟動OracleLinux
- linux oracle 自動啟動LinuxOracle
- Oracle RAC自啟動Oracle
- Service啟動流程
- oracle 隨系統開啟,自動啟動Oracle
- windows開機自動啟動oracleWindowsOracle
- oracle instance and listener自動啟動Oracle
- 讓oracle自動啟動方法!(轉)Oracle
- oracle開機自啟動Oracle
- 開機自動啟動ORACLE ON LinuxOracleLinux
- 自動重新啟動oracle例項 for windowsOracleWindows
- linux下oracle的自動啟動LinuxOracle
- windows下oracle自動啟動指令碼WindowsOracle指令碼
- 【Azure Bot Service】部署NodeJS ChatBot程式碼到App Service中無法自動啟動NodeJSAPP
- 4 配置Oracle資料庫自動啟動Oracle資料庫
- oracle資料庫開機自動啟動Oracle資料庫
- Linux下開機自動啟動OracleLinuxOracle
- Linux Oracle 隨系統自動啟動LinuxOracle
- 自動重新啟動oracle監聽程式 for windowsOracleWindows
- Oracle監聽啟動後自動關閉Oracle
- oracle自動啟動和關閉的方法Oracle
- linux 配置oracle+asm自動啟動LinuxOracleASM
- oracle配置開機自啟動Oracle
- Oracle 12c啟動時PDBs的自動開啟Oracle
- 原創:Android怎麼讓一個service開機自動啟動Android
- Service啟動過程分析
- Oracle自動啟動和關閉的方法 (轉)Oracle
- RedHat54下設定Oracle自動啟動RedhatOracle
- linux 下oracle10g自動啟動LinuxOracle
- Shell Script(bash)--用於自動備份的Shell Script(轉)
- oracle在AIX下的自啟動OracleAI
- Linux下oracle庫自啟動LinuxOracle
- Solaris下設定Oracle自啟動Oracle
- 開啟或關閉時自動設定service_names
- centos 自動啟動指令碼和自啟動服務CentOS指令碼