Linux下的Oracle 11g设置开机自启

前提说明:虚拟机VMWare+RedHat6.4+Oracle11.2.0.4
感兴趣的可以看看:
虚拟机VMWare安装
RedHat6.4安装教程
RedHat6.4中安装Oracle11.2.0.4

当我们的虚拟机关机后重新开机,会遇到一个问题。
会发现oracle实例,监听程序和emctl程序没有启动。

我们可以手动来启动
1 startup启动实例

[oracle@rhel64 ~]$ sqlplus / as sysdba
SQL> startup

在这里插入图片描述
2 启动监听

[oracle@rhel64 ~]$ lsnrctl status
[oracle@rhel64 ~]$ lsnrctl start

在这里插入图片描述
3 启动emctl
另外也可以发现http://localhost.localdomain:1158/em 目前是没有反应的,这边要另外启动,启动的指令如下:

[oracle@rhel64 ~]$ emctl start dbconsole

在这里插入图片描述
4 Oracle11g 设置实例和监听开机自启

1.修改dbstart dbshut 文件

[root@rhel64 ~]$ vi /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
ORACLE_HOME_LISTNER=$1 改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
[root@rhel64 ~]$ vi /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbshut
ORACLE_HOME_LISTNER=$1 改为 ORACLE_HOME_LISTNER=$ORACLE_HOME

2.修改oratab 文件,将N改为Y

[root@rhel64 ~]$ vi /etc/oratab 
PROD:/u01/app/oracle/product/11.2.0/dbhome_1:Y
[root@rhel64 ~]$ cd /etc/rc.d/init.d/

3.创建启动oracle11g的init脚本

[root@rhel64 init.d]# cd /etc/rc.d/init.d/ 
[root@rhel64 init.d]# touch oracle
给所有用户给予oracle文件可执行权限
[root@rhel64 init.d]# chmod a+x oracle
[root@rhel64 init.d]# vi oracle

注意文件中这部分一定根据自己的安装路径来
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=PROD
export ORACLE_OWNR=oracle

#!/bin/bash
#chkconfig: 2345 80 25
# /etc/init.d/oracle11g
#description: ORACLE 11g Server
# Run-level Startup script. for the Oracle Listener and Instances
# It relies on the information on /etc/oratab
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=PROD
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
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.加入到系统服务列表中

[root@rhel64 init.d]# chkconfig --add oracle
[root@rhel64 init.d]# chkconfig --level 345 oracle on

5.测试(没有报错就说明成功了)

[root@rhel64 init.d]# service oracle restart
[root@rhel64 init.d]# service oracle stop
[root@rhel64 init.d]# service oracle start

当然也可以重启验证。

如果您觉得不错,点赞收藏一下哦,创造不易

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值