在windows 环境下安装完oracle 数据库,每次启动系统时,oracle会自动启动。但是在liunx平台下需要手动启动oracle 实例。
为了让oracle数据数据库自动随操作系统启动,需要手动配置,下面给大家介绍下详细的配置步骤。
1.修改Oracle系统配置文件:/etc/oratab
Oracle 安装后$ORACLE_HOME/bin路径下有自带的dbstart(启动数据库)和dbshut(关闭数据库)两个脚本。
root用户下执行
[root@pxboracle]# vi /etc/oratab
在文件下添加一行
devdb:/u01/oracle/product/11.2.0/db_1:Y
devdb 是实例名,:/u01/oracle/product/11.2.0/db_1是oracle安装home路径,后面添加 Y 即可!
#
# 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 boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
devdb:/u01/oracle/product/11.2.0/db_1:Y
2. 在 /etc/rc.d/init.d/ 目录下,创建oracle服务脚本文件,并将如下内容放入脚本中:
[root@pxboracle]# vi oracle
#!/bin/bash
# See how we were called.
case "$1" in
start)
su - oracle -c "lsnrctl start" >>/var/startdb.log
su - oracle -c "dbstart" >>/var/startdb.log
;;
stop)
su - oracle -c "dbshut" >>/var/stopdb.log
su - oracle -c "lsnrctl stop" >>/var/stopdb.log
;;
esac
exit 0
3. 修改刚才新创建的oracle文件权限
[root@pxboracle]# chmod 755 /etc/rc.d/init.d/oracle
4.创建链接,建立启动与关闭界面的连接(S打头的是启动程序,K打头的是关闭程序)
liunx图形界面启动的文件在rc5.d目录下
linux图形界面下的自启动在rc5.d
[root@pxboracle]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/S99oracle
需要在关机或重启机器之前停止数据库
linux图形界面下的关闭服务链接
[root@pxboracle]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/K99oracle
liunx非图形界面启动的文件在rc3.d目录下
linux文字界面下的自启动在rc3.d
[root@pxboracle]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/S99oracle
需要在关机或重启机器之前停止数据库
linux文字界面下的关闭服务链接
[root@pxboracle]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/K99oracle
上面的“S99oracle”和“K99oracle”文件也都要设置为可执行文件
[root@pxboracle]# chmod 777 /etc/rc.d/rc5.d/S99oracle
[root@pxboracle]# chmod 777 /etc/rc.d/rc5.d/K99oracle
[root@pxboracle]# chmod 777 /etc/rc.d/rc3.d/S99oracle
[root@pxboracle]# chmod 777 /etc/rc.d/rc3.d/K99oracle
4. 添加oracle自动启动到服务中
[root@pxboracle]#chkconfig --add oracle
[root@pxboracle]#chkconfig --list oracle
5. 先使用如下方法测试下
[root@pxboracle]# service oracle start //启动oracle
[root@pxboracle]# service oracle stop //关闭oracle
[root@pxboracle]# service oracle restart //重启oracle
6. 重启系统
[root@pxboracle]#reboot
7.至此完成linux启动时自动启动oracle,如何检查是否成功.
1、查看日志文件/var/startdb.log,记录启动过程。
[root@pxboracle]#su - oracle 切换到oracle 用户下
[oracle@pxboracle]#set ORACLE_SID=devdb
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12798004/viewspace-1143970/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12798004/viewspace-1143970/
1777

被折叠的 条评论
为什么被折叠?



