设为首页 加入收藏

TOP

Solairs系统中配置Oracle 12c 开机启动
2017-02-18 08:15:22 】 浏览:260
Tags:Solairs 系统 配置 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


重启服务器,测试成功。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Oracle 12C 开启数据库归档模式 下一篇Oracle GoldenGate 12.2-异构环境..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目