CentOS 设置 oracle 开机自动启动

1、
[root@localhost ~]# gedit /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:/data/oracle/product/11.2.0/db_1:Y

2、
[root@localhost init.d]# gedit /etc/rc.d/rc.local

文件内容为:

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

touch /var/lock/subsys/local

# add start

su oracle -lc "/data/oracle/product/11.2.0/db_1/bin/lsnrctl start"

su oracle -lc /data/oracle/product/11.2.0/db_1/bin/dbstart

# add end

3、
[root@localhost init.d]# gedit /etc/init.d/oracle

文件内容为:

#!/bin/sh

# chkconfig: 345 61 61

# description: Oracle 11g R2 AutoRun Servimces

# /etc/init.d/oracle

#

# Run-level Startup script for the Oracle Instance, Listener, and

# Web Interface

export ORACLE_BASE=/data/oracle #根据个人情况修改路径

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_SID=orcl #改成自己的ORACLE_SID:testsid

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

4、
[root@localhost init.d]# cd /etc/rc.d/init.d
[root@localhost init.d]# chmod +x oracle
5、
[root@localhost init.d]# ./oracle start

运行结果为:

ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener

Usage: /data/oracle/product/11.2.0/db_1/bin/dbstart ORACLE_HOME

Processing Database instance "orcl": log file /data/oracle/product/11.2.0/db_1/startup.log

Oracle Start Succesful!OK.

[root@localhost init.d]# ./oracle stop

运行结果为:

ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener

Usage: /data/oracle/product/11.2.0/db_1/bin/dbshut ORACLE_HOME

Processing Database instance "orcl": log file /data/oracle/product/11.2.0/db_1/shutdown.log

Oracle Stop Succesful!OK.

6、
[root@localhost init.d]# gedit /data/oracle/product/11.2.0/db_1/bin/dbstart

文件修改内容为(替换掉ORACLE_HOME_LISTNER=$1):

省略...

# First argument is used to bring up Oracle Net Listener

#ORACLE_HOME_LISTNER=$1

ORACLE_HOME_LISTNER=$ORACLE_HOME

省略...

7、
[root@localhost init.d]# gedit /data/oracle/product/11.2.0/db_1/bin/dbshut

文件修改内容为(替换掉ORACLE_HOME_LISTNER=$1):

省略...

# The this to bring down Oracle Net Listener

#ORACLE_HOME_LISTNER=$1

ORACLE_HOME_LISTNER=$ORACLE_HOME

if [ ! $ORACLE_HOME_LISTNER ] ; then

省略...

8、
[root@localhost init.d]# ./oracle start

运行结果为

Processing Database instance "orcl": log file /data/oracle/product/11.2.0/db_1/startup.log

Oracle Start Succesful!OK.

9、
[root@localhost init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc2.d/S61oracle
[root@localhost init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc3.d/S61oracle
[root@localhost init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc4.d/S61oracle
[root@localhost init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc0.d/S61oracle
[root@localhost init.d]# ln -s /etc/rc.d/init.d/oracle /etc/rc6.d/S61oracle
10、
[root@localhost init.d]# ll /etc/rc0.d/

total 0

lrwxrwxrwx. 1 root root 32 Nov 15 01:04 K43vmware-tools-thinprint -> ../init.d/vmware-tools-thinprint

lrwxrwxrwx. 1 root root 20 Nov 14 22:30 K50netconsole -> ../init.d/netconsole

lrwxrwxrwx. 1 root root 17 Nov 14 22:30 K90network -> ../init.d/network

lrwxrwxrwx. 1 root root 22 Nov 15 01:04 K99vmware-tools -> ../init.d/vmware-tools

lrwxrwxrwx 1 root root 23 Dec 1 17:31 S61oracle -> /etc/rc.d/init.d/oracle

11、
[root@localhost init.d]# chkconfig --level 234 oracle on
[root@localhost init.d]# chkconfig --add oracle
[root@localhost init.d]# chkconfig --list oracle

Note: This output shows SysV services only and does not include native

systemd services. SysV configuration data might be overridden by native

systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.

To see services enabled on particular target use

'systemctl list-dependencies [target]'.

oracle 0:on 1:off 2:on 3:on 4:on 5:on 6:on

CentOS 设置 oracle 开机自动启动的更多相关文章

  1. CentOS设置服务开机自动启动【转】

    CentOS设置服务开机自动启动[转]Posted on 2012-06-28 16:00 eastson 阅读(4999) 评论(0) 编辑 收藏 CentOS安装好apache.mysql等服务器 ...

  2. linux系统下设置oracle开机自动启动

    在Linux系统中,安装好oracle数据库服务后,并不像在Windows系统下一样,oracle服务在默认情况下会随时系统的启动自动启动.Linux系统中,是需要用户去手动进行设置,才能实现orac ...

  3. centos设置服务开机自动启动的方法

    centos安装好apache,mysql等服务器程序后,并没有设置成开机自动启动的,为避免重启后还要手动开启web等服务器,还是做下设置好,其实设置很简单,用chkconfig命令就行了. 例如要开 ...

  4. centOS设置zookeeper开机自动启动

    在/etc/rc.local文件中追加: # java_homeexport JAVA_HOME=/opt/java/jdk1.7.0_75# zookeeper/home/cent2014/zook ...

  5. 【CentOS】设置服务开机自动启动

    CentOS安装好apache.mysql等服务器程序后,并没有设置成开机自动启动的,为避免重启后还要手动开启web等服务器,还是做下设置好,其实设置很简单,用chkconfig命令就行了. 例如,要 ...

  6. centos将nginx服务设置为开机自动启动

    centos将nginx服务设置为开机自动启动 1.在/etc/init.d下创建文件nginx 发现原来就有并且配置就是默认的,而且是正确的 命令为: vim /etc/init.d/nginx 需 ...

  7. centos设置服务开机启动

    Linux CentOS设置服务开机启动的方法 by 天涯 · 2013/07/26 CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别 在CentOS或者RedHa ...

  8. CentOS设置服务开机启动的方法

    CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别在CentOS或者RedHat其他系统下,如果是后面安装的服务,如httpd.mysqld.postfix等,安装后 ...

  9. centos设置服务开机自启动

    在CentOS或者RedHat其他系统下,如果是后面安装的服务,如httpd.mysqld.postfix等,安装后系统默认不会自动启动的.就算手动执行/etc/init.d/mysqld start ...

随机推荐

  1. super-smack压测工具

    简介 super-smack是一款开源压测工具,支持MySQL.PostgreSQL.Oracle.本篇主要介绍一下使用super-smack压测MySQL体会. 1.SQL定义 2.数据字典定义 3 ...

  2. C++中string的使用

    概述 这篇博文为了记录C++中string的使用,用到一点补充一点. 预备 使用string之前需要包含头文件 #include<iostream> #include<string& ...

  3. kafka 支持发布订阅

    概述 一般消息队列的是实现是支持两种模式的,即点对点,还有一种是topic发布订阅者模式,比如ACTIVEMQ.KAFKA也支持这两种模式,但是实现的原理不一样. KAFKA 的消息被读取后,并不是马 ...

  4. Mybatis-Plus 实战完整学习笔记(八)------delete测试

    1.根据ID删除一个员工deleteById /** * 删除客户 * * @throws SQLException */ @Test public void deletedMethod() thro ...

  5. CodeForces 916A Jamie and Alarm Snooze (水题)

    题意:给定一个数字n,和一个时间,问你每次可以把当前时间往回调n分钟,然后调多少次后时间中包含数字7. 析:直接模拟就好,从当前分钟向后调,注意调成负数的情况就好.很简单. 代码如下: #pragma ...

  6. jdk1.6的配置

    执行下列命令安装jdk1.7 /usr/lib/jvm$ sudo apt-get install openjdk-7-jdk openjdk-7-jre 会得到下面这两个文件: 查看当前jdk版本: ...

  7. Linux批量远程命令和上传下载工具

    https://github.com/eyjian/mooon/releases/tag/mooon-tools mooon_ssh:批量远程命令工具,在多台机器上执行指定命令 mooon_uploa ...

  8. Ng第十二课:支持向量机(Support Vector Machines)(一)

    1 目录 支持向量机基本上是最好的有监督学习算法了,从logistic回归出发,引出了SVM,揭示模型间的联系,过渡自然. 2 重新审视logistic回归 Logistic回归目的是从特征学习出一个 ...

  9. android:padding和android:margin的区别[转]

    本文综合了:http://zhujiao.iteye.com/blog/1856980 和 http://blog.csdn.net/maikol/article/details/6048647 两篇 ...

  10. hdu 3915 高斯消元

    http://acm.hdu.edu.cn/showproblem.php?pid=3915 这道题目是和博弈论挂钩的高斯消元.本题涉及的博弈是nim博弈,结论是:当先手处于奇异局势时(几堆石子数相互 ...