ORACLE 12C 开机自动启动监听、CDB、PDB
admin
2023-04-18 06:22:55
0

linux下数据库实例监听开机自启动设置
2018年8月1日 zhanky

测试介绍
系统版本:Oracle linux 7.2 x64
数据库版本:Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
实例名:orcl CDP:orcl PDB:orcl1、orcl2
ORACLE_HOME:/u01/app/oracle/product/12.2.0/db_1

一、设置监听和CDB开机自启
通过使用rc.local开机自动运行脚本,调用Oracle自带的dbstart和lsnrct启动。但调用dbstart需要在oratab中允许
1、修改oratab

[root@zhanky ~]# vi /etc/oratab 
[root@zhanky ~]# cat /etc/oratab 
#
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

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

2、编辑rc.local
因为Oracle linux 7.2默认rc.local是没有执行权限,需执行chmod自己增加
dbstart默认将oratab中参数为Y的所有库启动

[root@zhanky ~]# vi /etc/rc.d/rc.local 
[root@zhanky ~]# cat /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
##用oracle用户登录,运行lsnrctl start 脚本启用监听。
su - oracle -c "/u01/app/oracle/product/12.2.0/db_1/bin/lsnrctl start"
##用oracle用户登录,运行dbstart启动数据库
su - oracle -c "/u01/app/oracle/product/12.2.0/db_1/bin/dbstart"
[root@zhanky ~]# chmod +x /etc/rc.d/rc.local

二、设置PDB自动启动
通过触发器来启东PDB,下列触发器中ALTER PLUGGABLE DATABASE ALL OPEN代表将所有PDB启动,
如果只需

CREATE OR REPLACE TRIGGER open_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END open_pdbs;
/

三、测试验证,重启数据库服务器即可。

相关内容

热门资讯

终于了解“酷玩联盟究竟有挂吗?... 终于了解“酷玩联盟究竟有挂吗?”(外卦神器下载)您好,酷玩联盟这个游戏其实有挂的,确实是有挂的,需要...
今日重大消息“微信小程序掼蛋是... 网上科普关于“微信小程序掼蛋有没有挂”话题很是火热,小编也是针对微信小程序掼蛋作*弊开挂的方法以及开...
今日重磅消息“新众亿炸/金/花... 网上科普关于“新众亿炸/金/花有没有挂”话题很是火热,小编也是针对新众亿炸/金/花作*弊开挂的方法以...
【第一财经】“新毛豆互娱到底是... 【第一财经】“新毛豆互娱到底是不是挂?”(其实是有挂)您好,新毛豆互娱这个游戏其实有挂的,确实是有挂...
终于懂了“欢乐情怀开挂器?”(... 有 亲,根据资深记者爆料欢乐情怀是可以开挂的,确实有挂(咨询软件无需打开...
紫燕食品创新研究院:以科研赋能... 在消费升级驱动食品行业高质量发展的背景下,研发创新成为企业核心竞争力的关键支撑。作为卤味行业领军企业...
玩家攻略科普“桂麻圈怎么开挂?... 家人们!今天小编来为大家解答桂麻圈透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买很多...
【第一消息】“海阔麻将到底是不... 有 亲,根据资深记者爆料海阔麻将是可以开挂的,确实有挂(咨询软件无需打开...
终于懂了“阿当福建麻将到底有挂... 网上科普关于“阿当福建麻将有没有挂”话题很是火热,小编也是针对阿当福建麻将作*弊开挂的方法以及开挂对...
今日重磅消息“友间十三张真的有... 您好:友间十三张这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款游...