设置 Oracle 实例和监听服务自启动
1. 增加启动脚本
touch /etc/init.d/orcl
vi orcl
# !/bin/bash
# whoami
# root
# chkconfig: 345 51 49
# /etc/init.d/orcl
# description: starts the oracle dabase deamons
#
ORA_HOME=/home/oracle/product/10.2.0/db_1/
ORA_OWNER=oracle
case "{GetProperty(Content)}" in
start)
echo -n "Starting orcl: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
touch /var/lock/subsys/orcl
echo
;;
stop)
echo -n "shutting down orcl: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/orcl
echo
;;
restart)
echo -n "restarting orcl: "
{GetProperty(Content)} stop
{GetProperty(Content)} start
echo
;;
*)
echo "Usage: `basename {GetProperty(Content)}` start|stop|restart"
exit 1
esac
exit 0
保存 orcl 并退出
2. 增加配置服务
/sbin/chkconfig --add orcl
3. 修改 /etc/oratab 文件
vi /etc/oratab
ORACLE_SID:ORACLE_HOME:Y -- 是否自启动
4. 重启测试一下
或者简单的配置 /etc/rc.d/rc.local 增加两条启动命令
su - oracle -c /home/oracle/product/10.2.0/db_1/bin/dbstart
su - oracle -c /home/oracle/product/10.2.0/db_1/bin/lsnrctl start