Search This Blog

Wednesday, February 27, 2013

How To Start, Stop and Restart Oracle Listener


How To Start, Stop and Restart Oracle Listener

1. Display Oracle Listener Status

Before starting, stopping or restarting make sure to execute lsnrctl status command to check the oracle listener status as shown below. Apart from letting us know whether the listener is up or down, you can also find the following valuable information from the lsnrctl status command output.

Listner Start Date and Time.
Uptime of listner – How long the listener has been up and running.
Listener Parameter File – Location of the listener.ora file. Typically located under $ORACLE_HOME/network/admin
Listener Log File – Location of the listener log file. i.e log.xml

If the Oracle listener is not running, you’ll get the following message.


# lsnrctl status
LSNRCTL for HPUX: Version 9.2.0.7.0 - Production on 27-FEB-2013 05:37:54
Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   HPUX Error: 239: Connection refusedLSNRCTL for Linux: Version 11.1.0.6.0 - Production on 04-APR-2009 16:27:39
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(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=IPC)(KEY=EXTPROC)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory


If the Oracle listener is running, you’ll get the following message.

# lsnrctl status      
LSNRCTL for HPUX: Version 9.2.0.7.0 - Production on 27-FEB-2013 05:40:28
Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for HPUX: Version 9.2.0.7.0 - Production
Start Date                27-FEB-2013 05:40:20
Uptime                    0 days 0 hr. 0 min. 8 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /var/opt/oracle/listener.ora
Listener Log File         /opt/oracle/product/920_ee_64/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname.dc-dublin.de)(PORT=1521)))
The listener supports no services
The command completed successfully

2. Start Oracle Listener

If the Oracle listener is not running, start the listener as shown below. This will start all the listeners. If you want to start a specific listener, specify the listener name next to start. i.e lsnrctl start [listener-name]


#  lsnrctl start
LSNRCTL for HPUX: Version 9.2.0.7.0 - Production on 27-FEB-2013 05:40:20
Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.
Starting /opt/oracle/product/920_ee_64/bin/tnslsnr: please wait...
TNSLSNR for HPUX: Version 9.2.0.7.0 - Production
System parameter file is /var/opt/oracle/listener.ora
Log messages written to /opt/oracle/product/920_ee_64/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname.dc-dublin.de)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for HPUX: Version 9.2.0.7.0 - Production
Start Date                27-FEB-2013 05:40:20
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   /var/opt/oracle/listener.ora
Listener Log File         /opt/oracle/product/920_ee_64/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname.dc-dublin.de)(PORT=1521)))
The listener supports no services
The command completed successfully

3. Stop Oracle Listener

If the Oracle listener is running, stop the listener as shown below. This will stop all the listeners. If you want to stop a specific listener, specify the listener name next to stop. i.e lsnrctl stop [listener-name]


$ lsnrctl stop
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 04-APR-2009 16:27:37
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(PORT=1521)))
The command completed successfully

4. Restart Oracle Listener

To restart the listener use lsnrctl reload as shown below instead of lsnrctl stop and lsnrctl start. realod will read the listener.ora file for new setting without stop and start of the Oracle listener.

Oracle Database Startup and Shutdown Procedure


How To Startup Oracle Database

1. Login to the system with oracle username

Typical oracle installation will have oracle as username and dba as group. On Linux, do su to oracle as shown below.

$ su - oracle

2. Connect to oracle sysdba

Make sure ORACLE_SID and ORACLE_HOME are set properly as shown below.


$ env | grep ORA
ORACLE_SID=DEVDB
ORACLE_HOME=/u01/app/oracle/product/10.2.0

Example:
oracle@hostname:/opt/oracle # env|grep ORA
ORACLE_BASE=/opt/oracle
ORATAB=/var/opt/oracle/oratab
ORACLE_HOME=/opt/oracle/product/920_ee_64

You can connect using either “/ as sysdba” or an oracle account that has DBA privilege.

$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:28 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning and Data Mining options
SQL>

Example:
oracle@hostname:/opt/oracle # sqlplus '/ as sysdba'
SQL*Plus: Release 9.2.0.7.0 - Production on Wed Feb 27 05:26:06 2013
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Connected.
SQL> 

3. Start Oracle Database

The default SPFILE (server parameter file) is located under $ORACLE_HOME/dbs. Oracle will use this SPFILE during startup, if you don’t specify PFILE.

Oracle will look for the parameter file in the following order under $ORACLE_HOME/dbs. If any one of them exist, it will use that particular parameter file.

spfile$ORACLE_SID.ora
spfile.ora
init$ORACLE_SID.ora

Type “startup” at the SQL command prompt to startup the database as shown below.


SQL> startup
ORACLE instance started.
Total System Global Area  812529152 bytes
Fixed Size                  2264280 bytes
Variable Size             960781800 bytes
Database Buffers           54654432 bytes
Redo Buffers                3498640 bytes
Database mounted.
Database opened.
SQL>


If you want to startup Oracle with PFILE, pass it as a parameter as shown below.


How To Shutdown Oracle Database

Following three methods are available to shutdown the oracle database:

Normal Shutdown
Shutdown Immediate
Shutdown Abort

1. Normal Shutdown

During normal shutdown, before the oracle database is shut down, oracle will wait for all active users to disconnect their sessions. As the parameter name (normal) suggest, use this option to shutdown the database under normal conditions.

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

2. Shutdown Immediate

During immediate shutdown, before the oracle database is shut down, oracle will rollback active transaction and disconnect all active users. Use this option when there is a problem with your database and you don’t have enough time to request users to log-off.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

3. Shutdown Abort

During shutdown abort, before the oracle database is shutdown, all user sessions will be terminated immediately. Uncomitted transactions will not be rolled back. Use this option only during emergency situations when the “shutdown” and “shutdown immediate” doesn’t work.

$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:33 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to an idle instance.
SQL> shutdown abort
ORACLE instance shut down.
SQL>

Reducing the mirror of Logical Volume using PV Key of the disk



Replaced Disk was not coming in available state:

Following below mirror disk was in defective

/dev/dsk/c0t6d0

   PV Name                     /dev/dsk/c0t6d0
   PV Status                   unavailable              
   Total PE                    1023    
   Free PE                     0       
   Autoswitch                  On        

After Disk Replacement dd command was working fine, but still the disk was not coming in available state.

dd if=/dev/rdsk/c0t6d0 of=/dev/null bs=1024

root@hosttest1# dd if=/dev/rdsk/c0t6d0 of=/dev/null bs=1024
553+0 records in
553+0 records out


Forcefully Reducing the disk from vg00

# vgreduce -l /dev/vg00 /dev/dsk/c0t6d0

root@hosttest1# pvcreate -f /dev/rdsk/c0t6d0
Physical volume "/dev/rdsk/c0t6d0" has been successfully created.
root@hosttest1# vgextend /dev/vg00 /dev/dsk/c0t6d0
Volume group "/dev/vg00" has been successfully extended.


Reducing the mirror of  Logical Volume using PV Key of the disk

I see that c0t6d0 is in available state but probably it doesnt contain the full information about vg
you can run a lvdisplay -v -k lvolname to find the pvkey identify the PV key number of the failed disk c0t6d0 and then run a lvreduce with -k option to remove c0t6d0


root@hosttest1# lvdisplay -v /dev/vg00/lvol4|more
--- Logical volumes ---
LV Name                     /dev/vg00/lvol4
VG Name                     /dev/vg00
LV Permission               read/write   
LV Status                   available/stale           
Mirror copies               1            
Consistency Recovery        MWC                 
Schedule                    parallel     
LV Size (Mbytes)            12              
Current LE                  3         
Allocated PE                6           
Stripes                     0       
Stripe Size (Kbytes)        0                   
Bad block                   on           
Allocation                  strict                    
IO Timeout (Seconds)        default             

   --- Distribution of logical volume ---
   PV Name            LE on PV  PE on PV  
   /dev/dsk/c2t6d0    3         3         

   --- Logical extents ---
   LE    PV1                PE1   Status 1 PV2                PE2   Status 2 
   00000 /dev/dsk/c2t6d0    00494 current  ???                00494 stale    
   00001 /dev/dsk/c2t6d0    00495 current  ???                00495 stale    
   00002 /dev/dsk/c2t6d0    00496 current  ???                00496 stale    

Here the mirror PE status is showing stale, which was on failed disk c0t6d0

root@hosttest1# lvdisplay -v -k /dev/vg00/lvol4
--- Logical volumes ---
LV Name                     /dev/vg00/lvol4
VG Name                     /dev/vg00
LV Permission               read/write   
LV Status                   available/stale           
Mirror copies               1            
Consistency Recovery        MWC                 
Schedule                    parallel     
LV Size (Mbytes)            12              
Current LE                  3         
Allocated PE                6           
Stripes                     0       
Stripe Size (Kbytes)        0                   
Bad block                   on           
Allocation                  strict                    
IO Timeout (Seconds)        default             

   --- Distribution of logical volume ---
   PV Name            LE on PV  PE on PV  
   /dev/dsk/c2t6d0    3         3         

   --- Logical extents ---
   LE    PV1                PE1   Status 1 PV2                PE2   Status 2 
   00000      0             00494 current       3             00494 stale    
   00001      0             00495 current       3             00495 stale    
   00002      0             00496 current       3             00496 stale


So The PV Key of disk 
lvreduce -k -m 0 /dev/vg00/lvol4 3



root@hosttest1# lvreduce -k -m 0 /dev/vg00/lvol4 3
Logical volume "/dev/vg00/lvol4" has been successfully reduced.

root@hosttest1# lvdisplay -v /dev/vg00/lvol4|more
--- Logical volumes ---
LV Name                     /dev/vg00/lvol4
VG Name                     /dev/vg00
LV Permission               read/write   
LV Status                   available/syncd           
Mirror copies               0            
Consistency Recovery        MWC                 
Schedule                    parallel     
LV Size (Mbytes)            12              
Current LE                  3         
Allocated PE                3           
Stripes                     0       
Stripe Size (Kbytes)        0                   
Bad block                   on           
Allocation                  strict                    
IO Timeout (Seconds)        default             

   --- Distribution of logical volume ---
   PV Name            LE on PV  PE on PV  
   /dev/dsk/c2t6d0    3         3         

   --- Logical extents ---
   LE    PV1                PE1   Status 1 
   00000 /dev/dsk/c2t6d0    00494 current  
   00001 /dev/dsk/c2t6d0    00495 current  
   00002 /dev/dsk/c2t6d0    00496 current  


How to change the name of a logical volume

How to change the name of a logical volume

ibtest:/root#bdf /usr/sap/ZH1/EXT

Filesystem          kbytes    used   avail %used Mounted on
/dev/vgusrsapall/usrsapZH1
                   20971520   67432 20740784    0% /usr/sap/ZH1/EXT

Make the note of the device file

ibtest:/root#ll /dev/vgusrsapall/usrsapZH1
brw-r-----   1 root       sys         64 0x02000f Dec  6 19:31 /dev/vgusrsapall/usrsapZH1

ibtest:/#umount /usr/sap/ZH1/EXT

ibtest:/dev/vgusrsapall#mv rusrsapZH1 rusrsap
ibtest:/dev/vgusrsapall#mv usrsapZH1 usrsap

# mknod /dev/vgusrsapall/usrsap b 64 0x02000f

# mknod /dev/vgusrsapall/rusrsap c 64 0x02000f

#vi /etc/fstab {reflect the new logical volume }


# mount -a


#rmsf /dev/vgusrsapall/usrsapZH1

#rmsf /dev/vgusrsapall/rusrsapZH1

Or
Changing the name of logical volume "/dev/vg01/lvol1" to "/dev/vg01/data1" on volume group "vg01".

1.      Check the current volume group special device files.
# ll /dev/vg01/*
crw-r-----   1 root       sys         64 0x010000 Oct 11 10:37 /dev/vg01/group
brw-r-----   1 root       sys         64 0x010001 Oct 11 10:45 /dev/vg01/lvol1
crw-r-----   1 root       sys         64 0x010001 Oct 11 10:45 /dev/vg01/rlvol1

2.      Unmount the filesystem. You need to stop any active process on the logical volume.

# umount /dev/vg01/lvol1

3.      Disable the volume group.

# vgchange -a n /dev/vg01
Volume group "/dev/vg01" has been successfully changed.

4.      Rename the block and character device special files.

# mv /dev/vg01/lvol1 /dev/vg01/data1
 
# mv /dev/vg01/rlvol1 /dev/vg01/rdata1
 
5.      Enable the volume group

# vgchange -a y /dev/vg01
Activated volume group
Volume group "/dev/vg01" has been successfully changed.

Edit the corresponding entries in /etc/fstab to point to the new volume group paths.

Thank you for Reading,

For Reading other article, visit to “https://sites.google.com/site/unixwikis/