每次启动关闭Oracle,都要敲一大串的命令,特别在学习或者测试环境,敲多了难免感觉烦,因而就写了个servcie脚本,利用RedHat的service命令简单的启动,关闭,重启Oracle数据库,同时开启或者关闭em和lsnrctl,下面附上shell脚本和测试结果[root@jsb-ylw-5024 ~]# cat /etc/init.d/oracle
#!/bin/sh
#chkconfig: 35 85 15
#description:oracle
#function: start .. stop and restart the oracle instance on 11g R2 64bit
#author:lw.yang
#version: V.1.0ORACLE_PID=`ps -ef |grep ora |grep -E "smon|pmon|ckpt" |wc -l`
export ORACLE_BASE=/u01
export ORACLE_HOME=/u01/oracle
export ORACLE_SID=yang
export PATH=$ORACLE_HOME:/bin:$PATH# Source function library.
. /etc/rc.d/init.d/functionsstart() {
su - oracle<<EOF
emctl start dbconsole
lsnrctl start
sqlplus /nolog<<EOD
conn /as sysdba
startup
exit
EOD
exit
EOF
}stop() {
su - oracle<<EOF
emctl stop dbconsole
lsnrctl stop
sqlplus /nolog<<EOD
conn /as sysdba
shutdown immediate
exit
EOD
exit
EOF
}case "$1" in
start)
start
touch /var/lock/subsys/oracle
;; stop)
stop
;; status)
if [ "$ORACLE_PID" = "3" ];then
echo "Oracle instance is running..."
else echo "Oracle instance is not running..."
fi
;; restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1esac
[root@jsb-ylw-5024 ~]# chmod +x /etc/init.d/oracle
[root@jsb-ylw-5024 ~]# chkconfig --add oracle
[root@jsb-ylw-5024 ~]# service oracle status
Oracle instance is not running...
Oracle 入门之管理online redolog在UNIX 和Linux平台上如何部署IBM DB2 产品相关资讯 oracle
- [INS-32052] Oracle基目录和Oracle (07/22/2014 07:41:41)
- Oracle 4个大对象(lobs)数据类型 (02/03/2013 12:33:05)
- Oracle按时间段分组统计 (07/26/2012 10:36:48)
| - [Oracle] dbms_metadata.get_ddl的 (07/12/2013 07:37:30)
- Liferay Portal 配置使用Oracle和 (07/31/2012 20:07:18)
- Concurrent Request:Inactive (07/20/2012 07:44:05)
|
本文评论 查看全部评论 (0)