Heim  >  Artikel  >  Datenbank  >  SUSE Linux 11 开机 自动启动 Oracle 数据库

SUSE Linux 11 开机 自动启动 Oracle 数据库

WBOY
WBOYOriginal
2016-06-07 17:11:291456Durchsuche

1.修改/etc/oratab文件,后面的dbstart和dbshut依据这个文件启动数据库soadb:/u01/oracle/product/11.2.0/dbhome_1:Y2.创建数据库

1.修改/etc/oratab文件,后面的dbstart和dbshut依据这个文件启动数据库

soadb:/u01/Oracle/product/11.2.0/dbhome_1:Y

2.创建数据库初始化文件:

#cp $ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora.* $ORACLE_HOME/dbs/init$ORACLE_SID.ora

cp /u01/oracle/admin/soadb/pfile/init.ora.116201214406 /u01/oracle/product/11.2.0/dbhome_1/dbs/initsoadb.ora

3.接下来在/etc/init.d下建立系统自动启动和关机前自动关闭Oracle的脚本文件,,分别如下:

vi start_oracle.sh(开机后启动oracle数据库脚本):

#!/bin/bash

#this script is used to start the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbstart"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"

chmod a+x /etc/init.d/start_oracle.sh

vi stop_oracle.sh(关机前停止oracle数据库脚本):

#!/bin/bash

#this script is used to stop the oracle

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/lsnrctl stop"

su - oracle -c "/u01/oracle/product/11.2.0/dbhome_1/bin/dbshut"

chmod a+x /etc/init.d/stop_oracle.sh

4.创建随系统启动和关闭的链接:

在/etc/rc2.d下加入自动启动链接,命令如下:

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc2.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc3.d/S16start_oracle

ln -s /etc/init.d/start_oracle.sh  /etc/rc.d/rc5.d/S16start_oracle

在/etc/rc0.d下加入自动关闭链接,命令如下:

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc2.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc3.d/K01stop_oracle

ln -s /etc/init.d/stop_oracle.sh /etc/rc.d/rc5.d/K01stop_oracle

接着cp这两个链接在/etc/rc.d/rcN.d(N=3,5)下各一份

设置完毕,可以重启看看效果了。

linux:~ # reboot

test@linux:~> ps -ef | grep ora

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn