Saturday, January 12, 2008

MANAGING ORACLE LISTENER


Characteristics of the Listener Process

The listener is a process running on a node that listens for incoming connections on behalf of a database or a number of databases. The following are the characteristics of a listener:

• A listener process can listen for more than one database

• Multiple listeners can listen on behalf of a single database to perform load balancing

• The listener can listen for multiple protocols

• The default name of the listener in Oracle Net is LISTENER

• The name of the listener must be unique per listener.ora file

Note: Oracle9i databases requires a release 9.0 listener. Previous versions of the listener are not supported. However, it is possible to use a release 9.0 listener with previous versions of the Oracle database.


The Listener Responses

When a connection request is made by a client to a server, the listener performs one of the following:

• Spawns a server process and passes the connection to it

• Hands off the connection to a dispatcher or server process in an Oracle Shared Server configuration

• Redirects the connection to a dispatcher or server process


Configuring the Listener


The listener can be configured in two ways:


Static Service Registration

In order for a listener to accept client requests from an Oracle8 or earlier release, the

listener.ora file must be configured. The static configuration is also required for Oracle

Enterprise Manager (OEM) and other services such as external procedures and Heterogeneous Services.


Dynamic Service Registration

An Oracle9i instance uses service registration to inform the listener about its database services. Service registration relies on the PMON process to register instance information with the listener. PMON also informs the listener about the current state and load of the instance and Shared Server dispatchers.


If Oracl9i JVM is installed, HTTP and IIOP listening endpoints can be registered dynamically with the listener.


Benefits of Dynamic Service Registration

• The listener.ora file does not require the SID_LIST_LISTENER_NAME parameter that specifies information on the databases served by the listener. This parameter is still required if the management tool you are using requires it.

• Connect-time failover is enabled.

• Connection load balancing is enabled for shared servers.



listener.ora File Contents


1. LISTENER =

2. (ADDRESS_LIST =

3. (ADDRESS= (PROTOCOL= TCP)(Host= stc1)(Port= 1521))

)

4. SID_LIST_LISTENER =

5. (SID_LIST =

6. (SID_DESC =

7. (ORACLE_HOME= /home/oracle)

8. (GLOBAL_DBNAME = ORCL.us.oracle.com)

9. (SID_NAME = ORCL)

)

10. ...sample additional SID description ...

)


The default listener.ora file contains the following parameters:

1. The name of the listener. The default name is LISTENER.

2. The ADDRESS_LIST parameter contains a block of addresses at which the listener

listens for incoming connections. Each of the addresses defined in this block represents

a different way by which a listener receives a connection.

3. The TCP address identifies incoming TCP connections from clients on the network

attempting to connect to port 1521. The clients use the port defined in their

tnsnames.ora file to connect to this listener. Based on the SID_LIST defined for this

listener, the listener specifies the database to which to connect. Please note that is

possible to configure multiple listeners here as long as they have unique names and

unique ports on the node where they are configured. Each listener configured will have

its own SID_LIST but a single database can be serviced by multiple listeners.

4. A listener can listen for more than one database on a machine. The

SID_LIST_LISTENER_NAME block or parameter is where these SIDs are defined.

5. The SID_LIST parameter is defined if more than one SID is defined.

6. The SID_DESC parameter must exist for each defined SID.

7. The ORACLE_HOME is where the home directory of the database is defined. This

enables the listener to identify the location of a database executable file.

8. The parameter GLOBAL_DBNAME identifies the global database name of the database, a name comprised of the database name and database domain. The global database name is of the form database_name.database_domain. Consider, for example, orcl.us.acme.com where the database name portion, orcl, is a simple name you wish to call your database. The database domain portion, us.oracle.com, specifies the database domain in which the database is located, making the global database name unique You can obtain the GLOBAL_DBNAME value from the SERVICE_NAMES parameter in the initialization parameter file. This parameter must be embedded under SID_DESC and should match the value of the SERVICE_NAMES parameter.

9. The SID_NAME parameter defines the name of the SID on behalf of which the listener accepts connections.

10. By default, an example SID is defined here.



LISTENER.ORA Parameters

Parameter Description

CONNECT_TIMEOUT_listener_name Sets the number of seconds that the listener waits for the server process to get a valid database query after the session has started.

LISTENER_address Defines the listening addresses for the listener.

LOG_DIRECTORY_listener_name Controls the directory in which the log file

is written.

LOG_FILE_listener_name Specifies the filename to which the log information is written.

LOGGING_listener_name By default, logging is always on unless you provide this parameter and turn logging off.

PASSWORDS_listener_name Sets a nonencrypted password for authentication to the Listener Control utility (LSNRCTL).

SAVE_CONFIG_ON_STOP_listener_name Any changes made by the LSNRCTL SET command are made permanent if the if the parameter is set to TRUE.

SERVICE_LIST_listener_name Defines the service served by the listener. This is the same as the SID_LIST, made more generic for nondatabase servers.

SID_LIST_listener_name Defines the SID of the databases served by the listener.

STARTUP_WAIT_TIME_listener_name Sets the number of seconds that the listener sleeps before responding to the first LSNRCTL STATUS command. This assures that a listener with a slow protocol has time to start up before responding to a

status request.

TRACE_DIRECTORY_listener_name Controls the directory in which the trace

file is written.

TRACE_FILE_listener_name Sets the name of the trace file.

TRACE_LEVEL_listener_name Turns tracing off or to a specified level.


Creating an Additional Listener

By default a listener called LISTENER is created after the installation. If you need to create an additional listener, the following steps describe the procedure:

1. Start up Oracle Net Manager

2. Click the Listeners icon.

3. Select Create from the Edit menu.

4. Enter a listener name in the Listener Name field on the dialog box that appears.

5. Select Listening Locations from the drop-down list within Oracle Net Manager for your listener.

6. Click the Add Address button.

7. Change or enter information in the Protocol, the Host, and Port fields as necessary.

8. Select Save Network Configuration from the File menu of Oracle Met Manager.


Configuring Database Services

1. Select Database Services from the drop-down list within Oracle Net for your listener.

2. Click the Add Database button.

3. Enter the global database name, the Oracle home directory, and the SID in the

appropriate fields.

4. Select Save Network Configuration from the File menu of Net Manager.


Configuring Listener Logging and Tracing

1. Select General Parameters from the pull-down menu within Net Manager for your

listener.

2. Click the Logging & Tracing tab.

3. Enable logging by selecting the Logging Enabled option button.

4. Enter the path and filename for a log file.

5. Select Save Network Configuration from the File menu of Oracle Net.

6. Repeat above steps for tracing (if needed). Be aware that logging and especially tracing

can use large amounts of disk space and should be monitored. Tracing should only be

used if needed.


Configuring Service Registration

The following init.ora parameters must be configured for service registration to work:

SERVICE_NAMES for the database service name

INSTANCE_NAME for the instance name

Examples:

SERVICE_NAMES=sales.us.oracle.com

INSTANCE_NAME=salesdb


How to configure PMON for Dynamic Service Registration:

By default, PMON registers with a local listener on the server with the following settings:


Listener name LISTENER

Port 1521

Protocols TCP/IP

SID name Default instance

Host name Default host name


Using a Non-default Listener

You can force PMON to register with a local listener on the server that does not use TCP/IP or use port 1521 by configuring the LOCAL_LISTENER parameter in the init.ora file as follows:

LOCAL_LISTENER=listener_alias

listener_alias must be resolved to the listener protocol address through a naming

method such as tnsnames.ora.

An example entry in the tnsnames.ora follows:

listener_name=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1421)))


Listener Control Utility (LSNRCTL)

Commands from the Listener Control utility can be

issued from the command-line or from the LSNRCTL

prompt.

$ lsnrctl <command name>

LSNRCTL> <command name>

Control a non-default listener

LSNRCTL> set current_listener listener02

When the lsnrctl command is issued, the command will work against the default listener “listener” unless the SET LISTENER command is executed. Another way to control different listeners is to use the listener name as a command modifier:


$ lsnrctl start listener02


Starting the Listener

LSNRCTL> START [listener_name]

or

$ lsnrctl start [listener_name]


Stopping the Listener

LSNRCTL> STOP [listener_name]

or

$ lsnrctl stop [listener_name]


Command Description

CHANGE_PASSWORD Dynamically changes the encrypted password of a listener.

EXIT Quits the LSNRCTL utility.

HELP Provides the list of all available LSNRCTL commands.

QUIT Provides the functionality of the EXIT command.

RELOAD Shuts down everything except listener addresses and rereads the listener.ora file. You use this command to add or change services without actually stopping the listener.

SAVE_CONFIG Creates a backup of your listener configuration file (called listener.bak) and updates the listener.ora file itself to reflect any changes

SERVICES Provides detailed information about the services the listener listens for.

SET parameter This command sets a listener parameter.

SHOW parameter This command lists the value of a listener parameter.


LSNRCTL SET and SHOW Modifiers

The SET modifier is used to change listener parameters in the Listener Control utility environment.

The SHOW modifier is used to display the values of the parameters set for the listener.

LSNRCTL> SET trc_level ADMIN

LSNRCTL> SHOW connect_timeout


Tuning Oracle Listener

The Listener is a process residing on a database server or other machine that "listens" for database connection requests. When a request is received the Listener hands off or passes on the connection to a database server process. Following is a very simple Listener configuration file. This file is called listener.ora by default and is placed in the $ORACLE_HOME/network/admin directory.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1521))

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = <SID>.<xyz.com>)

(SID_NAME = <SID>)

(ORACLE_HOME = /oracle/ora92)

)

)

What can be done to tune or at least improve the Listener under certain circumstances?

  • Listener Queue Size. Allows a larger number of Listener requests to be serviced by allowing them to wait in a queue.

  • Listener Logging and Tracing. Logging is defaulted on and tracing is defaulted off.

  • Multiple Listeners and Load Balancing. Randomized load balancing can be created between multiple Listeners, pointing at the same database.

16.1.1 Listener Queue Size

Very large quantities of network requests and traffic to the Listener can cause the Listener to use a queue in order to allow the Listener to keep up with requests. If there are too many requests then waiting requests to the Listener will be queued. The default length of the Listener queue is operating-system-specific and can be increased by setting the QUEUESIZE parameter in the Listener configuration file.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS =

(PROTOCOL = TCP)

(HOST = <hostname>)

(PORT = 1521)

(QUEUESIZE = 50)

)

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = <SID>.<xyz.com>)

(SID_NAME = <SID>)

(ORACLE_HOME = /oracle/ora92)

)

)

16.1.2 Switching Off Listener Logging and Tracing

By default a file called $ORACLE_HOME/network/log/listener.log file is created and constantly appended to. Tracing can also be switched on but is off by default. Logging and tracing of the Listener process can be switched off by setting the appropriate configuration parameters in the listener.ora file. Switch off Listener logging and especially tracing if this is switched on. Log and trace files can become extremely large and will affect performance. Unless really necessary do not log or trace the Listener process.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1521))

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = <SID>.<xyz.com>)

(SID_NAME = <SID>)

(ORACLE_HOME = /oracle/ora92)

)

)

LOGGING_LISTENER = OFF

TRACE_LEVEL_LISTENER = OFF

16.1.3 Multiple Listeners and Load Balancing

Load balancing can help performance by providing multiple Listener connection points to a database server. If one Listener is busy another Listener process can be deferred to, thus reducing load on the first Listener. So let's add a Listener. The listener.ora configuration might now look something like that shown below. Note that the Listener called LISTENER2 uses a different port number to the Listener called LISTENER. Both of the two Listeners LISTENER and LISTENER2 allow connections to the same database.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1521))

)

)

LISTENER2 =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1522))

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = <SID>.<xyz.com>)

(SID_NAME = <SID>)

(ORACLE_HOME = /oracle/ora92)

)

)

SID_LIST_LISTENER2 =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = <SID>.<xyz.com>)

(SID_NAME = <SID>)

(ORACLE_HOME = /oracle/ora92)

)

)

How do we implement load balancing between multiple Listener processes?

The configuration file shown opposite is the client configuration file called the Transparent Network Substrate configuration file. This file is placed in the $ORACLE_HOME/network/ admin directory and is called tnsnames.ora. The tnsnames.ora file, which is a local naming client connection configuration file, can be placed on both Oracle server and client installations, specifying how a client process such as SQL*Plus can communicate with a Listener process. Note how there are two connection strings with ports 1521 and 1522, matching the different Listener address in the previously shown listener.ora file.

<TNSname> =

(DESCRIPTION =

(ADDRESS_LIST =

(LOAD_BALANCE = YES)

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)

(PORT = 1522))

)

(CONNECT_DATA = (SID = <SID>) (ORACLE_HOME =

/oracle/ora81))

)


Monday, January 7, 2008

CLIENT SIDE CONFIGURATION


Oracle Uses the following method to connect client to the Oracle Server

  1. Host Naming method

  2. Local naming method

  3. Net service names


Q. How do you configure Oracle Networking without configuring the TNSNAMES.ora file ?

Ans. We can configure the Client/Server connection in Oracle without configuring the TNSNAMES.ora file by using the Host naming method.



1. Host Naming

Clients can connect to a server using a host name if:

You are connecting to an Oracle database service using Oracle Net Services Client software

Your client and server are connecting over a TCP/IP protocol

Host names are resolved through an IP address translation mechanism such as DNS or a local

/etc/hosts file


Step 1

Configuring client side for Host naming

Make the following changes in the SQLNET.ora file


TRACE_LEVEL_CLIENT = OFF

sqlnet.authentication_services = (NTS)

names.directory_path = (HOSTNAME)


Step 2

Configuring Server side for Host naming

If you are using the host naming method, you must have TCP/IP installed on your server as well as your client. You also need to install Oracle Net Services and the TCP/IP protocol adaptor on the server side.


A listener using the default name listener must be started on port 1521 and if instance

registration is not implemented, the listener.ora file must include the line:

GLOBAL_DBNAME = host name



Make the following changes in the LISTENER.ora file

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = ica.us.oracle.com)

(ORACLE_HOME = /u03/ora9i/rel12)

(SID_NAME = TEST)


Step 3

Establishing the connection to SQL using Host Naming Method

If all of the requirements are met on the client and server side, you can issue the connection request from the client, and this connects you to the instance TEST:


sqlplus system/manager@stc-sun02.us.oracle.com


SQL*Plus: Release 9.0.0.0.0 - Beta on Tue Feb 24 3:11:07 2001

(c) Copyright 2000 Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.0.0.0.0 - Beta

SQL>


Q. What is Oracle Net Configuration Assistant and how do you start this in Linux/Unix Environment ?

Ans. Oracle Net Configuration Assistant or Oracle Net Manager is a tool to configure host naming, local naming listener configuration and directory services.

Because Oracle Net Configuration Assistant is implemented in Java and is packaged with the Java Runtime Environment, you can run it on any platform where Oracle Net Services is installed.


Starting Oracle Net Configuration Assistant

From a command prompt enter:

$ netca

Select the Naming Methods Configuration option button and click Next.



2. Local Naming Method

The local naming method requires net service names be stored in the tnsnames.ora file.


Advantages of local naming:

Provides a relatively straightforward method for resolving service name addresses.

Resolves service names across networks running different protocols.

Can easily be configured using a graphical configuration tool




Step 1.

Configure the Client Side SQLNET.ora file and make the entries as shown below

NAMES.DEFAULT_DOMAIN = us.oracle.com

NAMES.DIRECTORY_PATH = (LOCAL , HOSTNAME)


Step 2.

Configure the Client Side TNSNAMES.ora file and make the entries as shown below


MY_SERVICE.US.ORACLE.COM =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = stc-sun02.us.oracle.com)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = TEST.us.oracle.com)

)

)


Step 3.

Make the following changes in the LISTENER.ora file

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(ORACLE_HOME = /u03/ora9i/rel12)

(SID_NAME = TEST)



Step 4

$ sqlplus system/manager@MY_SERVICE


SQL*Plus: Release 9.0.0.0.0 - Beta on Tue Feb 27 10:11:00 2001

(c) Copyright 2000 Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.0.0.0.0 - Beta

JServer Release 9.0.0.0.0 - Beta


SQL>


TNSPING Utility

The service name can also be tested from the command line by using the tnsping

utility. For example:


$ tnsping U01


TNS Ping Utility for Solaris: Version 9 - Production on 10-MAY-2001

Used parameter files:

/u01/user01/NETWORK/ADMIN/sqlnet.ora

/u01/user01/NETWORK/ADMIN/tnsnames.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=stc-sun02)(PORT=1701))

OK (0 msec)


Common Oracle Networking Errors and their Troubleshooting Tips


Error # 1

ORA-12154: “TNS: could not resolve service name”

Cause Oracle Net Services cannot locate the connect descriptor specified in the tnsnames.ora configuration file.

Actions

1. Verify that a tnsnames.ora file exists and that it is accessible.

2. Verify that the tnsnames.ora file is in the location specified by the TNS_ADMIN environment variable.

3. In your tnsnames.ora file, verify that the service name specified in your connection string is mapped to a connect descriptor in the tnsnames.ora file. Also, verify that there are no syntax errors in the file.

4. Verify that there are no duplicate copies of the sqlnet.ora file.

5. If you are connecting from a login dialog box, verify that you are not placing an at symbol (@) before your connection service name.



Error # 2

ORA-12198: “TNS:could not find path to destination” and ORA-12203: “TNS:unable to connect to destination”

Cause The client cannot find the desired database.

Actions

1. Verify that you have correctly entered the service name of the database that you want to reach.

2. Verify that the service name ADDRESS parameters in the connect descriptor of your TNSNAMES.ORA file are correct.

3. Verify that your TNSNAMES.ORA file is stored in the directory defined in the

TNS_ADMIN environment variable.

4. Verify that the listener on the remote node has started and is running. If not, start the

listener by using the Listener Control utility.

5. If you are connecting from a login dialog box, verify that you are not placing an at

symbol (@) before your connection service name.


Error# 3

ORA-12541: TNS:no listener

Cause The listener on the remote node cannot be contacted.

Actions Verify that the listener on the remote node has been started. You can check its status with the STATUS command of the Listener Control utility and start it with the START command if necessary.