设置oracle 随机启动,配置Oracle单实例随机启动(11gR2)

系统信息:

beiora01:/home/oracle> uname -a

Linux beiora01a.bskyb.com 2.6.18-348.6.1.el5 #1 SMP Tue May 21 15:29:55 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

数据库信息:

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE    11.2.0.3.0      Production

TNS for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 - Production

1. 使用root用户编辑如下文件

vi /etc/init.d/dbora

#!/bin/sh

# chkconfig: 345 99 10

# description: Oracle auto start-stop script.

#

# Set ORA_OWNER to the user id of the owner of the

# Oracle database software.

ORA_OWNER=oracle

case "$1" in

'start')

# Start the Oracle databases:

# The following command assumes that the oracle login

# will not prompt the user for any values

# Remove "&" if you don't want startup as a background process.

su $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1" &

touch /var/lock/subsys/dbora

;;

'stop')

# Stop the Oracle databases:

# The following command assumes that the oracle login

# will not prompt the user for any values

su $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"

rm -f /var/lock/subsys/dbora

;;

esac

修改权限

chmod 750 /etc/init.d/dbora

chkconfig --add dbora

2. 创建自动启动和关闭数据库的脚本

# mkdir -p /home/oracle/scripts

# chown oracle.oinstall /home/oracle/scripts

vi /home/oracle/scripts/startup.sh

注意修改红体自变量

#!/bin/bash

export TMP=/tmp

export TMPDIR=$TMP

export PATH=/usr/sbin:/usr/local/bin:$PATH export ORACLE_HOSTNAME=localhost.localdomain

export ORACLE_UNQNAME=phyprimary

export ORACLE_SID=phyprimary ORAENV_ASK=NO

. oraenv

ORAENV_ASK=YES

# Start Listener

lsnrctl start

# Start Database

sqlplus / as sysdba << EOF

STARTUP;

EXIT;

EOF

vi /home/oracle/scripts/shutdown.sh

注意修改红体字变量

#!/bin/bash

export TMP=/tmp

export TMPDIR=$TMP

export PATH=/usr/sbin:/usr/local/bin:$PATH export ORACLE_HOSTNAME=localhost.localdomain

export ORACLE_UNQNAME=phyprimary

export ORACLE_SID=phyprimary ORAENV_ASK=NO

. oraenv

ORAENV_ASK=YES

# Stop Database

sqlplus / as sysdba << EOF

SHUTDOWN IMMEDIATE;

EXIT;

EOF

# Stop Listener

lsnrctl stop

3. 确认脚本权限

[root@localhost ~]# chmod u+x /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh

[root@localhost ~]# chown oracle.oinstall /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh

4. 测试实验结果

# service dbora start

# service dbora stop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值