编辑oratab文件
#用root用户执行编辑vi /etc/oratab# This file is used by ORACLE utilities. It is created by root.sh# and updated by either Database Configuration Assistant while creating# a database or ASM Configuration Assistant while creating ASM instance.# 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|Y>:## 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:/data/oracle/product/11.2.0/db_1:Y#最后一行的N改成Y
编辑rc.local文件
#用root用户进行编辑操作vim /etc/rc.d/rc.local#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In contrast to previous versions due to parallel execution during boot# this script will NOT be run after all other services.## Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure# that this script will be executed during boot.touch /var/lock/subsys/localsu - oracle -c '/data/oracle/product/11.2.0/db_1/bin/lsnrctl start'su - oracle -c '/data/oracle/product/11.2.0/db_1/bin/dbstart'#最后两行为添加内容#给rc.local文件可执行权限chmod +x /etc/rc.d/rc.local
新建Oracle服务启动脚本
#用root用户编辑操作vim /etc/init.d/oracle#!/bin/sh# chkconfig: 345 61 61# description: Oracle 11g R2 AutoRun Servimces# /etc/init.d/oracle## Run-level Startup script for the Oracle Instance, Listener, and# Web Interfaceexport ORACLE_BASE=/data/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export ORACLE_SID=ORCLexport PATH=$PATH:$ORACLE_HOME/binORA_OWNR="oracle"# if the executables do not exist -- display errorif [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]thenecho "Oracle startup: cannot start"exit 1fi# depending on parameter -- startup, shutdown, restart# of the instance and listener or usage displaycase "$1" instart)# Oracle listener and instance startupsu $ORA_OWNR -lc $ORACLE_HOME/bin/dbstartecho "Oracle Start Succesful!OK.";;stop)# Oracle listener and instance shutdownsu $ORA_OWNR -lc $ORACLE_HOME/bin/dbshutecho "Oracle Stop Succesful!OK.";;reload|restart)$0 stop$0 start;;*)echo $"Usage: `basename $0` {start|stop|reload|reload}"exit 1esacexit 0#增加 oracle服务控制脚本执行权限chmod +x /etc/rc.d/init.d/oracle#将 oracle服务加入到系统服务chkconfig --add oracle#检查 oracle服务是否已经生效chkconfig --list oracle
此命令:chkconfig --list oracle执行后如下图所示:

测试

文章转载自WorkLifeRecords,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




