数据库和监听器开机自启动
 
编辑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:<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.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 <<EOF
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 <<EOF
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 数据库和监听器开机自启动两种实现方法的更多相关文章

  1. Oracle数据库日期范围查询的两种实现方式

    参考文档:http://database.51cto.com/art/201108/288058.htm Oracle数据库日期范围查询有两种方式:to_char方式和to_date方式,接下来我们通 ...

  2. ORACLE数据库实现自增的两种方式

    Mysql数据库因为其有自动+1,故一般我们不需要花费太多时间,直接用关键字auto_increment即可,但是Oracle不行,它没有自动增长机制.顾我们需要自己去实现.一般有两种方式,但是这两种 ...

  3. 通过exp命令对Oracle数据库进行备份操作(提供两种情况的备份:备份本地,备份远程的数据库)

    exp 用户名/密码@数据库所在ip地址:数据库端口号/数据库的service-name file=存储到的位置 这个是能成功的 http://www.2cto.com/database/201402 ...

  4. Oracle数据库创建表是有两个约束带有默认索引

    Oracle数据库创建表是有两个约束带有默认索引.1.主键primary Key:唯一索引.非空2.唯一Unique:唯一索引,可以是空值如果没有设定主键和唯一约束,表中不会有默认索引的. 建立主键/ ...

  5. 解决mybatis实体类和数据库列名不匹配的两种办法

    我们在实际开发中,会遇到实体类与数据库类不匹配的情况,在开发中就会产生各种各样的错误,那么我们应该怎么去解决这一类的错误呢?很简单,下面我们介绍两种解决方法: 首先我们看一下数据库和实体类不匹配的情况 ...

  6. oracle多表关联删除的两种方法

    oracle多表关联删除的两种方法 第一种使用exists方法 delete from tableA where exits ( select 1 from tableB Where tableA.i ...

  7. linux安装mysql服务分两种安装方法:

    linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点是安装速度 ...

  8. 两种Ajax方法

    两种Ajax方法 Ajax是一种用于快速创建动态网页的技术,他通过在后台与服务器进行少量的数据交换,可以实现网页的异步更新,不需要像传统网页那样重新加载页面也可以做到对网页的某部分作出更新,现在这项技 ...

  9. 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结

    史上最全的CSS hack方式一览 2013年09月28日 15:57:08 阅读数:175473 做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我 ...

随机推荐

  1. [转帖] 一文看懂:"边缘计算"究竟是什么?为何潜力无限?

    一文看懂:"边缘计算"究竟是什么?为何潜力无限? 转载cnbeta   云计算 雾计算 边缘计算...   知名创投调研机构CB Insights撰文详述了边缘计算的发展和应用前景 ...

  2. OneZero第二周第二次站立会议(2016.3.29)

    会议时间:2016年3月29日  13:05~13:16 会议成员:冉华,张敏,王巍,夏一鸣. 会议目的:汇报前一天工作,全体成员评论,确定会后修改内容或分配下一步任务. 会议内容:以下是会议插图 1 ...

  3. KM算法 PK 最小费用最大流

    用到了KM算法 ,发现自己没有这个模板,搜索学习一下上海大学final大神,http://www.cnblogs.com/kuangbin/p/3228861.html #include <st ...

  4. SpringBoot 7.SpringBoot 结合 Thymeleaf

    一.引入 Thymeleaf 依赖 <!-- Spring boot - thymeleaf --> <dependency> <groupId>org.sprin ...

  5. SVN Update Error: Please execute the 'Cleanup' command

    尝试用下面两种方法 svn clean up 中有一个选项break lock勾选上 把对应的文件来里的.svn里面的lock文件删除. svn local delete, incoming dele ...

  6. ssm 整合 redis(简单教程)

    最后我建议大家使用 Spring StringRedisTemplate 配置,参阅: http://blog.csdn.net/hanjun0612/article/details/78131333 ...

  7. The Super Powers UVA - 11752(合数幂)

    题意: 求1~2^64-1之间所有的 至少是两个不同的正整数的幂的数  升序输出 一个数的合数次幂即为这样的数 找出1~2^64-1中所有数的合数次幂 用set存起来(既能防止重复 又能升序) 最后输 ...

  8. MT【125】四点共圆

    (2017湖南省高中数学竞赛16题) \(AB\)是椭圆\(mx^2+ny^2=1(m>0,n>0,m\ne n)\)的斜率为 1 的弦.\(AB\)的垂直平分线与椭圆交于两点\(CD\) ...

  9. 【刷题】BZOJ 3653 谈笑风生

    Description 设T 为一棵有根树,我们做如下的定义: ? 设a和b为T 中的两个不同节点.如果a是b的祖先,那么称"a比b不知道 高明到哪里去了". ? 设a 和 b 为 ...

  10. STM32配置GPIO前须先打开其时钟,否则配置失败

    @2018-5-9 17:11:38 STM32配置GPIO前须先打开其时钟,否则配置失败