CentOS Oracle11gR2 设置开机自启动

转载 2015年11月20日 12:36:18

[1] 更改/etc/oratab

复制代码
[root@localhost ~]# vi /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:<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:/usr/oracle/app/product/11.2.0/dbhome_1:Y #改变此处
复制代码

[2] oracle用户profile文件中增加SID环境变量

复制代码
[root@localhost ~]# vi /usr/oracle/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

# add at the last line

umask 022
export ORACLE_BASE=/usr/oracle/app

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
#在文件末尾增加
复制代码
export ORACLE_SID=orcl

[3] 创建启动Oracle的Init脚本

复制代码
[root@localhost ~]# vi /etc/rc.d/init.d/oracle
# this is an example
#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_USER=oracle

case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac

exit 0
复制代码

[4] 更改启动脚本权限

[root@localhost ~]# chmod 755 /etc/rc.d/init.d/oracle

[5] 启动oracle数据库

复制代码
[root@localhost ~]# service oracle start
Starting Oracle Database:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 09-OCT-2012 12:50:44

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /usr/oracle/app/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/l                                                                             istener.ora
Log messages written to /usr/oracle/app/diag/tnslsnr/localhost/listener/alert/lo                                                                             g.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                09-OCT-2012 12:50:44
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/                                                                             listener.ora
Listener Log File         /usr/oracle/app/diag/tnslsnr/localhost/listener/alert/                                                                             log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://localhost:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ....... started.
------------------------------------------------------------------
Logs are generated in directory /usr/oracle/app/product/11.2.0/dbhome_1/localhost_MFGS/sysman/log
复制代码

相应关闭oracle数据库的命令为

[root@localhost ~]# service oracle stop

[6] 设置oracle为开机自启动

[root@localhost ~]# chkconfig oracle on
[root@localhost ~]# chkconfig --list oracle
oracle          0:off   1:off   2:on    3:on    4:on    5:on    6:off

相关文章推荐

CentOS Oracle11gR2 设置开机自动启动

CentOS Oracle11gR2 设置开机自启动 [1] 更改/etc/oratab [root@localhost ~]# vi /etc/oratab # # Th...

Oracle10gr2 开机自启动脚本

目录目录 软件环境 Oracle服务启动停止重启脚本软件环境 操作系统 RHEL6.1 软件 Oracle10gr2 Oracle服务启动、停止、重启脚本su - oracle cd /u01/o...
  • Jmilk
  • Jmilk
  • 2016年06月03日 09:16
  • 843

centos install oracle11gR2(环境配置与启动设置)

操作系统:CentOS 5.10 64位 数据库:Oracle 11G R2(版本号为11.02) 安装操作系统的时候,注意交换分区的大小不得低于2G 1.同步时钟及修改/etc/hosts ...

azure 云端centos6.5下oracle11g服务开机自启动

1云端rc.local设置失效服务器信息是centos6.5,oracle数据库版本是orcle11g,小版本号是11.2.0.1.0,以前在idc环境设置的oracle服务器开机启动oracle服务...
  • mchdba
  • mchdba
  • 2016年04月18日 06:02
  • 5231

CentOS Linux下配置Oracle 11gR2为系统服务自动启动

PS:在Windows下安装完成Oracle 11gR2后,默认就开机自启动Oracle相关服务,但Linux下安装完后每次都得手动启动和关闭数据库(dbstart | dbshut)、监听器(l...

CentOS 7 Linux下配置Oracle 11gR2为系统服务自动启动

1、Redhat init简介: Linux启动时,会运行一个init程序,然后由init来启动后面的任务,包括多用户环境(inittab中设定)和网络等。运行级就是当前程序运行的功能级别,这个级别...
  • karali
  • karali
  • 2014年09月19日 22:07
  • 4440

oracle11g在linux系统下开机自启动设置

oracle服务器一般来说最好是手动启动,这样碰到问题的话,可以现场解决,但是也担心有时候机器故障,自动重启后,为了快速恢复应用,需要自动开机启动oracle,而且发现在不同的os下,启动的设置都不太...
  • mchdba
  • mchdba
  • 2015年10月27日 10:53
  • 7148

CENTOS7下设置oracle 11g自启动

修改oratab文件 以root身份进入系统,通过vi命令打开文件 vi /etc/oratab 进入vi编辑器后,找到“orcl:/oracle/app/product/11.2.0/...

Oracle11gR2在Linux+CentOS+5

  • 2009年12月19日 00:07
  • 393KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CentOS Oracle11gR2 设置开机自启动
举报原因:
原因补充:

(最多只允许输入30个字)