Linux配置Oracle 11g自动启动
2024-10-20 11:30:08
http://www.cnblogs.com/edwardcmh/archive/2012/05/11/2495671.html
安装完毕Oracle 11g每次都得手动启动 | 停止数据库(dbstart | dbshut)、监听器(lsnrctl)、控制台(emtcl)。
设置一下,若手动启动数据库的同时监听器没有启动(即启动数据库时自动启动监听器,停止数据库时停止监听器),则需要修改dbstart脚本文件:
[oracle@localhost ~]$ cd /u01/app/oracle/product/11.1.0/db_1/bin/
[oracle@localhost ~]$ vi dbstart
找到下面的代码段:
# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1
### 需要将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
同样,修改dbshut:
[oracle@localhost ~]$ vi dbshut # The this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$1
### 需要将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
完成后配置Linux启动脚本oracle,内容如下:
[oracle@localhost bin]$ cd /etc/init.d/
[oracle@localhost init.d]$ vi oracle
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin ORA_OWNR="oracle" # if the executables do not exist -- display error if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi # depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|reload|reload}"
exit 1
esac
exit 0
赋予脚本可执行权限:
[oracle@localhost init.d]$ chmod 750 /etc/init.d/oracle
建立链接:
[oracle@localhost init.d]$ ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle
[oracle@localhost init.d]$ ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
启用脚本并添加到服务:
[oracle@localhost init.d]$ chkconfig --level 345 oracle on
[oracle@localhost init.d]$ chkconfig --add oracle
注意:
这样的脚本一般不会启动实例,如果想让实例也随脚本一起启动的话,就需要修改文件/etc/oratab
如果这个文件不存在,就要运行脚本文件产生它。
[root@localhost init.d]# $ORACLE_HOME/root.sh
# 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:<N|Y>:
#
# 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.
#
# orcl:/u01/app/oracle/product/11.1.0/db_1:Y
可以看出,实例orcl是自动启动的(标识为Y),只要在这里配置好,再配合上面的脚本,即可实现自动启动。
最新文章
- java重置定时器频率
- 【Web】URI和URL,及URL的编码
- 【Alpha阶段】第十次Scrum例会
- Ahjesus获取自定义属性Attribute或属性的名称
- 转 Java多线程中Sleep与Wait的区别
- 广搜+打表 POJ 1426 Find The Multiple
- 第十二章 process.tar.gz中代码的运行
- ZOJ 3911 Prime Query ZOJ Monthly, October 2015 - I
- mysql优化 mysql explain
- 玩一个:可以显示任何xml树结构的xaml定义
- 中断——中断描述符表的定义和初始化(一) (基于3.16-rc4)
- 移动前端javascript事件
- virtualization-vs-containerization
- uva10465(完全背包,要求装满背包)
- mysql常用基础操作语法(三)~~对数据的增删改操作【命令行模式】
- java后台通过Servlet给用户发送手机短信验证码,第一次写勿喷,欢迎转载
- Eclipse搭建.C#和..NET Core环境
- 日记整理---->;2016-11-25
- python进度条
- windows下快速启动或关闭系统服务方法
热门文章
- boost split字符串
- c++语言第二次作业
- Luogu 4149 Race
- 20179223《Linux内核原理与分析》第二周学习笔记
- MD5加盐加密
- andriod studio报错 Emulator: emulator: ERROR: x86 emulation currently requires hardware acceleration! Emulator: Process finished with exit code 1
- pat 乙级 1093 字符串A+B (20 分)
- vs2010 创建和C#使用动态链接库(dll)
- UVA12716 GCD XOR 数论数学构造
- Spring整合Quartz定时器