Centos5.6 oracle 10g
开机启动数据库配置
|
系统 |
数据库版本 |
实现功能开机自动启动 ORACLE |
|
Centos5.6 |
10.2.0.1 |
很复杂,今天来学习 |
1 、 修改 /etc/oratab
doudou:/opt/oracle/product/10.2.0: Y
2 、修改 $ORACLE_HOME/bin/dbstart 脚本中的一处错误
将 ORACLE_HOME_LISTNER= /ade/vikrkuma_new/oracle 修改成 ORACLE_HOME_LISTNER= $ORACLE_HOME
3 、 创建 database 脚本
vi /etc/rc.d/init.d/database
#!/bin/bash
# chkconfig: 35 85 90
##
(这里跟我们
chkconfig --add database
有关)(这里很重要如果你不设置,就不能添加
chkconfig
,不能自动启动数据库了。)
##
# description: Oracle auto start-stop script.
# AUTH:seker
. /etc/init.d/functions
start(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"cannot start database: database is already running."
failure $"cannot start database: database is already running."
echo
exit 1
else
echo -n $"Starting Database: "
daemon su - $ORA_OWNER -c "dbstart" && touch /var/lock/subsys/`basename $0`
echo
fi
}
stop(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"Stoping Database: "
daemon su - $ORA_OWNER -c "dbshut" && rm -f /var/lock/subsys/`basename $0`
echo
else
echo -n $"cannot stop database:Database is not already running."
failure $"cannot stop database:Database is not already running."
echo
exit 1
fi
}
ORA_OWNER=oracle
case "$1" in
start)
start
;;
stop)
stop
;;
emstart)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && echo "OEM is already running" || emctl start dbconsole'
;;
emstop)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && emctl stop dbconsole || echo "OEM is not running"'
;;
isqlstart)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null || isqlplusctl start'
;;
isqlstop)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null && isqlplusctl stop || echo "isqlplus is not running"'
;;
lsnstart)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && echo "listen is already running" || lsnrctl start &>/dev/null'
;;
lsnstop)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && lsnrctl stop &>/dev/null || echo "lsnrctl is not already running"'
;;
*)
echo "USAGE: $0 {start|stop|lsnstart|lsnstop|emstart|emstop|isqlstart|isqlstop}"
echo -e "\tstart : database start"
echo -e "\tstop : database stop"
echo -e "\tlsnstart : listen start"
echo -e "\tlsnstop : listen stop"
echo -e "\temstart : OEM start"
echo -e "\temstop : OEM stop"
echo -e "\tisqlstart : isqlplus start"
echo -e "\tisqlstop : isqlplus stop"
esac
4 、 修改执行权限 chmod 755 ora
chmod 755 /etc/rc.d/init.d/database
5 、 修改 chkconfig database on 开机自动启动
chkconfig --add database
chkconfig --list database
chkconfig database on
6 、使用 service 是否可以开启,关闭数据库
service database start
service database stop
7 、 reboot
OK ,开机自动启动数据库了!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26442936/viewspace-736828/ ,如需转载,请注明出处,否则将追究法律责任。