Ubuntu Automatic Startup – Shutdown LISTENER 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 statuslsnr
#!/bin/sh
# Start the oracle listener
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_SID=pmr02
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl status
exit 0

oracle@pmr02:~$ chmod u+x statuslsnr

3. create script start listener
oracle@pmr02:~$ vim.tiny startlsnr
#!/bin/sh
# Start the oracle listener
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_SID=pmr02
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl start
exit 0

oracle@pmr02:~$ chmod u+x startlsnr

4. create script stop listener
oracle@pmr02:~$ vim.tiny stoplsnr
#!/bin/sh
# Start the oracle listener
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_SID=pmr02
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl stop
exit 0

oracle@pmr02:~$ chmod u+x stoplsnr

5. create script status,start dan stop listener
oracle@pmr02:~$ vim.tiny listener11g
#!/bin/sh
#
# chkconfig: 345 51 49
# description: startup and shutdown the Oracle 11g listener
#
echo “Oracle 11g listener start/stop/status”
ORA_OWNER=oracle
ORA_BASE=/u01/app/oracle
ORA_HOME=$ORA_BASE/product/11.1.0/db_1

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

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

‘status’)
# Status the listener
echo -n “Status Listener for 11g: ”
su – $ORA_OWNER -c $ORA_HOME/bin/statuslsnr
echo
;;

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

echo “Usage: listener11g [ status | start | stop | restart }ORACLE_SID=pmr02
exit 1
esac
exit 0

oracle@pmr02:~$ chmod u+x listener11g

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

7. test script listener11g login as root
root@pmr02:~# cd /etc/init.d/
root@pmr02:/etc/init.d# ./listener11g
Oracle 11g listener start/stop/status
Usage: listener11g [ status | start | stop | restart }

root@pmr02:/etc/init.d# ./listener11g restart
Oracle 11g listener start/stop/status
Restarting Listener for 11g: Oracle 11g listener start/stop/status
Shutting down Listener for 11g:
LSNRCTL for Linux: Version 11.1.0.6.0 – Production on 20-AUG-2010 10:16:02
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pmr02)(PORT=1521)))
The command completed successfully
Oracle 11g listener start/stop/status
Starting the Listener for 11g:
LSNRCTL for Linux: Version 11.1.0.6.0 – Production on 20-AUG-2010 10:16:04
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr: please wait…
TNSLSNR for Linux: Version 11.1.0.6.0 – Production
System parameter file is /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/pmr02/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pmr02)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pmr02)(PORT=1521)))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.1.0.6.0 – Production
Start Date                20-AUG-2010 10:16:04
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/pmr02/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pmr02)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

root@pmr02:/etc/init.d# ./listener11g status
Oracle 11g listener start/stop/status
Status Listener for 11g:
LSNRCTL for Linux: Version 11.1.0.6.0 – Production on 20-AUG-2010 10:15:30
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pmr02)(PORT=1521)))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.1.0.6.0 – Production
Start Date                20-AUG-2010 08:31:29
Uptime                    0 days 1 hr. 44 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/pmr02/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pmr02)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “pmr02” has 1 instance(s).
Instance “pmr02”, status READY, has 1 handler(s) for this service…
Service “pmr02XDB” has 1 instance(s).
Instance “pmr02”, status READY, has 1 handler(s) for this service…
Service “pmr02_XPT” has 1 instance(s).
Instance “pmr02”, status READY, has 1 handler(s) for this service…
The command completed successfully

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

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

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

    It is really nice detail of scripting provide for startup and shutdown listener automatically in Ubantu. Does it work for another linux also?

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

    yes, it work for another linux also, i use scripting in Linux Centos (RedHat Community)

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: