1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# chkconfig: 345 10 10
# description: Oracle dgstart / dbshut
#
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_UNQNAME=liupsdg
export ORACLE_SID=liups
export ORACLE_OWNER=oracle
LOGFILE=$ORACLE_BASE/dgstartup.log
echo "[$(date "+%F %T")]:########begin#######" >> ${LOGFILE}
echo "[$(date "+%F %T")]:/etc/init.d/oracle Begin 2 run:" >> ${LOGFILE}
if [ ! -f ${ORACLE_HOME}/bin/dgstart ] || [ ! -f ${ORACLE_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORACLE_HOME}/bin/dbstart or ${ORACLE_HOME}/bin/dbshut!" >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
exit
fi
start(){
echo "[$(date "+%F %T")]:Startup Database..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dgstart ${ORACLE_HOME}"
touch /var/lock/subsys/oracle
echo "[$(date "+%F %T")]:Startup Database Done."
su - ${ORACLE_OWNER} -c "$ORACLE_HOME/bin/emctl start dbconsole"
}
stop(){
echo "[$(date "+%F %T")]:Shutdown Database..."
su - ${ORACLE_OWNER} -c "${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}"
echo "[$(date "+%F %T")]:Shutdown Database Done."
rm -f /var/lock/subsys/oracle
su - ${ORACLE_OWNER} -c "$ORACLE_HOME/bin/emctl stop dbconsole"
}
case "$1" in
'start')
start >> ${LOGFILE}
;;
'stop')
stop >> ${LOGFILE}
;;
'restart')
stop >> ${LOGFILE}
start >> ${LOGFILE}
;;
*)
echo "Usage: 'basename $0' start|stop|restart"
exit 1
esac
echo "[$(date "+%F %T")]:Finished." >> ${LOGFILE}
echo "[$(date "+%F %T")]:########end#######" >> ${LOGFILE}
exit 0

原文作者: liups.com

原文链接: http://www.liups.cn/posts/7fb01a53/

许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议