Home  >  Article  >  Database  >  Linux怎么自动启动Oracle服务和ArcSDE服务

Linux怎么自动启动Oracle服务和ArcSDE服务

WBOY
WBOYOriginal
2016-06-07 15:50:541013browse

其实这个问题最主要的是自动启动Oracle服务,在网上也有很多例子,但是根据例子走并不一定能实现成功,下面就根据我的实际操作来看一下在配置过程中有哪些问题需要注意的。 1:修改Oracle系统配置文件/etc/oratab [root@localhost ~]# vi /etc/oratab 我们查

       其实这个问题最主要的是自动启动Oracle服务,在网上也有很多例子,但是根据例子走并不一定能实现成功,下面就根据我的实际操作来看一下在配置过程中有哪些问题需要注意的。

1:修改Oracle系统配置文件/etc/oratab

[root@localhost ~]# vi /etc/oratab
我们查看下面内容,如果安装好了Oracle,这个配置文件会自动将ORACLE_HOME标识清楚

但是默认为:orcl:/opt/oracle/product/11.2.0/dbhome_1:N,我们只需要修改为Y如下所示即可

# 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:<n>:
#
# 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.
#
#
orcl:/opt/oracle/product/11.2.0/dbhome_1:Y
</n>

2:编写服务脚本

我们可以首先创建一个Oracle配置文件,位置为:/etc/rc.d/init.d文件夹里面

然后进行编辑该文件

[root@localhost ~]# vi /etc/rc.d/init.d/oracle
将下面的信息填入即可

#!/bin/bash
#
#chkconfig:345 99 10
#description: StartupScriptfororacleDatabases
#/etc/rc.d/init.d/oradbstart

export ORACLE_BASE=/opt/oracle/
export ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export SDEHOME=/home/arcsde/sdeexe100
export PATH=$PATH:$ORACLE_HOME/bin:$SDEHOME/bin
case "$1" in
start)
echo "-----startup oracle-----">>/var/log/oracle11log
su - oracle -c $ORACLE_HOME/bin/dbstart
touch /var/lock/subsys/oracle11
echo "-----startup oracle successful-----">>/var/log/oracle11log
echo "OK"



su - arcsde  -c "sdemon -o start -p sde"
;;
stop)
echo "-----shutdown oracle-----">>/var/log/oracle11log
su - oracle -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle11
echo "-----shutdown oracle successful-----">>/var/log/oracle11log
echo "OK"
;;
*)
echo "Usage:'basename$0'start|stop"
exit 1
esac
exit 0
export  ORACLE_SID=orcl
export  PATH=$PATH:$ORACLE_HOME/bin
case "$1" in
start)
echo "-----startuporacle-----">>/var/log/oracle11log
su - oracle -c $ORACLE_HOME/bin/dbstart
touch/var/lock/subsys/oracle11
echo "-----startuporaclesuccessful-----">>/var/log/oracle11log
echo "OK"
;;
stop)
echo "-----shutdwnoracle-----">>/var/log/oracle11log
su - oracle -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle11
echo "-----shutdownoraclesuccessful-----">>/var/log/oracle11log
echo "OK"
;;
*)
echo "Usage:'basename$0'start|stop"
exit1
esac
exit0
注意:

1:需要将用户自己的环境变量,名称进行对比进行修改

2:特别特别注意,有些用户看到这么多,就直接在Windows系统进行编辑,然后再传入到相关的Linux位置,这样做是有问题的。

请参考:http://wenku.baidu.com/view/455f66eb19e8b8f67c1cb9df.html

要么用户之间在Linux进行编辑,要么在windows编辑完使用编辑软件进行转换一下编码即可

也可以使用:dos2unix  文件名来进行转换

3:注意该文件的空格 比如  su  -   oracle ,echo   "----

编辑完毕后,需要修改一下相关的权限

[root@localhost ~]# chmod 755 /etc/rc.d/init.d/oracle


3:建立服务连接
系统启动时启动数据库,我们需要以下连结∶
    [root@localhost ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc2.d/S99oracle
    [root@localhost ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc3.d/S99oracle
    [root@localhost ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc5.d/S99oracle #rc4.d unused
    要在重新启动时停止数据库,我们需要以下连结∶

    [root@localhost ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K01oracle # stop
    [root@localhost ~]# ln -s /etc/rc.d/init.d/oracle /etc/rc.d/rc6.d/K01oracle # restart

说明:S99代表:服务第99个Start

           K01代表:服务地1个Kill

   至于为什么建立软连接到rc2.d等文件,有兴趣自己看看吧,我也不太清楚

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

也可以使用以下方法代替连接

[root@rhsde ~]# chkconfig --add oracle
[root@rhsde ~]# chkconfig --level 345 oracle on
[root@rhsde ~]# chkconfig --list oracle
oracle          0:off   1:off   2:off   3:on    4:on    5:on    6:off

4:修改ORACLE_HOME里面的DBSTART和DBSHUT文件

[oracle@localhost ~]$ vi $ORACLE_HOME/bin/dbstart
其他的不用管,只需要将ORACLE_HOME_LISTNER修改为正确的ORACLE_HOME(与环境变量一致即可)

ORACLE_HOME_LISTNER=/opt/oracle/product/11.2.0/dbhome_1
DBSHUT与DBSTART一样
修改步骤基本结束,用户可以直接reboot进行试验。

注意:在试验过程中:

1:首先可以执行以下我们编辑好的Oracle文件看看是否可以正常启动服务

2:因为我们看到S99Oracle,也就是Oracle服务是第99个启动,所以需要耐心等待,我一开始配置完毕刚启动完linux就去查看Oracle服务,老是没有启动,就老觉得有问题

3:还是那个Oracle配置文件,注意字符。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn