solairs系统中配置oracle 12c 开机启动

安装完成oracle 12c的数据库后,发现不能随机开启数据库。

如何使用系统脚本完成数据库的随机启动呢?

整理一下,Oracle Solaris系统中完成oracle 12c数据库自动的启动、关闭和重新启动的操作步骤。


1、oratab文件

对于非Oracle Solaris系统的oratab文件会保存在/etc/oratab,而solairs系统的oratab文件保存在/var/opt/oracle目录下。

# cat /var/opt/oracle/oratab

这个文件里面的内容很简短,格式$ORACLE_SID:$ORACLE_HOME:

当$ORACLE_SID:$ORACLE_HOME:设置为Y时,允许实例自启动,当设置为N时,则不允许自启动


# cat /var/opt/oracle/oratab

dota:/export/home/oracle/app/product/12.1.0.2/dbhome_1:Y


该oratab文件使用root.sh脚本创建,并且在使用DBCA命令时会更新这个文件。它的作用很简单,类似于房间里面电力系统总开关闸的作用。


2、dbstart和dbshut


对于数据库的启停还是oracle的$ORALCE_HOME/bin目录下,dbstart和dbshut两个脚本。

dbstart和dbshut脚本中,对于oratab文件有这么一段描述。

# This script will start all databases listed in theoratabfile

# whose third field is a "Y".  If the third field is set to "Y" and

# there is no ORACLE_SID for an entry (the first field is a *),

# then this script will ignore that entry.


3、创建dbora文件并加入系统环境中


在/etc/init.d/目录下,创建文件dbora,内容如下


#! /bin/sh

# description: Oracle auto start-stop script.

#

# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME

# from which you wish to execute dbstart and dbshut;

#

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

# Oracle database in ORACLE_HOME.

#ORA_HOME=   

#ORA_OWNER=


ORA_HOME=/export/home/oracle/app/product/12.1.0.2/dbhome_1

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 "$ORA_HOME/bin/dbstart $ORA_HOME" &

    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 "$ORA_HOME/bin/dbshut $ORA_HOME" &

    rm -f /var/lock/subsys/dbora

    ;;

Esac


我们可以在root用户下使用命令进行测试

#  su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"  

即使切换到oracle用户执行./dbstart命令测试,发现无法执行成功并返回以下错误

./bin/dbstart: dota: argument expected 

原因是在dbstart和dbshut文件中使用/bin/sh的shell,而脚本中含有bash格式的命令行,需要使用/bin/bash的shell。所以在dbstart和dbshut文件中,使用/bin/bash替换掉/bin/sh


更改文件数组和权限、创建软连接

# chgrp dba dbora

# chmod 750 dbora

 

# ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora

# ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora

 

重启服务器,测试成功。


其它操作系统的设置,参考官方网站介绍 https://docs.oracle.com/database/121/UNXAR/strt_stp.htm#UNXAR417


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27039319/viewspace-2133148/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27039319/viewspace-2133148/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值