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的脚本文件,分别如下:
3.1添加文件
vi start_oracle.sh
脚本内如下,拷贝过去就可以:
#!/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
脚本内容如下,也是拷贝过去即可:
#!/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下加入自动关闭链接,接着cp这两个链接在/etc/rc.d/rcN.d(N=3,5)下各一份
命令如下:
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
设置完毕,可以重启看看效果了。
linux:~ # reboot
test@linux:~> ps -ef | grep ora
___________________________________________________________________________________
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Author: laven54 (lurou)
Email: laven54@163.com