Configuring Listener



Oracle 12c Installation

About listener

Listener is a process which is used for connecting oracle client and database server. Some important points on LISTENER.

  • A database can have more than one listener(but port will be different for each listener)

  • Already established connections will be working even if the listener is down after the connections.

  • In recent versions, Database will be registered automatically by PMON, else DBA will do it manaully.
STEPS TO CONFIGURE LISTENER

Type netca in linux, which will popup a GUI screen.

Listener NETCA

Choose listener configuration.

Listener NETCA

Choose Add to create a new listener.

Listener NETCA

Give the name for the LISTENER

Listener NETCA

Cick the Next button, which by defaut chooses TCP Protocol

Listener NETCA

Choose the port 1521 which is default port, else you can customise the port number.(Make sure the port is not used by other applications, to check , use linux command [ netstat -tunlp ])

Listener NETCA

Choose Yes, if you need to configure additional listeners.

Listener NETCA

Click Next ,Listener configuration is done.

Listener NETCA

Click Finish.

Listener NETCA

The above configuration will create a listener.ora file in $ORACLE_HOME/network/admin, with listener entry.

  [oracle@linux admin]$  cat listener.ora
  # listener.ora Network Configuration File: /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
  # Generated by Oracle configuration tools.

  LISTENER =
    (DESCRIPTION_LIST =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = linux.localdomain)(PORT = 1521))
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      )
    )
    

Oracle LISTENER Configuration using NETCA(Network Configuration Assistant)

[oracle@linux admin]$   lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 00:43:02

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                27-MAY-2020 00:42:27
Uptime                    0 days 0 hr. 0 min. 35 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/linux/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully


[oracle@linux admin]$   lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 00:43:19

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                27-MAY-2020 00:42:27
Uptime                    0 days 0 hr. 0 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/linux/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

We see no database is resigtered with the listener. So starting up the database.


[oracle@linux admin]$   sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 00:43:21 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> !ps -ef|grep pmon
oracle   21498 21467  0 00:43 pts/0    00:00:00 /bin/bash -c ps -ef|grep pmon
oracle   21500 21498  0 00:43 pts/0    00:00:00 grep pmon

SQL> startup
ORACLE instance started.

Total System Global Area  838860800 bytes
Fixed Size                  8626240 bytes
Variable Size             335548352 bytes
Database Buffers          490733568 bytes
Redo Buffers                3952640 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

After starting the database, the database is registered with the listener.


[oracle@linux admin]$   lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 00:43:59

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=linux.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                27-MAY-2020 00:42:27
Uptime                    0 days 0 hr. 1 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/linux/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "demo" has 1 instance(s).
 Instance "demo", status READY, has 1 handler(s) for this service...
The command completed successfully


[oracle@linux admin]$   netca

Oracle Net Services Configuration:
Default local naming configuration complete.
   Created net service name: demo
Oracle Net Services configuration successful. The exit code is 0

Now, configuring the tnsnames.ora to connect database, which will create tnsnames.ora files under $ORACLE_HOME/network/admin/



[oracle@linux admin]$   cat /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

DEMO =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = demo)
   )
 )


[oracle@linux admin]$  sqlplus scott/tiger@demo

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 00:46:16 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Wed May 27 2020 00:45:17 +05:30

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select global_name from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------
DEMO

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


[oracle@linux admin]$