前提说明:虚拟机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
当然也可以重启验证。
如果您觉得不错,点赞收藏一下哦,创造不易
版权声明:本文为qq_32789063原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。