設置 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