Automatic Startup – Shutdown LISTENER ORACLE 11g

9 Dec

1. create script status listener
[oracle@mkt ~]$ cd $ORACLE_HOME/bin
[oracle@mkt bin]$ vi 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=mkt
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=ubs
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl status
exit 0

[oracle@mkt ~]$ chmod u+x statuslsnr

2. create script start listener
[oracle@mkt ~]$ cd $ORACLE_HOME/bin
[oracle@mkt bin]$ vi 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=mkt
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=ubs
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl start
exit 0

[oracle@mkt bin]$ chmod u+x startlsnr

3. create script stop listener
[oracle@mkt ~]$ cd $ORACLE_HOME/bin
[oracle@mkt bin]$ vi 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=mkt
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_SID=ubs
export ORACLE_TERM=xterm
$ORACLE_HOME/bin/lsnrctl stop
exit 0

[oracle@mkt bin]$ chmod u+x stoplsnr

4. create script status,start dan stop listener
[oracle@mkt ~]$ cd $ORACLE_HOME/bin
[oracle@mkt bin]$ vi 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 }”
exit 1
esac
exit 0

[oracle@ubs bin]$ chmod u+x listener11g

4. copy script listener11g to /etc/rc.d/init.d/
[oracle@mkt bin]$ su – root
Password:
[root@mkt ~]# cp /u01/app/oracle/product/11.1.0/db_1/bin/listener11g /etc/rc.d/init.d/
[root@mkt ~]# chmod 700 /etc/rc.d/init.d/listener11g

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

[root@mkt 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 09-DEC-2008 14:41:00
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mkt.localdomain)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 – Production
Start Date 09-DEC-2008 07:55:38
Uptime 0 days 6 hr. 45 min. 22 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/mkt/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mkt.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “mkt” has 1 instance(s).
Instance “mkt”, status READY, has 1 handler(s) for this service…
Service “mktXDB” has 1 instance(s).
Instance “mkt”, status READY, has 1 handler(s) for this service…
Service “mkt_XPT” has 1 instance(s).
Instance “mkt”, status READY, has 1 handler(s) for this service…
The command completed successfully

[root@mkt 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 09-DEC-2008 14:42:02

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mkt.localdomain)(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 09-DEC-2008 14:42:07

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/mkt/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mkt.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mkt.localdomain)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 – Production
Start Date 09-DEC-2008 14:42:07
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/mkt/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mkt.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

6. chkconfig script listener11g
[root@mkt init.d]# /sbin/chkconfig –add listener11g
[root@mkt init.d]# /sbin/chkconfig –list listener11g
listener11g 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@mkt init.d]# /sbin/chkconfig listener11g on

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

  1. Subekti February 4, 2009 at 4:35 am #

    setelah sekian kali install oracle 10g (32 dan 64 bit)di server (32 dan 64 bit), saya menemukan ada yang aneh dalam instalasi oracle di eth1 (bukan eth0).

    Studi kasus, pak.

    1. server punya 2 nic, eth0 dan eth1. karena satu dan lain hal (misal terbakar, dll) eth0, tidak digunakan. yg digunakan eth1.
    2. install oracle 10g, welcome screen…bla..bla…. congratulation. artinya sukses install oracle
    3.
    $ sqlplus /nolog

    SQL*Plus: Release 10.2.0.1.0 – 64bit Production on Wed Feb 4 11:13:55 2009
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    SQL> conn / as sysdba
    Connected.
    SQL> select count(*) from v$session;
    COUNT(*)
    ———-
    22

    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – 64bit Production
    With the Partitioning, OLAP and Data Mining options

    $ lsnrctl start
    LSNRCTL for Linux: Version 10.2.0.1.0 – Production on 04-FEB-2009 11:25:47
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait…

    TNS-12537: TNS:connection closed
    TNS-12560: TNS:protocol adapter error
    TNS-00507: Connection closed
    Linux Error: 29: Illegal seek

    $ lsnrctl status
    LSNRCTL for Linux: Version 10.2.0.1.0 – Production on 04-FEB-2009 11:18:20
    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=dbdev)))
    TNS-12541: TNS:no listener
    TNS-12560: TNS:protocol adapter error
    TNS-00511: No listener
    Linux Error: 111: Connection refused
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostdev)(PORT=1521)))
    TNS-12541: TNS:no listener
    TNS-12560: TNS:protocol adapter error
    TNS-00511: No listener
    Linux Error: 111: Connection refused
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=hostdev)(PORT=2484)))
    TNS-12541: TNS:no listener
    TNS-12560: TNS:protocol adapter error
    TNS-00511: No listener
    Linux Error: 111: Connection refused

    ada solusi untuk ini, pak??

  2. setijoagus February 5, 2009 at 6:00 am #

    selama ini aku nggak pny msalah diinstall di eth0 / eth1, kl sepintas lihat dari errornya ada disetting lsnrctl
    coba di cek di file :

    $ vi $ORACLE_HOME/network/admin/listener.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ppc)(PORT = 1521))
    )
    )

    dari contoh diatas jika host menyebutkan nama, ini berkonotasi terhadap file /etc/hosts, periksa :

    $ vim /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1 ppc localhost.localdomain localhost
    172.20.141.25 ppc

    jadi solusinya ada 2
    a. ganti $ORACLE_HOME/network/admin/listener.ora host dengan ip
    b. edit /etc/hosts sesuaikan ip dan nama

    semoga membantu

    nb :
    sorry baru jawab sedang banyak kerjaan

  3. Subekti February 5, 2009 at 9:29 am #

    listener.ora dan tnsnames.ora sudah diganti dengan IP, tetapi masih belum bisa.

    • setijoagus February 6, 2009 at 5:56 am #

      coba konfigurasi ulang lewat netca, jangan lupa lsnrctl start

  4. Subekti February 6, 2009 at 7:04 am #

    listener.ora dan tnsnames.ora sudah berhasil diganti menggunakan IP (sebelumnya nama) lewat $netca.

    $lsnrctl start … masih menunjukan error yg sama.

    • setijoagus February 7, 2009 at 1:57 am #

      opo yo kok nggak bisa, coba aku cari tahu u/ sementara give up aku.
      kl bukan production machine alternative yg menjengkalkan “install ulang”

  5. Subekti February 7, 2009 at 3:45 am #

    yup benar pak, ini bukan production..
    status development doang…

    sejak awal, ‘tidak sengaja’ tancepin kabel cuma satu, itupun di eth1 pula dan tidak bonding (bridge kalo di ms-windows).

    ke depan, dengan experience ini akan lebih hati-hati kalo mau setup server. rabu depan, 11/2/2009, rencananya akan install ulang.

    meanwhile, this case will be still mystery…

  6. yocki February 24, 2009 at 2:51 am #

    mas,
    aku selalu menjalankan ini setiap kali menghidupkan server :

    SET ORACLE_SID=DB1
    SQLPLUS SYS/SYS as SYSDBA
    STARTUP;

    kenapa harus selalu begitu ya ? bgmn caranya membuat databasenya langsung online…

    trims

    • setijoagus February 24, 2009 at 5:53 am #

      O/S nya pakai apa kl pakai linux ikuti langkah – langkah yang telah saya buat.
      kl pakai windows lain lagi ceritanya :
      umumnya tinggal aktifkan service yang ada di windows. start > control panel > Administrative Tools > services
      cari yang berkaitan dengan oracle

  7. yocki February 24, 2009 at 2:52 am #

    nohon balasannya ya mas. maturnuwun

  8. yocki February 25, 2009 at 11:46 am #

    pakai Windows 2003 Server.
    Service di windows sudah diaktifkan, tapi databasenya tetep g mount. akhirnya td saya sudah nemu caranya yaitu dengan men-set registry AUTO_sid_RESTART ke “TRUE”. database langsung mount sendiri saat server di restart. Apakah ini cara benar ?

  9. setijo agus February 26, 2009 at 2:24 am #

    soal benar / salah, aku nggak bisa jawab, sebab yang agak “menjengkelkan” dengan windows salah satunya adalah “registry”, dimana tingkah dan polahnya cenderung “susah” dimengerti, sekedar saran mulailah coba linux atau bahkan solaris.

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: