您好,登录后才能下订单哦!
设置开机(Linux)自动启动Oracle关机自动关闭Oracle
1、切换到root用户下,确认启动文件和关闭文件是存在
[oracle@oracle3 bin]$ pwd
/u01/oracle/product/10.2.0/db_1/bin
[oracle@oracle3 bin]$ ls dbstart
dbstart --sqlplus执行startup的时候调用的脚本
[oracle@oracle3 bin]$ ls dbshut
dbshut --sqlplus执行shutdown的时候调用的脚本
2、修改oratab文件
[oracle@oracle3 etc]$ vim /etc/oratab
ORCL:/u01/oracle/product/10.2.0/db_1:Y --将N改为Y
3、测试启动文件和关闭文件的正确性
/u01/oracle/product/10.2.0/db_1/bin
[oracle@oracle3 bin]$ export ORACLE_SID=ORCL
[oracle@oracle3 bin]$ dbshut
[oracle@oracle3 bin]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 16:23:12 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance. --数据库是关闭的
注意: conn /as sysdba = conn sys/orcl as sysdba
SQL> conn sys/orcl as sysdba
Connected to an idle instance. --连接到一个空闲的例程表示数据库没有启动
SQL> conn sys/orcl@ORCL as sysdba
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Warning: You are no longer connected to ORACLE. --因为数据库关闭了,是无法用监听器访问的,仅仅可以以sysdba的身份连接而已。
不管进行什么操作,都必须连接一下,用sysdba的身份登录校验操作系统的密码文件。
[oracle@oracle3 bin]$ dbstart --测试启动文件是可用的
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
Processing Database instance "ORCL": log file /u01/oracle/product/10.2.0/db_1/startup.log
[oracle@oracle3 bin]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 16:30:35 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected. --
4、编写一段shell脚本
[root@oracle3 ~]# cd /etc/rc.d/init.d
[root@oracle3 init.d]# touch start_shut
[root@oracle3 init.d]# vi start_shut
----------------------------------------------
#!/bin/sh
OPT_=$1
case "$OPT_" in
start)
/bin/echo "$0 : (start)"
#
# your service startup command goes here
#
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl start"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/dbstart"
# NOTE:Must exit with zero unless error is server
chmod 1777 /tmp
chown sys:sys /tmp
exit 0
;;
stop)
/bin/echo "$ : (stop)"
#
# your service shutdown command goes here.
#
su - oralce -c "/u01/oracle/product/10.2.0/db_1/bin/dbshut"
su - oracle -c "/u01/oracle/product/10.2.0/db_1/bin/lsnrctl stop"
#Note: Must exit with zero unless error is server
exit 0
;;
*) /bin/echo ''
/bin/echo "Usage: $0[start|stop]"
/bin/echo "Invalid argument ==>\"${OPT_}\""
/bin/echo ''
exit 0
;;
esac
----------------------------------------------------------------------------------
5、修改权限
[root@oracle3 init.d]# chmod 755 start_shut
6、将文件链接到启动区域和关闭区域
[root@oracle3 init.d]# cd /etc/rc5.d
[root@oracle3 rc5.d]# ln -s /etc/rc.d/init.d/start_shut S99start_shut
[root@oracle3 rc5.d]# cd /etc/rc0.d
[root@oracle3 rc0.d]# ln -s /etc/rc.d/init.d/start_shut K01start_shut
7、测试:
init 6
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。