当前位置:文档之家› linux下oracle设置开机自启动的几种方法

linux下oracle设置开机自启动的几种方法

linux下oracle设置开机自启动的几种方法
运行环境:linux as4+oracle9204

方法1)、添加以下脚本到/etc/rc.d/rc.local 或/etc/rc.d/rc

#设置环境变量
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/9204
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export ORACLE_OWNER=oracle
export ORACLE_SID=TEST
export ORACLE_TERM=xterm
export LD_ASSUME_KERNEL=2.4.19
export THREADS_FLAG=native
export LD_LIBRARY_PATH=/opt/oracle/product/9204/lib:$LD_LIBRARY_PATH
export PATH=/opt/oracle/product/9204/bin:$PATH


export DISPLAY=:0
#使用帐户名oracle登录启动oracle
oracle_user=oracle

# 启动****和数据库

su – “$oracle_user”<< EOO
lsnrctl start
sqlplus /nolog<#使用dba帐户 system登录 connect system(此为帐户名)/system(帐户密码) as sysdba
connect system/system as sysdba
startup
EOS
EOO

ps:也可以把上面的脚本放到一个文件里,然后在rc.local加入调用的语句。
方法2)、加载为服务自启动、停止

步骤1:在/etc/rc.d/init.d 目录添加一启动脚本,如oracleservice,脚本如下

#!/bin/sh
#
#name:/etc/rc.d/init.d/oracleservice
# chkconfig: 345 99 99
# description: 启动、停止oracle数据库和****控制程序
# 注:上面两行是必须,不明的可以参考chkconfig相关资料
# oracle environment

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/9204
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export ORACLE_OWNER=oracle
export ORACLE_SID=TEST
export ORACLE_TERM=xterm
export LD_ASSUME_KERNEL=2.4.19
export THREADS_FLAG=native
export LD_LIBRARY_PATH=/opt/oracle/product/9204/lib:$LD_LIBRARY_PATH
export PATH=/opt/oracle/product/9204/bin:$PATH

export DISPLAY=:0

oracle_user=oracle

case “$1″ in
start)

# 启动****控制程序和数据库

su – “$oracle_user”<< EOO
lsnrctl start
sqlplus /nolog<connect system/system as sysdba
startup
EOS
EOO
;;

stop)

# 停止****控制程序和数据库

su – “$oracle_user”<lsnrctl stop
sqlplus /nolog<connect???? system/system as sysdba
shutdown immediate

EOS
EOO
;;

*)
;;

esac
#–脚本结束
#从脚本里可以得知,此脚本通过参数start或stop来启动、停止数据库和****控制程序

步骤2:

更改权限,设置为可运行,在shel窗口中输入:
# chmod +x /etc/rc.d/init.d/oracleservice

步骤3:把oracleservice添加到服务里

# chkconfig –add /etc/rc.d/init.d/oracleservice

查看自动启动设置是否成功:
# chkconfig –list oracleservice
oracleservice???? 0:关闭???? 1:关闭???? 2:关闭???? 3:开启???? 4:开启???? 5:开启???? 6:关闭
*从上面可以看出level为345的都已经开启了,配置成功!

步骤4:重启检查oracle自启动是否成功。

方法3)、使用oracle本身的dbstart脚本,位置$ORACLE_HOME/bin/dbstart
看网上介绍,使用d

bstart是需要修改/etc/oratab把里面设置的最后一项设置为Y,如:
TEST:/opt/oracle/product/9204:N,更改为TEST:/opt/oracle/product/9204:Y

使用dbstart方式还没空尝试,有空再试试

/etc/oratab文件说明:
this file is used by oracle utilities. it is created by root.sh
# and updated by the database configuration assistant when creating
# a database.

# a colon, :, is used as the field terminator. a new line terminates
# the entry. lines beginning with a pound sign, #, are comments.
#
# entries are of the form:
# $oracle_sid:$oracle_home::
#
# the first and second fields are the system identifier and home
# directory of the database respectively. the third filed indicates
# to the dbstart utility that the database should , “y”, or should not,
# “n”, be brought up at system b oot time.
#
# multiple entries with the same $oracle_sid are not allowed.


相关主题
文本预览
相关文档 最新文档