Vous êtes sur la page 1sur 7

Connectiivity Networking

Oracle Network Environment


Oracle uses its own protocol for network based connections coming from Oracle Clients. These
clients are applications sitting on some other machine in the network and trying to connect to the
Oracle Database Server. All the clients using Oracles proprietary method for network based
connections go through a Listener.
Part-1 : The Oracle Listener
A Listener program is a specially designed application which listens on a given IP Address and
on a given Port using some supported protocol for incoming connection requests from the client
application.
When a client wants to connect to the Oracle Instance (to establish a session), it first contacts the
Listener process. The Listener then facilitates the connection making process. The Listener
contacts the Instance (for this the listener must be aware of such instance) when there is a new
incoming connection request. The instance validates the login and gives back the Address of the
Server Process back to the Listener.
The Listener then forwards this address to the client. The client now onwards can directly talk
with the Server Process. For the duration of the established session the listener has no other role
to play.
The Listener normally runs on the same machine where your database instance is configured to
run. However there is a small possibility that a listener can be configured on a remote machine
other than the machine where your instance is running. The listener attributes are configured via
a file : $ORACLE_HOME/network/admin/listener.ora which in its most simplest form should
look like
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = slodam-vm.oraclexpert.com)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u002/app/oracle
A DEFAULT listener listens on the

same machine where the instance is running


uses TCP as the protocol
listens on the Port 1521
If a listener uses a different setting than the above configuration, it would be termed as a NONDEFAULT LISTENER.
A listener acts as a facilitator for the incoming clients connections. To be able to work as a
facilitator a listener must first know what all instances are running on this machine or some other
machine. A listener can be made aware of the existence of the instances using any of the
following methods.
1. Dynamic Service Registration
In this method, whenever a new instance starts on a given machine the PMON process of that
instance would check if there is a DEFAULT listener running on that machine. If it finds a
DEFAULT listener it registers the service to that listener. This is how the listener comes to
know about the existence of that instance on the current machine. No special configuration is
required.
This simplifies the task. PMON periodically updates the Listener about the current workload
(connections established) on the instance.
Instance DGSDEVL, status READY, has 1 handler(s) for this service When the instance is in
NOMOUNT state : status BLOCKED is reported by the listener.
2. Static Registration
In this method, a listener is made aware of the existence of the instance by adding the details of
that instance into the listeners configuration file using the SID_LIST section.
Instance DGSDEVL, status UNKNOWN, has 1 handler(s) for this service
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DGSDEVL)
(ORACLE_HOME = /u002/app/oracle/product/11.2.0/myHome)
(SID_NAME = DGSDEVL)
)
)
Note : To start a DEFAULT listener, you dont mandatorily need the listener.ora
configuration file.

Oracle provides a command line interface to start/stop a listener.


$ORACLE_HOME/bin/lsnrctl start [<LISTENER_NAME>]
$ORACLE_HOME/bin/lsnrctl stop [<LISTENER_NAME>]
$ORACLE_HOME/bin/lsnrctl status [<LISTENER_NAME>]
$ORACLE_HOME/bin/lsnrctl services [<LISTENER_NAME>]
$ORACLE_HOME/bin/lsnrctl reload [<LISTENER_NAME>]
[<LISTENER_NAME>] is to be provided only when the name of the listener is not
LISTENER.
The tnslsnr program gets started when you say : $ORACLE_HOME/bin/lsnrctl start
[<LISTENER_NAME>]
When you attempt to start a listener, the tnslsnr program reads the configuration of the listener
from listener.ora file and then accordingly starts the listener process.
You can invoke the lsnrctl command prompt LSNRCTL> and then execute the necessary
commands.
Frequently seen error messages are :
ORA-12541: TNS:no listener
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
ORA-12154: TNS:could not resolve the connect identifier specified.
Those sessions which are connected via a listener can be seen on the server using : ps -ef|grep
LOCAL=NO
Those sessions which are connected locally bypassing a listener can be seen on the server using :
ps -ef|grep LOCAL=YES
To create a listener configuration file you can use
netca Network Configuration Assistant (GUI Utility)
netmgr Network Manager (GUI Utility)
Any text editor
A listener would generate log files in 2 formats
Text Logfile =>
$ADR_BASE/diag/tnslsnr/<machinename>/<listenername>/trace/<listenername>.log
XML Logfile => $ADR_BASE/diag/tnslsnr/<machinename>/<listenername>/alert/log.xml
When a listener process is started on Unix platform, a socket file gets created under
/usr/tmp/.oracle folder.

Do NOT delete these socket files manually. If you remove the socket files created by the running
listener, the listener becomes useless.The only way forward is to kill the listener and restart it.
A listener can be made secured by assigning a PASSWORD to the listener. This allows only the
person knowing the password to start/stop the listener. But this method is now useless starting
from Oracle 10g where the Security Model is changed to : ON: Local OS Authentication. This
means whether or not a Listener has a password it is not prompted
for the user who is the owner of the listener (oracle user in Unix).
How Client Applications Connect To Oracle Database On Network?
A client must first establish a session with the database instance. For this, the client must specify
the following details
1. Username (like SCOTT)
2. Password (like tiger)
3. Connect String (like @TNS_ENTRY)
sqlplus scott/tiger@TNS_ENTRY
TNS_ENTRY is an entry defined in client-side tnsnames.ora file which is under
$ORACLE_HOME/network/admin. The client machine must have the Oracle Client Software
installed.
A TNS Entry can be defined using any of the following methods
netca Network Configuration Assistant (GUI Utility)
netmgr Network Manager (GUI Utility)
Any text editor
A typical TNS Entry would look like
MY_TNS_ENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = slodam-vm.oraclexpert.com)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = DGSDEVL)
)
)
MY_TNS_ENTRY ==> is called as Net Service Name

(DESCRIPTION ==> this section is called as CONNECT DESCRIPTOR


A client can be a local client which runs some application from the same ORACLE_HOME on
the database server or A client could be a remote client which runs some application from the
remote machine to connect to the database server.
All remote clients must connect via the LISTENER.
If a client is unable to connect to the database using a particular tns entry you should perform
tnsping test.tnsping is used to perform reachability test much similar to ping test at the OS level.
A client can use various NAMES RESOLUTION methods. A NAMES RESOLUTION
method tells a client which path to follow to resolve the location of the listener. The NAMES
RESOLUTION methods are Local Naming (aka tnsnames)
This is the most common method used by client applications to connect to the Oracle Database
Server.
In this method, the client machine MUST have Oracle Client software installed. When you
install the Oracle client software it configures that machine with all the necessary libraries
required for Oracle Net8 Communication. Oracle Net8 Communication is Oracles proprietory
method of establishing connections with Oracles database. In this method, the client machine
must be configured with TNS Entry. The TNS Entry is defined in
$ORACLE_HOME/network/admin/tnsnames.ora. Later, a client application (like SQL*Plus) can
connect by saying : sqlplus scott/tiger@TNS_Entry
All the clients connection in this case would go via the LISTENER.
Host Naming (HOSTNAME)
This method is rarely used in real life. In this method, the name of the database must be same as
the name of the server. This method only supports TCP protocol. This method is not suitable
when you have multiple databases running on the same server as all those databases cannot have
the same name as the name of the host. A client need not configure a TNS Entry and can
directly connect using sqlplus scott/tiger@HOSTNAME where HOSTNAME is the name of the
machine where the database with the same name is already running.
Easy Connect (EZCONNECT)
This method was introduced in Oracle 10g. In this method, while connecting you mention all the
required details of the CONNECT DESCRIPTOR which are otherwise mentioned in the TNS
Entry in case of Local Naming. This method only supports TCP protocol. A client can now
connect using : sqlplus scott/tiger@<hostname>:<ListenerPort>/<DBNAME> sqlplus
scott/tiger@slodam-vm:1522/DGSDEVL
So, a client machine need not have a TNS Entry defined in tnsnames.ora file.
Directory Naming (LDAP)
LDAP is a platform independent Light-Weight Directory Access Protocol. This protocol is
used to query/manipulate a DIRECTORY TREE.

A DIRECTORY TREE can be thought of an inverted tree where information is organized as :


root ===> branches ===> leaves
Eg: My Organization has 3 departments viz : ADMIN, MARKETING, FINANCE.
Each department is spread in 2 locations via : MUMBAI, PUNE Each department has mutliple
roles. And those roles are performed by various employees Now, to store the users login
information and address book structure we can use LDAP which would store Identity Data
LDAP is mostly used in cases : where data manipulation is less but data read is high.
There are multiple LDAP products such as : Microsoft Active Directory, Oracle Internet
Directory, Oracle Sun Directory Server, IBM Tivoli Directory Server, 389 Directory Server and
Apache Directory Server.
Irrespective of the vendor of the LDAP product all of them can be operated upon by using :
LDAP* commands In Directory Naming method, there should be a LDAP complaint Directory
Server which could have usernames, passwords and TNS Entries defined in the Central
Repository. Any client who wants to connect to the database server must have Oracle Client
Software installed and must know the details of the LDAP Directory Server. The LDAP server
details are mentioned in $ORACLE_HOME/network/admin/ldap.ora file.
The client can then connect to the database server by saying : sqlplus scott/tiger@TNS_Entry
.The only difference now is the TNS_Entry is not defined in tnsnames.ora but inside the LDAP
Server.
NIS Naming
Network Information Server (NIS) is a central repository for managing user information in
Unix environments.
This method can also be used by Oracle Client as one of the methods of Names Resolution.
Extremely a rare case.
The NAMES RESOLUTION methods configured for a given client are stored in
$ORACLE_HOME/network/admin/sqlnet.ora file NAMES.DIRECTORY_PATH=
(TNSNAMES, EZCONNECT, HOSTNAME, LDAP, NIS)
What is purpose of sqlnet.ora?
$ORACLE_HOME/network/admin/sqlnet.ora file is required both on the database server and on
client machines if you
want to enable encryption when the data is transferred between the server and the client
want to configure logging and tracing for all the network communication between the server
and the client.
want to define the details of the NIS Server Maps
want to provide Notices/Banners when a client connects to the server

want to use all the names resolutions methods


want to route the clients connecting via some firewall
want to use the Advanced Security Options such as : RADIUS and KERBEROS protocols.
Server : listener.ora, [sqlnet.ora], [tnsnames.ora]
Client : tnsnames.ora, [sqlnet.ora]
A Server must have tnsnames.ora if you want to create DBLinks.
A DB Link connects you to the remote schema in the remote database.
SQL> create public database link MYLINK connect to scott identified by tiger using THIRD;
SQL> select count(*) from emp@mylink;
Shared Server Configuration and TNS Entry:
You can either run your database server in : DEDICATED mode or in SHARED Server mode
Certain DBA activities cannot be done via SHARED Server mode.
sqlplus sys/welcome1@new as sysdba
SQL> shutdown immediate
ORA-00106: cannot startup/shutdown database when connected to a dispatcher.
In such cases, while connecting using a TNS Entry add SERVER = DEDICATED
NEW =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = slodam-vm.oraclexpert.com)(PORT = 1522))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DGSDEVL)
)
)
This allows the connection to use : DEDICATED connection although the database instance
itself is configured in SHARED Server mode as a default.

Vous aimerez peut-être aussi