数据库和监听器开机自启动
 
编辑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. Mysql设置允许外网访问(图文)

    1.打开mysql.exe(MySQL Command Line Client),输入密码 2.输入:use mysql; 3.查询host输入: select user,host from user ...

  2. Linux命令(二十六) 用户管理命令

    一.添加用户 useradd useradd 命令用于创建新用户,格式为useradd [选项] 用户名. 可以使用 useradd 命令创建用户帐户,使用该命令创建账户时,默认的用户目录在 /hom ...

  3. Delphi中如何实现模拟组合按键,如发送Ctrl+F的按键

    利用 keybd_event函数可实现,如下面的代码用以实现在一个公共菜单中模拟Ctrl_F按钮以调用DBGridEH的查找对话框功能:这是在一个ActionList中的某一Action的OnExec ...

  4. idea中 读取mybatis的配置文件时候 如果放在文件下面 需要加上路径

  5. SSM 中 BaseController 使用 session

    转载: http://blog.sina.com.cn/s/blog_7085382f0102v9jg.html public class BaseController { //region Http ...

  6. 【BZOJ1295】[SCOI2009]最长距离(最短路)

    [BZOJ1295][SCOI2009]最长距离(最短路) 题面 BZOJ 洛谷 题解 这题很妙啊. 我们枚举一个点,只需要考虑到他的最远点就行了,显然只需要考虑一个点即可.那么这两个点之前联通的最小 ...

  7. Docker镜像加速==》阿里云加速器

    1.使用阿里云加速器加快获取docker官方的镜像 步骤一:如果没有阿里云账号,需要注册阿里云开发账号 https://dev.aliyun.com/ 步骤二:进入加速器页面获取加速信息 https: ...

  8. Python之旅:并发编程之协程

    一 引子 本节的主题是基于单线程来实现并发,即只用一个主线程(很明显可利用的cpu只有一个)情况下实现并发,为此我们需要先回顾下并发的本质:切换+保存状态 cpu正在运行一个任务,会在两种情况下切走去 ...

  9. mes平台的一些方法

    1.打开的一个缓存的页面的代码 $.openPane({ "width":"1500px",     "height":"1000 ...

  10. OpenStack 图形化服务 Horizon使用(十三)

    构建一台云主机 上图中Count可以选择同时创建多台 最终“启动实例” 创建成功后,可以进入控制台,操作新建云主机