Oracle DBA, How To, Error, Cause and Action

Showing posts with label listener. Show all posts
Showing posts with label listener. Show all posts

Explore Oracle 12c Services In RAC

To check the services via Oracle Listener

[oracle@ora12cn1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 21-NOV-2013 22:23:08
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date                21-NOV-2013 14:25:29
Uptime                    0 days 7 hr. 57 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/12.1.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora12cn1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.101)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.111)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=ora12cn1.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0/db_1/admin/ora12c/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "ora12c" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
Service "ora12cXDB" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
Service "quote" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
The command completed successfully

Make sure that the listener is started, if not started start the listener. To view detail services use services parameter

[oracle@ora12cn1 admin]$ lsnrctl services
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 21-NOV-2013 22:24:29
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "ora12c" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:3 refused:0 state:ready
         LOCAL SERVER
Service "ora12cXDB" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: ora12cn1, pid: 3844>
         (ADDRESS=(PROTOCOL=tcp)(HOST=ora12cn1.localdomain)(PORT=21683))
Service "quote" has 1 instance(s).
  Instance "ora12c_1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:3 refused:0 state:ready
         LOCAL SERVER
The command completed successfully



To list the services automatically created for each container.


SQL> SELECT name, con_id FROM v$services;
NAME               CON_ID
-------------------- ----------
quote                       3
ora12cXDB                    1
ora12c                      1
SYS$BACKGROUND                1
SYS$USERS                    1


Note: There we will never have PDB$SEED service because, we never can connect to the PDB SEED, in this example case I only have 1 PDB namely QUOTE.

SQL> col pdb_name form a20
SQL> select pdb_id, pdb_name from cdb_pdbs;
PDB_ID     PDB_NAME
---------- --------------------
2 PDB$SEED
       3 QUOTE

Linux Error: 98: Address already in use Listener

If you tried to start listener with srvctl command

$ srvctl start listener -n rac10gn2db1
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 04-JAN-2015 05:20:32
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Copyright (c) 1991, 2010, Oracle.  All rights reserved.
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Starting /u01/app/oracle/product/10.2.0/asm/bin/tnslsnr: please wait...
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:TNSLSNR for Linux: Version 10.2.0.5.0 - Production
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:System parameter file is /u01/app/oracle/product/10.2.0/asm/network/admin/listener.ora
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Log messages written to /u01/app/oracle/product/10.2.0/asm/network/log/listener_rac10gn2db1.log
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.68.1.24)(PORT=1521)))
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac10gn2db1)(PORT=1521)))
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:TNS-12542: TNS:address already in use
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr: TNS-12560: TNS:protocol adapter error
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:  TNS-00512: Address already in use
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:   Linux Error: 98: Address already in use
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Listener failed to start. See the error message(s) above...
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 04-JAN-2015 05:20:33
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Copyright (c) 1991, 2010, Oracle.  All rights reserved.
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac10gn2db1-vip)(PORT=1521)))
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:TNS-12541: TNS:no listener
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr: TNS-12560: TNS:protocol adapter error
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:  TNS-00511: No listener
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:   Linux Error: 111: Connection refused
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac10gn2db1)(PORT=1521)))
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:TNS-12541: TNS:no listener
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr: TNS-12560: TNS:protocol adapter error
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:  TNS-00511: No listener
rac10gn2db1:ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr:   Linux Error: 111: Connection refused
CRS-0215: Could not start resource 'ora.rac10gn2db1.LISTENER_RAC10GN2DB1.lsnr'.


If you start manually if will like following

$ lsnrctl start LISTENER_RAC10GN1DB2

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 04-JAN-2015 05:34:14

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

Starting /u01/app/oracle/product/10.2.0/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.5.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/db/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db/network/log/listener_rac10gn1db2.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.68.1.26)(PORT=1521)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac10gn1db2)(PORT=1521)))
TNS-12542: TNS:address already in use
 TNS-12560: TNS:protocol adapter error
  TNS-00512: Address already in use
   Linux Error: 98: Address already in use

Listener failed to start. See the error message(s) above...


The issue is because the listener.ora is using hostname instead of IP.

Change all the hostname with the real IP will solve the issue. This applicable for 10g, 11g and non Linux OS as well.

Configure Oracle LISTENER

In this post I would like to share how to create Oracle Listener with Oracle utility call Network Manager.

The configured file of the LISTENER is listener.ora and the default location is $ORACLE_HOME/network/admin

Before I start to demonstrate how to create listener fist I will rename my current listener.ora file so that I am able to create from scratch.


To open Network Manager, you need to login as oracle account and call netmgr

netmgr



Oracle Network Manager is Open.




Expand the Local and click on Listeners



Click Green Plus Sign to add new listener, if you notice that the Default Listener name is Listener is LISTENER, you may change it, however if you change it every time you use lsnrctl utility you need to set the the current listener setting by

SET SET_CURRENT listener name.

So to make this easy I just use default name which is LISTENER.



Now we are setting the Listening Locations, click the Add Address to setup your database hosting information.



This network address is the location where your database is, which is localhost, you may set the hostname to the hostname of the database or localhost (127.0.0.1) or the IP address of your database.
By default oracle listener is using TCP port 1521, for security purpose highly secured database will change the port to other than that, because I create this just for fun and education purpose I am using 1521.



Click on the pull down menu, and choose General Parameter.



Click the Logging & tracing, in this section, I want to disabled the logging of the listener.log. Listener.log is very important log file, if this is production system, I suggest you to keep the logging on. This logging information will able to capture all client connection to the database, we will know who connect to your database. Again my virtual server base on small budget environment with limited storage therefore I disabled this setting.



Click the Pull down menu again, looks like only 1 line, Oracle Network Manager not display properly the pull down menu, just click the line.



Now choose the Database Service



We need to Add database instance information into this listener, click Add Database



Set te global name and SID and oracle home correctly.



Save the changes, File-> Save Network Configuration



Now Exit from Network Manager, File-> Exit



If you list the $ORACLE_HOME/network/admin you will see the listener.ora file is created.



The information also can be change with text editor



lsnrctl utility is used to start and stop the listener, most common use is
- start
to start service
- stop
to stop service
- set current_listener
to change the current listener to your listener name by default is LISTENER
- reload
if you reconfigure the listener.ora file you need to issue reload so that the changes take effect.