oracle上设置自动启动多个数据实例

本文介绍两种启动多个Oracle数据实例的方法,一种是通过手动设置环境变量并启动每个实例,另一种是通过配置系统服务实现开机自动启动所有实例。同时,还介绍了如何配置监听端口和服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现有一台机器,需要启动多个数据实例,如DB1、DB2
方法一:
export ORACLE_SID=DB1
sqlplus ‘/as sysdba' <<!
startup
exit
!
 
export ORACLE_SID=DB2
sqlplus ‘/as sysdba' <<!
startup
exit
!
 
如果是不同的监听端口,启动监听端口的方法是lsnctl start listener1/linsterner2/
关于listener?的配置可以通过lsnctl status查看配置文件,然后再编辑他就好了。
 
如果是同一端口,只需启动lsnctl start就好了。
 
关于web配置的启动,可以更改SID启动
export ORACLE_SID=DB1
emctl start dbconsole

方法二:(开机自动启动oracle数据实例)
修改/etc/oratab文件,将需要启动的实例名称后面的N修改为Y,如果要全部都启动,则使用
:g/N/s//Y/g将全部N修改为Y
然后编写个shell脚本
cd /etc/init.d

vi orasrvd

#!/bin/bash

# chkconfig: 35 95 1
# description: script to start/stop oracle serverd
    
case "$1" in
start)
    date >>/var/log/oracle
    echo -e "\nThe oracle will start\n">/var/log/oracle
    su - oracle -c "lsnrctl start;dbstart;emctl start dbconsole;exit;">>/var/log/oracle
    echo -e "The oracle started">>/var/log/oracle
;;
stop)
     date >>/var/log/oracle
    echo -e "\nThe oracle will stop\n">/var/log/oracle
    su - oracle -c "dbshut;emctl stop dbconsole;lsnrctl stop;exit;">>/var/log/oracle
    echo -e "The oracle stoped">>/var/log/oracle
;;
restart)
    $0 stop
    $0 start
;;
*)
    echo -e "usage $0 {start|stop|restart}"
    exit 1
esac
保存。

注:以上红色部分必须要加,否则不能用chkconfig
chmod a+x oracle.sh

chkconfig --add orasrvd   加入系统服务

chkconfig --list 查看
这样就可以实现oracle多实例自动启动了。

 

删除orasrvd服务
chkconfig --del orasrvd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值