oracle监听器如何自启动,Oracle 数据库和监听器开机自启动两种实现方法

5268f80b9b1e01f982625ef6fac83ca1.png

数据库和监听器开机自启动

编辑oratab文件:

修改:orcl:/u01/app/oracle/product/11.2.0/db_1:N

orcl:/u01/app/oracle/product/11.2.0/db_1:Y

[oracle@ocptest bin]$ 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::

#

# 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.2.0/db_1:Y

执行dbstart和dbshut(数据库启动而监听器没有自启动)

[oracle@ocptest ~]$ dbstart

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

Usage: /u01/app/oracle/product/11.2.0/db_1/bin/dbstart ORACLE_HOME

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

修改dbstart和dbshut文件:

[oracle@ocptest ~]$ cd $ORACLE_HOME/bin

[oracle@ocptest bin]$ vi dbstart

找到这行修改为:

ORACLE_HOME_LISTNER=$1

ORACLE_HOME_LISTNER=$ORACLE_HOME

同上修改dbshut文件。

dbstart验证:

[oracle@ocptest bin]$ dbstart

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

[oracle@ocptest bin]$ ps -ef|grep smon

oracle 4125 1 0 23:46 ? 00:00:00 ora_smon_orcl

oracle 4241 3254 0 23:46 pts/0 00:00:00 grep smon

[oracle@ocptest bin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-APR-2019 23:47:11

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocptest)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date 21-APR-2019 23:46:20

Uptime 0 days 0 hr. 0 min. 51 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File /u01/app/oracle/diag/tnslsnr/ocptest/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocptest)(PORT=1521)))

Services Summary...

Service "orcl" has 1 instance(s).

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...

dbshut验证:

[oracle@ocptest bin]$ dbshut

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

[oracle@ocptest bin]$ ps -ef|grep smon

oracle 4369 3254 0 23:48 pts/0 00:00:00 grep smon

[oracle@ocptest bin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-APR-2019 23:48:32

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocptest)(PORT=1521)))

TNS-12541: TNS:no listener

TNS-12560: TNS:protocol adapter error

TNS-00511: No listener

Linux Error: 111: Connection refused

添加开机自启动:

编辑/etc/rc.d/rc.local添加su oracle -lc /u01/app/oracle/product/11.2.0/db_1/bin/dbstart 到最后一行

[oracle@ocptest ~]$ vi /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don‘t

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

su oracle -lc /u01/app/oracle/product/11.2.0/db_1/bin/dbstart

如果上面没有编辑dbstart和dbshut文件添加侦听器参数:

则还需添加 su oracle -lc "/u01/oracle/bin/lsnrctl start"到/etc/rc.d/rc.local文件中;

第二种方法:

在oracle家目录创建两个文件:

oracle.start

oracle.stop

编辑:

vi oracle.start

[oracle@ocptest ~]$ vi oracle.start

#!/bin/bash

source /u01/app/oracle/product/11.2.0/db_1

lsnrctl start;

sqlplus / as sysdba <

startup

EOF

vi oracle.stop

[oracle@ocptest ~]$ vi oracle.stop

#!/bin/bash

source /u01/app/oracle/product/11.2.0/db_1

sqlplus / as sysdba <

startup

EOF

lsnrctl stop;

权限:

chmod +x /etc/init.d/oracle

chmod a+x oracle.start oracle.stop

单独执行这两个脚本进行验证;

通过copy一个network模板

cp /etc/init.d/network /etc/init.d/oracle

[root@ocptest ~]# vi /etc/init.d/oracle

#! /bin/bash

#

# oracle Bring up/down oracle

#

# chkconfig: 2345 90 1

# description: Activates/Deactivates all oracle configured to # start at boot time.

#

# Source function library.

. /etc/init.d/functions

# See how we were called.

case "$1" in

start)

su - oracle -c "/home/oracle/oracle.start"

;;

stop)

su - oracle -c "/home/oracle/oracle.stop"

;;

*)

echo $"Usage: $0 {start|stop}"

exit 2

esac

chkconfig oracle on

然后重启服务器测试下,我这里测试都没问题。

验证端口:

[oracle@ocptest ~]$ netstat -an|grep :1521

tcp 0 0 192.168.181.2:62747 192.168.181.2:1521 ESTABLISHED

tcp 0 0 :::1521 :::* LISTEN

tcp 0 0 ::ffff:192.168.181.2:1521 ::ffff:192.168.181.2:62747 ESTABLISHED

Oracle 数据库和监听器开机自启动两种实现方法

标签:with   esc   should   call   执行   lin   log   art   rtu

1428d0e076c3959ab11d28a39bc84fab.png

5268f80b9b1e01f982625ef6fac83ca1.png

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:https://www.cnblogs.com/kingwwz/p/10759685.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值