Ubuntu Automatic Startup – Shutdown database ORACLE 11g

20 Aug

1. pindah directory terlebih dulu
pmr02@pmr02:~$ sudo su – root
root@pmr02:~# su – oracle
oracle@pmr02:~$
oracle@pmr02:~$ cd $ORACLE_HOME/bin
oracle@pmr02:/u01/app/oracle/product/11.1.0/db_1/bin$ pwd
/u01/app/oracle/product/11.1.0/db_1/bin

2. create script start database
oracle@pmr02:~$ vim.tiny startora11g
#!/bin/sh
# Start the oracle database
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=pmr02
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/dbstart
exit 0

oracle@pmr02:~$ chmod u+x startora11g

3. create script stop database
oracle@pmr02:~$ vim.tiny stopora11g
#!/bin/sh
# Stop the oracle database
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=pmr02
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/dbshut
exit 0

oracle@pmr02:~$ chmod u+x stopora11g

4. create script restart, start & stop
oracle@pmr02:~$ vim.tiny oracle11g
#!/bin/sh
#
# chkconfig: 345 51 49
# description: startup and shutdown the Oracle 8i database
#
echo “Oracle 11g database start/stop/restart”
ORA_OWNER=oracle
ORA_BASE=/u01/app/oracle
ORA_HOME=$ORA_BASE/product/11.1.0/db_1

case “$1? in
‘start’)
# Start the database
echo -n “Starting the database for 11g: ”
su – $ORA_OWNER -c $ORA_HOME/bin/startora11g
echo
;;

‘stop’)
# Stop the database
echo -n “Shutting down database for 11g: ”
su – $ORA_OWNER -c $ORA_HOME/bin/stopora11g
echo
;;

‘restart’)
# Restart the Oracle databases:
echo -n “Restarting database for 11g: ”
$0 stop
$0 start
echo
;;
*)

echo “Usage: oracle11g [ start | stop | restart }”
exit 1
esac
exit 0
oracle@pmr02:~$ chmod u+x oracle11g

5. Login root & edit /etc/oratab.
oracle@pmr02:~$ exit
root@pmr02:~# vim.tiny /etc/oratab
pmr02:/u01/app/oracle/product/11.1.0/db_1:N
menjadi
pmr02:/u01/app/oracle/product/11.1.0/db_1:Y

6. copy script oracle11g to  /etc/init.d/
root@pmr02:~# cp /u01/app/oracle/product/11.1.0/db_1/bin/oracle11g /etc/init.d/
root@pmr02:~# chmod 700 /etc/rc.d/init.d/oracle11g

7. test script oracle11g start, stop, restart with login as root
root@pmr02:~# cd /etc/init.d/
root@pmr02:/etc/init.d# ./oracle11g
Oracle 11g database start/stop/restart
Usage: oracle11g [ start | stop | restart }

root@pmr02:/etc/init.d# ./oracle11g start
Oracle 11g database start/stop/restart
Starting the database for 11g: ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/product/11.1.0/db_1/bin/dbstart ORACLE_HOME
Processing Database instance “pmr02”: log file /u01/app/oracle/product/11.1.0/db_1/startup.log

root@pmr02:/etc/init.d# ./oracle11g stop
Oracle 11g database start/stop/restart
Shutting down database for 11g: ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener
Usage: /u01/app/oracle/product/11.1.0/db_1/bin/dbshut ORACLE_HOME
Processing Database instance “pmr02”: log file /u01/app/oracle/product/11.1.0/db_1/shutdown.log

8. Agar script oracle11g, dijalankan setiap kali boot
root@pmr02:/etc/init.d# update-rc.d oracle11g defaults

2 Responses to “Ubuntu Automatic Startup – Shutdown database ORACLE 11g”

  1. Jack Nicholson August 30, 2010 at 4:45 pm #

    Nice sharing. Excellent work. Keep it buddy. Kindly tell me does it require to set environment variable for xterm? Without setting it can work or not?

  2. setijoagus August 31, 2010 at 1:06 am #

    Without setting variable set environment for xterm, it can work.
    Because, all scriptting in text mode.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: