What is the listener in oracle database

 The contents are of my own testing and deployments. Not guaranteed that these might work in your environment. Please test before usage.


 Summary: in this tutorial, you will learn what a listener is in the Oracle database, and How to start and stop the listener.


What is Listener?

  • When a client request comes, the listener first receives it and then establishes the connection between the client and the database.
  • Once the Client connect the database successfully the listener hand over the client's conception to the server process 
  • If the listener stops running, you can no longer connect to the Oracle Database. However, all the existing connections will not be affected.



How to find the listener directory?

[oracle@ltitest ~]$ cd $ORACLE_HOME/network/admin

[oracle@ltitest admin]$ pwd

/u01/app/oracle/product/12.1.0/dbhome_1/network/admin

[oracle@ltitest admin]$


How to start the listener?

[oracle@ltitest admin]$ . oraenv

ORACLE_SID = [ltitest1] ?

The Oracle base remains unchanged with value /u01/app/oracle

[oracle@ltitest admin]$ lsnrctl start


LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 28-FEB-2023 12:42:16


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


Starting /u01/app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr: please wait...


TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Log messages written to /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                28-FEB-2023 12:42:16

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Log File         /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))

The listener supports no services

The command completed successfully


How to stop the Listener?

[oracle@ltitest admin]$ . oraenv

ORACLE_SID = [ltitest1] ?

The Oracle base remains unchanged with value /u01/app/oracle

[oracle@ltitest admin]$ lsnrctl stop


LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 28-FEB-2023 12:42:07


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


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

The command completed successfully


How to Confirm the listener is Up and running at the OS level?

[oracle@ltitest admin]$ ps -ef |grep tns

root        30     2  0 12:25 ?        00:00:00 [netns]

oracle    4018     1  0 12:42 ?        00:00:00 /u01/app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr LISTENER -inherit

oracle    4080  3220  0 12:48 pts/0    00:00:00 grep --color=auto tns


Note: As per the above command The listener process is up and running..


Listener Control utility syntax:

How to stop and start the listener using the listener control utility?

[oracle@ltitest admin]$ lsnrctl

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 28-FEB-2023 12:51:42

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                28-FEB-2023 12:42:16
Uptime                    0 days 0 hr. 9 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> stop
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully

LSNRCTL> start
Starting /u01/app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                28-FEB-2023 12:51:55
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully

LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                28-FEB-2023 12:51:55
Uptime                    0 days 0 hr. 0 min. 10 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/ltitest/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ltitest.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL>



                                                        Thanks for your time!!






0 Comments

DELETE Statement in ORACLE DB— Step by Step Internal Flow with classroom example.

Imagine your Oracle database like a school, and you’re Teacher decides to remove a student (row) from the classroom(table). Let’s see how the journey works step by step: 1)Classroom = Oracle Table 2)Students = Rows (Records) 3)Class Teacher = Oracle Server Process 4)Attendance Register = Data Dictionary User fires DELETE statement: DELETE FROM students WHERE grade = 'D'; Internal Processing Steps: Client Process Sends DELETE Statement to Server Process The teacher receives a request to remove a student from the classroom. Syntax Check (Parsing) The teacher checks if the request is grammatically correct — proper command, keywords, and a semicolon. Semantic Check Teacher verifies if the classroom exists and whether the condition (like grade = 'D') makes sense. Object Resolution Teacher confirms that the ‘students’ classroom (table) exists in the school records (data dictionary). Optimization Decides the fastest way to find those students — by roll number, grade, or al...