Deploy oracle 11g R2 on CentOS 6.3 x86-64 (2)

I have introduced how to deply oracle 11g R2 and start it in article https://www.roamway.com/?p=9&preview=true

Then I decide to add oracle to system service and set startup automatically

1. switch to root user,editing oracle startpu script, as shown in the following
cd /etc/init.d
vim oracle

# chkconfig: 35 90 10
# description: Oracle Database Service Daemon.
ORCL_BASE=“/opt/oracle”
ORACLE_HOME=$ORCL_BASE/product/11.2.0/dbhome_1
ORACLE_OWNER=oracle
case“$1”in
start)
su$ORACLE_OWNERc“$ORACLE_HOME/bin/lsnrctl start”
su$ORACLE_OWNERc“$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
su$ORACLE_OWNERc“$ORACLE_HOME/bin/emctl start dbconsole”
touch/var/lock/subsys/oracle11g
;;
stop)
su$ORACLE_OWNERc“$ORACLE_HOME/bin/emctl stop dbconsole”
su$ORACLE_OWNERc“$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
su$ORACLE_OWNERc“$ORACLE_HOME/bin/lsnrctl stop”
rmrf/var/lock/subsys/oracle11g
;;
restart)
$0stop
$0start
;;
*)
echo“Usage: $0{start|stop|restart}”
exit 1
;;
esac
exit 0
Gave executable permission.

chmod +x oracle

2. Add oracle to system service, making it start automatically

chkconfigadd oracle
chkconfig oracle on
chkconfiglist oracle
25
So we can execute “service oracle start|stop|restart” to manage oracle service.

3. In order to operate oracle more smoothly,we can set environment variable in global variable.
vim /etc/profile
Attach following content to the end of profile

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_HOME=oracle
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$PATH:ORACLE_HOME/bin

save and exit

vim /etc/oratab

Modify the letter “X” to “Y”,as shown in the following figure:

26

Save and exit

switch to the directory “/opt/oracle/product/11.2.0/dbhome_1/bin/”
source /etc/profile
cd /opt/oracle/product/11.2.0/dbhome_1/bin/
source /etc/profile

4. Login oracle from local
cd /opt/oracle/product/11.2.0/dbhome_1/bin/
./sqlplus sys AS SYSDBA
27

5. Log off root user,login system by oracle user
cd /opt/oracle/product/11.2.0/dbhome_1/bin/
./sqlplus sys AS SYSDBA
28

So far we have finished installing oracle 11gR2 in CentOS 6.3 x86_64

Leave a Reply