Wednesday, February 26, 2014

TNSnames and LISTENER.ora


Oracle Networking – TNSnames , Listener.ora

        UNDERSTANDING NETWORK CONFIGURATION
Oracle Net is a software component that resides on the client and the Oracle database server Or Oracle DBA Machine. It is responsible for establishing and maintaining the connection between the client application and the server, as well as exchanging messages between them.
For the client application and a database to communicate, the client application must specify location details for the database it wants to connect to and the database must provide some sort of identification, or address.
        WHAT IS AN ORACLE DATABASE LISTENER?
On the database server side,an Oracle Database Listener is an Oracle Database Process which "listen" for for users (clients) connecting to the database. The listener process, either creates a dedicated server process for each user or to a shared server process that handles many users.
It is configured in a file named listener.ora, with a protocol address that identifies the database.
(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=my-server) (PORT=1521)))This example shows a TCP/IP protocol address that specifies the host machine of the listener and a port number.

Here is an example of $ORACLE_HOME/network/admin/listener.ora:

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\Oracle_10g)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = cata1)(PORT = 1521))
)
)
LISTENER2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = cata1)(PORT = 1522))
)
)
Here 2 listeners are configured for this server.
        CONFIGURE THE CLIENT
When a client configured with the same protocol address broadcasts a request for a connection, the listener on the server machine or Oracle DBAmachine brokers the request and forwards it to the Oracle database.
The client uses a CONNECT DESCRIPTOR to specify the database it wants to connect to. This connect descriptor contains-- a protocol address and --a database service name.
A database can have multiple services defined, so a specific one must be specified for the connection. In the case of the preconfigured database that you installed, there is only one service, the name of which defaults to the global database name.The following example shows a CONNECT DESCRIPTOR that enables client to connect to a database service called live.
SCOTT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = cata1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = live)
    )
  )


Connection Requests:-
Users initiate a connection request by providing a connect string. A CONNECT STRING includes a username and password, along with a connect identifier.
This connect identifier can be the connect descriptor itself, or a name that resolves to the connect descriptor. One of the most common connect identifiers is a net service name, a simple name for a service.
The following example shows a connect string that uses net service name live as the connect identifier
CONNECT sagar/verma@live



        SOME QUESTIONS:-
Q) If I configured many listeners on my server, how could I see which is used ?
Ans)Using LSNRCTL> show current listener command.
       Other useful commands:-
       lsnrctl status       lsnrctl start       lsnrctl stop

Q)How could I see if the listener is running ?

No comments: