oracle的环境配置-设置开机(Linux)自动启动Oracle关机自动关闭Oracle
设置开机(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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。