Enable Oracle startup in CentOS 6.4
Objective: To enable Oracle to start on CentOS 6.4
Solution: First add start, close, restart Oracle services and instance services, and then add this service to the System Service running level.
Set CentOS to automatically start Oracle at startup
Steps:
1. New service
Run the following command:
# Vi/etc/rc. d/init. d/oracle
The content of the Oracle file is:
#! /Bin/bash
# Chkconfig: 234 61 61
# Description: Oracle 11g AutoRun Service
#/Etc/rc. d/init. d/oracle
Case "$1" in
Start)
# Starts oracle listener and instance
Echo "Starting Oracle Database :"
Su-oracle-lc "lsnrctl start"
Su-oracle-lc dbstartup
;;
Stop)
# Shutdown oracle listner and instance
Echo "Shuting down Oracle Database :"
Su-oracle-lc "lsnrctl stop"
Su-oracle-lc dbshutdown
;;
Reload | restart)
$0 stop
$0 start
;;
*)
Echo "Usage: {start | stop | reload | restart }"
Exit 1
Esac
Exit 0
Note: add at least two lines of comments to the script (in step 2). The first line tells chkconfig the running level of the service, and the second line adds a brief description about the service.
The preceding two scripts are involved: dbstart and dbshut.
2. Edit dbstartup and dbshutdown.
Execute Command
$ Vi $ ORACLE_HOME/bin/dbstartup
Content:
# Dbstartup
#/Opt/oracle/102/bin
Sqlplus/as sysdba <EOF
Startup
Exit
EOF
Vi $ ORACLE_HOME/bin/dbshutdown
Content:
# Dbshutdown
#/Home/oracle/102/bin
Sqlplus/as sysdba <EOF
Shutdown immediate
Exit
EOF
3. Check whether the startup script is correct.
# Cd/etc/rc. d/init. d
#./Oracle start
#./Oracle stop
4. Add the created oracle service to the system level.
Run the following command:
# Chmod 750/etc/rc. d/init. d/oracle
# Chkconfig -- level 234 oracle on
# Chkconfig -- add oracle