Linux下oracle11g数据库的监听自启动设置

1、设置自启动
su - root
vi /etc/oratab
orcl:/oracle/app/product/10.2.0/db_1:N --> orcl:/oracle/app/product/10.2.0/db_1:Y
2、修改数据库地址
su - root
cd $ORACLE_HOME/bin
vi dbstart

ORACLE_HOME_LISTNER=$ORACLE_HOME
3、创建启动脚本
$su - root
cd /etc/rc.d/init.d/
vi oradbstart

#!/bin/bash
# chkconfig: 345 99 10
# description: Startup Script for oracle Databases
# /etc/rc.d/init.d/dbstart
export ORACLE_BASE=/db/app/oracle
export ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/oracle
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
rm -f /var/lock/oracle
echo "OK";;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: 'basename $0' start|stop|restart|reload"
exit 1
esac
exit 0
4、修改脚本的运行权限
su - root
chown oracle:oinstall /etc/rc.d/init.d/oradbstart
chmod 775 /etc/rc.d/init.d/oradbstart

5、把oradbstart 服务添加到 chkconfig 中
su - root
chkconfig --add oradbstart
chkconfig --list oradbstart
6、配置完成,重启服务器
su - oracle
lsnrctl status

[参考] http://www.360doc.com/content/11/1208/09/7874148_170569773.shtml

原文地址:https://www.cnblogs.com/personal-blog/p/14380778.html