Chinaunix首页 | 论坛 | 博客
  • 博客访问: 20428
  • 博文数量: 5
  • 博客积分: 336
  • 博客等级: 二等列兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-17 15:31
文章分类
文章存档

2010年(5)

最近访客

分类: Oracle

2010-07-27 15:28:25

设置oracle11gR1linux主机启动

个人声明,此文章是参考网络资料进行修改,请尊重他们劳动结晶。

在安装oracle11gR1数据库之后,数据库实例(dbstart|dbshut),数据库监听(lsnrctl start|stop),控制台(emtcl start|stop)等,不会随主机启动。每次需要自己手动启动这些服务,本人根据网络资料进行修改并通过测试。

1.使用oracle用户修改/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::

#

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

#

#

ora:/opt/oracle/product/11.1.0/db_1:N

修改为:ora:/opt/oracle/product/11.1.0/db_1:Y

2.使用Oracle用户修改$ORACLE_HOME/bin/dbstart文件和$ORACLE_HOME/bin/dbshut文件找到下列代码,在最前端;

~>vi dbstart文件

# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1 //需要将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME

if [ ! $ORACLE_HOME_LISTNER ] ; then

  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"

  echo "Usage: $0 ORACLE_HOME"

else

  LOG=$ORACLE_HOME_LISTNER/listener.log

同样,也需要修改 dbshut文件

~>vi dbshut文件

# The  this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$1//需要将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME

if [ ! $ORACLE_HOME_LISTNER ] ; then

  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"

  echo "Usage: $0 ORACLE_HOME"

else
  LOG=$ORACLE_HOME_LISTNER/listener.log

3.测试运行 dbshut, dbstart 看能否启动Oracle 服务及listener服务,用oracle用户去运行如:

~>./dbstart./dbshut文件,一般是能成功的。并在/opt/oracle/product/11.1.0/db_1/目录下生成startup.logshutdown.log文件。

修改dbstartdbshut的日志文件的权限:

$su - root

#cd $ORACLE_HOME

#chown oracle:oinstall startup.log

#chown oracle:oinstall shutdown.log

注:startup.log shutdown.log 可能没有,当你运行 ./dbstart ./dbshut 之后才自动创建。

此次红色部分,是参考网络资料,本人是用oracle用户去运行,不需要更改这两个文件属性。

4.查看各个数据库实例,监听文件是否起来。

~> ps -efw | grep ora_

~>lsnrctl status

~> ps -efw | grep LISTEN | grep -v grep

可以看到对应的服务启动信息。

5.root用户在/etc/init.d/目录下创建oracle文件,此文件名自己随便起,只要能自己知道是启动服务就ok了。oracle文件内容如下:

#!/bin/sh

# chkconfig: 345 61 61

# description: Startup Script for Oracle Databases

# /etc/rc.d/init.d/dbstart

# if the executables do not exist -- display error

ORACLE_SID=ora

ORACLE_BASE=/opt/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1

export ORACLE_SID ORACLE_BASE ORACLE_HOME

export TNS_ADMIN=$ORACLE_BASE/product/11.1.0/db_1

PATH=$PATH:/$ORACLE_HOME/bin:$HOME/bin

export PARH

ORA_OWNR="oracle"

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

echo "Oracle startup: cannot start"

exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

start)

# Oracle listener and instance startup

echo -n "Starting Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

touch /var/lock/Oracle

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"

#su - $ORA_OWNR -c "$ORACLE_HOME/bin/sqlplus start"

echo "OK"

;;

stop)

# Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"

#su - $ORA_OWNR -c "$ORACLE_HOME/bin/sqlplus stop"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"

rm -f /var/lock/Oracle

echo "OK"

;;

reload|restart)

$0 stop

$0 start

;;

*)

echo "Usage: `basename $0` start|stop|restart|reload"

exit 1

esac

exit 0

此文件主要是配置数据库实例,监听文件,控制台各个的服务。之后修改文件属性。

~#chown oracle.oinstall /etc/init.d/oracle

~#chmod 775 /etc/init.d/oracle

6. oracle文件添加到启动服务里。

chkconfig --add oracle

chkconfig --list oracle

chkconfig --list oracle运行结果:

oradbstart 0:off 1:off 2:off 3:on 4:on 5:on 6:off

可以看到345,的服务是启动的,可以明确在345模式下能启动oracle服务。详细资料可以参考网络资料,主要是系统运行级别部分。

ln -s /etc/init.d/oracle /etc/rc3.d/K61oracle

ln -s /etc/init.d/oracle /etc/rc4.d/S61oracle

ln -s /etc/init.d/oracle /etc/rc5.d/S61oracle

当然设置这些启动之后,系统的启动也就变慢了。

http://jeff2008.javaeye.com/blog/580564

http://youtops.javaeye.com/blog/442540

http://ithero.javaeye.com/blog/315095

 

阅读(1498) | 评论(0) | 转发(1) |
0

上一篇:10 个Linux操作的好习惯(转载)

下一篇:没有了

给主人留下些什么吧!~~