Linux 下自动启动多个oracle实例

From:
http://blog.sina.com.cn/s/blog_6619c0420101bia8.html

Linux下自动启动多个oracle实例
—环境:

1> linux:linux4.5-32-bit-x86-setup

2> oracleracle Database10gRelease 2 (10.2.0.1.0) EnterpriseStandard Edition for Linux x86

--------------------------------------------------------
—操作详细过程:
[root@localhost ~]#cd /etc/rc.d/init.d
[root@localhost init.d]#touch dbauto              
用命令新建好文件(或是 在root用户etc/rc.d/init.d目录下直接新建文件),然后在文件中加入--下面--的脚本内容,保存
[root@localhost ~]# chmod 755 /etc/rc.d/init.d/dbauto    // 设置文件权限
[root@localhost ~]# ls -l /etc/rc.d/init.d/dbauto
-rwxr-xr-x  1 oracle oinstall 785 Oct 23 08:27 /etc/rc.d/init.d/dbauto
[root@localhost ~]# chkconfig --add dbauto   服务添加服务列表
[root@localhost ~]# chkconfig --level 345 dbauto on    //设置dbauto服务在指定的运行级别内被启动
[root@localhost ~]#vi dbauto  //添加下面内容

1)启动一个数据库实力时编写的脚本(取名dbauto)
#!/bin/bash
#
# chkconfig: 35 95 1
# description: init script. to start/stop oracle database10g, TNS
listener, EMS, isqlplus
#
#
#
# match these values to your environment:


export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
# export ORACLE_TERM=xterm
export PATH=$PATH/ORACLE_HOME/bin
export NLS_LANG='american_america.ZHS16GBK'
export ORACLE_SID=orc1
# export DISPLAY=localhost:0
export ORACLE_USER=oracle

# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start
EOO
;;

stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop
EOO
;;

*)
echo "Usage: $0 {start|stop}"
;;
esac

2)启动多个数据库实力时编写的脚本(取名dbauto)

//这个执行完成后所有实例都正常启动,服务正常运行============================================================
#!/bin/bash
#
# chkconfig: 35 95 1
# description: init script. to start/stop oracle database10g, TNS
listener, EMS, isqlplus
#
#
#
# match these values to your environment:


export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
# export ORACLE_TERM=xterm
export PATH=$PATH/ORACLE_HOME/bin
export NLS_LANG='american_america.ZHS16GBK'
export ORACLE_SID=orc1
# export DISPLAY=localhost:0
export ORACLE_USER=oracle

# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog <<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start
#change ORACLE_SID
export ORACLE_SID=Test001
lsnrctl start
sqlplus /nolog <<EOS
connect /as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start

EOO
;;

stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog <<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop
#change ORACLE_SID
export ORACLE_SID=Test001
lsnrctl stop
sqlplus /nolog <<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop

EOO
;;

*)
echo "Usage: $0 {start|stop}"
;;
esac

注意:编辑好启动文件后,需要给予执行权限!

 


<script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/buttonLite.js#style=-1&uuid=&pophcol=3&lang=zh"></script> <script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/bshareC0.js"></script>
阅读(160) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值