配置Oracle数据库和监听随Linux系统自启动【转】

1、修改oratab 文件,该文件的功能是控制Oracle的启动(dbstart)和关闭脚本(dbshut)是否可用。

[root@localhost etc]# 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:

ORACLESID: O R A C L E S I D : 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.

orcl:/data/oracle/product/11.2.0/dbhome_1:N #把N修改成Y

2、修改oratab的访问权限

[root@localhost etc]# chmod 755 /etc/oratab

3、编写自动启停脚本,脚本名称“oracle”,该文件需要保存在/etc/rc.d/init.d目录中。vi /etc/rc.d/init.d/oracle

!/bin/bash

#

Script. Function: Auto start oracle instance and listener.

Script. Name: oracle

Author:

Date: 2015-11-13

#

case “ 1instart)echoStartingOracleDatabasesuoraclecdbstartechoDone.echoStartingOracleListenersuoracleclsnrctlstartechoDone.touch/var/lock/subsys/oracle;;stop)echoShuttingdownOracleListenersuoracleclsnrctlstop>>/var/log/oracleechoDone.rmf/var/lock/subsys/oracleechoShuttingdownOracleDatabasesuoraclecdbshutechoDone.echo;;restart) 1 ” i n s t a r t ) e c h o “ S t a r t i n g O r a c l e D a t a b a s e … ” s u − o r a c l e − c “ d b s t a r t ” e c h o “ D o n e . ” e c h o “ S t a r t i n g O r a c l e L i s t e n e r … ” s u − o r a c l e − c “ l s n r c t l s t a r t ” e c h o “ D o n e . ” t o u c h / v a r / l o c k / s u b s y s / o r a c l e ; ; s t o p ) e c h o “ S h u t t i n g d o w n O r a c l e L i s t e n e r … ” s u − o r a c l e − c “ l s n r c t l s t o p ” >> / v a r / l o g / o r a c l e e c h o “ D o n e . ” r m − f / v a r / l o c k / s u b s y s / o r a c l e e c h o “ S h u t t i n g d o w n O r a c l e D a t a b a s e … ” s u − o r a c l e − c “ d b s h u t ” e c h o “ D o n e . ” e c h o “ ” ; ; r e s t a r t ) 0 stop
$0 start
;;
*)
exit 1
esac

4、修改oracle脚本的权限

chmod 755 oracle

5、建立连接文件

ln -s ../init.d/oracle /etc/rc.d/rc2.d/S87oracle

ln -s ../init.d/oracle /etc/rc.d/rc3.d/S87oracle

ln -s ../init.d/oracle /etc/rc.d/rc5.d/S87oracle

6、重新启动Linux系统后,Oracle的实例和监听自动启动。进行验证:

[root@localhost ~]# su - oracle #切换Oracle用户

[oracle@localhost ~]$ lsnrctl status #查看监听状态
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-AUG-2018 16:40:10
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 17-AUG-2018 16:33:58
Uptime 0 days 0 hr. 6 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /data/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /data/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.184.130)(PORT=1521)))
Services Summary…
Service “orcl” has 2 instance(s).
Instance “orcl”, status UNKNOWN, has 1 handler(s) for this service…
Instance “orcl”, status READY, has 1 handler(s) for this service…
Service “orclXDB” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully

[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Aug 17 16:41:15 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name,status from v$instance; #查看数据库状态

INSTANCE_NAME

STATUS

orcl
OPEN

原文地址:https://www.cnblogs.com/chenjunjie/p/4962353.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值