Showing posts with label Oracle Listener. Show all posts
Showing posts with label Oracle Listener. Show all posts

Monday, April 27, 2009

LISTENER

Listener Commands:
The listener's involvement is summarized as:
The listener catches the request spawns or requests a database process/thread redirects or passes the connection to the process/thread, usually on a different port gets out of the way

change_password:
set an encrypted listener password
c:\oracle\product\ora102\bin> lsnrctl startLSNRCTL> change_password
Old password:
New password:
Reenter new password:
LSNRCTL> save_config

Quit the listener application:
c:\oracle\product\ora10\bin> lsnrctl
LSNRCTL> exit

View help information:
c:\oracle\product\ora10\bin> lsnrctl help
or
c:\oracle\product\ora10\bin> lsnrctl
LSNRCTL> help

kill on *NIX:
ps -efgrep tnslsnrawk '{ print $2; }'xargs kill -9

Reload:
Causes a reread the listener.ora file. Enables the addition or modification of statically configured services without stopping the listener.
In addition, the database services, instances, service handlers, and listening endpoints that were dynamically registered with the listener are unregistered and subsequently registered again.
LSNRCTL> reload

save_config:
Use the SAVE_CONFIG command to compare the current configuration state of the listener, including trace level, trace file, trace directory, and logging to the listener.ora file. Any changes are stored in listener.ora, preserving formatting, comments, and case as much as possible. Prior to modification of the listener.ora file, a backup of the file, called listener.bak, is created.
See change_password above

View the configured listener service:
LSNRCTL> services

set Parameter:
current_listener: set current_listener
LSNRCTL> set current_listener uwlistener

displaymode: set displaymode
LSNRCTL> set displaymode VERBOSE

inbound_connect_timeout: set inbound_connect_timeout
LSNRCTL> set inound_connect_timeout 0

log_directory: set log_directory
LSNRCTL> set log_directory c:\temp

log_file: set log_file
LSNRCTL> set log_file uwlistener.log

log_status: set log_status <>
LSNRCTL> set log_status ON

password: set password
LSNRCTL> set password Password:

rawmode:set rawmode
LSNRCTL> set rawmode OFF

save_config_on_stop: set save_config_on_stop
LSNRCTL> set save_config_on_stop ON

startup_waittime: set startup_waittime
LSNRCTL> set startup_waittime 0

trc_directory: set trc_directory
LSNRCTL> set trc_directory c:\temp

trc_file: set trc_level
LSNRCTL> set trc_file uwlistener.trc

trc_level: set trc_level
Value Description
0 - 1 off
2 - 3 err
4 - 5 user
6 - 14 admin
15 dev
16 - 99 support
LSNRCTL> set trc_level 0

View the current listener services:
c:\oracle\product\ora10\bin> lsnrctl services

show Parameter
current_listener: show current_listener
LSNRCTL> show current_listener

displaymode: show displaymode
LSNRCTL> show displaymode

inbound_connect_timeout:
LSNRCTL> show inbound_connect_timeout

log_directory: show log_directory
LSNRCTL> show log_directory

log_file: show log_file
LSNRCTL> show log_file

log_status: show log_status
ON if listener activity is logged
LSNRCTL> show log_status

rawmode: show rawmode
LSNRCTL> show rawmode

save_config_on_stop: show save_config_on_stop
LSNRCTL> show save_config_on_stop

snmp_visible: show snmp_visible
LSNRCTL> show snmp_visible

startup_waittime: show startup_waittime
LSNRCTL> show startup_waittimeDefault is 0

trc_directory: show trc_directory
LSNRCTL> show trc_directory

trc_file: show trc_fileDefault is listener.trc
LSNRCTL> show trc_file

trc_level: show trc_level
LSNRCTL> show trc_level

start the listener:
c:\oracle\product\ora10\bin> lsnrctl start

view the current listener status:
c:\oracle\product\ora10\bin> lsnrctl status

stop the listener:
c:\oracle\product\ora10\bin> lsnrctl stop

Show the currently installed listener version:
c:\oracle\product\ora10\bin> lsnrctl version

Listener Parameters:
Prevent remote modification of listener.ora using lsnrctl commands
ADMIN_RESTRICTIONS_[listener_name]= ADMIN_RESTRICTIONS_ORABASE=ON Listener.ora Samples

Typical Listener.ora file for standalone Oracle.
# listener.ora Network Configuration File:
# c:\oracle\product\ora10\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\ora10)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orabase)
(ORACLE_HOME = C:\oracle\product\ora10)
(SID_NAME = orabase)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = perrito)(PORT = 1521))
)
)
)

Queue Size:
Add the queuesize parameter in your listener.ora file in the address description. By default oracle is able to open only 16 simultaneous connections

The result should look like this:
(ADDRESS= (PROTOCOL = TCP)(HOST = your-hostname)(PORT = 1521) (QUEUESIZE = 30))

Trace Levels:
TRACE_LEVEL_ =
Value equivalents:
OFF (equivalent to 0) provides no tracing
USER (equivalent to 4) identify user error error conditions
ADMIN (equivalent to 6) identify installation-specific problems
SUPPORT (equivalent to 16) provides trace information for support

Trace file results are written to $ORACLE_HOME/network/trace.
TRACE_LEVEL_LISTENER = USER

Force the database to register, or reregister, with the listener:
ALTER SYSTEM REGISTER;

Tuesday, April 7, 2009

Remote Listener

Registering Information with a Remote Listener:
A remote listener is a listener residing on one computer that redirects connections to a database instance on another computer. Remote listeners are typically used in an Oracle Real Application Clusters (Oracle RAC) environment. You can configure registration to remote listeners, such as in the case of Oracle RAC, for dedicated server or shared server environments.

Registering Information with a Remote Listener in a Dedicated Server Environment:
In a dedicated server environment, you must enable the PMON background process to register with a remote listener. You achieve this goal by configuring the REMOTE_LISTENER parameter in the initialization parameter file. The syntax of the REMOTE_LISTENER initialization parameter is as follows:

REMOTE_LISTENER=listener_alias

listener_alias is resolved to the listener protocol addresses through a naming method such as a tnsnames.ora file on the database host.

To dynamically update the REMOTE_LISTENER initialization parameter, use the SQL statement ALTER SYSTEM SET. If you set the parameter to null with the statement that follows, then PMON de-registers information with the remote listener with which it had previously registered information, as in the following example:

ALTER SYSTEM SET REMOTE_LISTENER=''

To register information with a remote listener in a dedicated server environment:
On the host where the remote listener resides, configure the listener.ora file with the protocol addresses of the remote listener.
For example, assume that a remote listener listens on port 1521 on host sales2-server.
On the database to which you want requests to be redirected, set the REMOTE_LISTENER parameter in the database initialization parameter file to the alias of the remote listener.

For example, suppose that a database resides on host sales1-server. To redirect requests to the database on sales1-server, you can set the REMOTE_LISTENER parameter in the initialization file for the database on host sales1-server as follows:

REMOTE_LISTENER=listener_sales2

Resolve the listener name alias for the REMOTE_LISTENER setting through a tnsnames.ora file on the database host.

For example, in the tnsnames.ora on sales1-server, you can resolve the remote listener alias listener_sales2 as follows:

listener_sales2=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521))
)

Registering Information with a Remote Listener in a Shared Server Environment:
In a shared server environment, you can use the same registration technique as for a dedicated server environment. Alternatively, you can set the LISTENER attribute of the DISPATCHERS parameter in the initialization parameter file to register the dispatchers with any listener.

The LISTENER attribute overrides the REMOTE_LISTENER parameter. Because the REMOTE_LISTENER parameter and the LISTENER attribute enable PMON to register dispatcher information with the listener, you need not specify both the parameter and the attribute if the listener values are the same.

The syntax of the LISTENER attribute is as follows:
DISPATCHERS="(PROTOCOL=tcp)(LISTENER=listener_alias)"

To register information with a remote listener in a shared server environment:
On the host where the remote listener resides, configure the listener.ora file with the protocol addresses of the remote listener.

For example, assume that a remote listener listens on port 1521 on host sales2-server.
On the database to which you want requests to be redirected, configure the LISTENER attribute of the DISPATCHERS parameter.

For example, suppose that a database resides on host sales1-server. To redirect requests to the database on sales1-server, set the DISPATCHER parameter in the initialization file for the database on host sales1-server as follows:
DISPATCHERS="(PROTOCOL=tcp)(LISTENER=listeners_sales2)"

Resolve the listener name alias for the LISTENER attribute through a tnsnames.ora file on the database host.

For example, in the tnsnames.ora on sales1-server, you can resolve the remote listener alias listener_sales2 as follows:
listeners_sales2=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521))
)

Oracle Listener

Oracle Default Listener:
Prior to Oracle 8i, a listener was statically configured (listener.ora) to service a given set of SIDs. From 8i, PMON dynamically registers a database service with the listener.Further, if the listener is running on the default TCP port of 1521, then there is no need to configure a listener.ora at all.

USING A DEFAULT LISTENER:
A listener.ora file is not required in order to use the default listener. The listener is started in the conventional manner:
$lsnrctl start
This listener will listen on two addresses:
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)) (ADDRESS=(PROTOCOL=tcp)(PORT=1521))

In order to change parameters to non default values (such as enabling listener tracing), a listener.ora should be created with the relevant parameters specified. The listener then needs to be restarted.

By default, PMON will register the database service with the listener on port 1521.

USING A NON DEFAULT LISTENER:
When a non-default listener is used, then a listener.ora must be configured with the relevant listener address. For example,
LISTENER = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP) (HOST=uksn115) (PORT=2500)) )

This would start a listener on port 2500.

In order for PMON to be able to register the database service(s) with this listener, the init.ora parameter LOCAL_LISTENER must be set.

eg, LOCAL_LISTENER=listener_A

PMON will attempt to resolve LOCAL_LISTENER using some naming method. For example, this may be resolved in tnsnames.ora, as follows:

listener_A = (DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=uksn155)(PORT=2500)) )

PMON will search for tnsnames.ora in the following order:

$HOME/.tnsnames.ora $TNS_ADMIN/tnsnames.ora /var/opt/oracle/tnsnames.ora or /etc/tnsnames.ora (depending on platform) $ORACLE_HOME/network/admin/tnsnames.ora

If a tnsnames.ora cannot be found or if LOCAL_LISTENER cannot be resolved, the alert.log will show:

PMON started with pid=2
Syntax error in listener string

If LOCAL_LISTENER can be resolved, but there is a syntax error in the tnsnames.ora
specification, the alert log will show:

PMON started with pid=2
Syntax error in listener string (DESCRIPTION =)

The instance will start regardless of PMON errors during registration, unless MTS is enabled. If
MTS enabled, then both of the above error scenarios will give:

ORA-00101: invalid specification for system parameterMTS_DISPATCHERS

in addition to the relevant alert log message. The instance will not start.

Note that if 'NAMES.DEFAULT_DOMAIN' is set in sqlnet.ora, then the tnsnames.ora entry should be of the form NAME.DOMAIN. The domain will be appended to LOCAL_LISTENER if not already specified.
eg,
init.ora: LOCAL_LISTENER=listener_A (or listener_A.uk.oracle.com)
sqlnet.ora: NAMES.DEFAULT_DOMAIN=uk.oracle.com
tnsnames.ora: listener_A.uk.oracle.com=(...)

The search order for the 'system' sqlnet.ora is:

$TNS_ADMIN/sqlnet.ora
$ORACLE_HOME/network/admin/sqlnet.ora

Additionally, the 'local' sqlnet.ora is always read from:
$HOME/.sqlnet.ora

If this file exists, then any parameters defined here will override the ones in the 'system' sqlnet.ora.

Note, /etc or /var/opt/oracle is not searched for the 'system' sqlnet.ora unless TNS_ADMIN happens to be set to this directory.


SPECIFYING MULTIPLE LOCAL_LISTENERS:
Multiple LOCAL_LISTENERs can be specified in one of two ways in the init.ora:
local_listener=listener_A, listener_B
local_listener=listener_A
local_listener=listener_B
In both cases, v$parameter will show: local_listener=listener_A, listener_B
PMON will register ONLY with the listener that appears first in the v$parameter value for local_listener (ie, listener_A in the above).
The correct method is to specify one local_listener in the init.ora, and to specify multiple listener ADDRESSes in the connect descriptor.

For example,
init.ora:
local_listener=all_listeners
tnsnames.ora:
all_listeners.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
)

In non-MTS mode, all listeners must be on the same host as the instance (unless pre-spawned servers are used on the remote host). However, even in dedicated mode and no pre-spawned servers, PMON still registers with listeners on another node. But this does not make any sense, as the remote listener will not be able to fork/exec oracle.

Registration in an MTS Environment:
Service registration is more flexible if the instance is running in MTS mode. For example,
PMON can register services with listeners on more than one node the dispatchers can register with a different listener than dedicated services different dispatchers can register with different listeners
This is illustrated by way of the following examples.
Example 1

init.ora on host1:
local_listener=all_listeners
mts_dispatchers="(protocol=tcp)"

tnsnames.ora on host1:
all_listeners.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
)

output of 'lsnrctl services':

host1, listener on port 2500:
-----------------------------
Services Summary...
V816 has 2 service handler(s)
DEDICATED SERVER established:0 refused:0
LOCAL SERVER
DISPATCHER established:0 refused:0 current:0 max:1022 state:ready
D000
(ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59155))

host1, listener on port 2600:
-----------------------------
Services Summary...
V816 has 2 service handler(s)
DEDICATED SERVER established:0 refused:0
LOCAL SERVER
DISPATCHER established:0 refused:0 current:0 max:1022 state:ready
D000
(ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59155))
In this case, the dispatcher has registered with the listeners specified by the local_listener parameter.

Example 2
init.ora on host1:

mts_dispatchers="(protocol=tcp)(listener=listener_host2.uk.oracle.com)" local_listener=listener_host1.uk.oracle.com

tnsnames.ora on host1:
listener_host2.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=2500))
)

listener_host1.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
)

output of 'lsnrctl services':
host1:
Services Summary...
Nov10 has 1 service handler(s)
DEDICATED SERVER established:0 refused:0
LOCAL SERVER

host2:
Services Summary...
V816 has 1 service handler(s)
DISPATCHER established:0 refused:0 current:0 max:1022state:ready
D000
(ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59165))

In this case, the dispatcher explicitly registers with a different
listener than the one for the dedicated service.

Example 3
init.ora on host1:
mts_dispatchers="(protocol=tcp)(listener=listenerA.uk.oracle.com)" local_listener=all_listeners

tnsnames.ora on host1:
all_listeners.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
)

listenerA.uk.oracle.com=
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
)

output of 'lsnrctl services':

host1, listener on port 2500:
Services Summary...
V816 has 1 service handler(s)
DEDICATED SERVER established:0 refused:0
LOCAL SERVER

host1, listener on port 2600:
Services Summary...
V816 has 2 service handler(s)
DEDICATED SERVER established:0 refused:0
LOCAL SERVER
DISPATCHER established:0 refused:0 current:0 max:1022 state:ready
D000
(ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59160))

This illustrates that the 'listener=' part of mts_dispatchers overrides local_listener when registering dispatchers.

Static Info Overwrite:
If a listener.ora is used, and a SID_DESC entry exists for an instance, the data within the SID_DESC section is referred to as 'static information' for that instance.

In 8.1.6, all static information in the listener.ora is overwritten when the instance is dynamically registered with the listener.

Therefore, any environment variables set within the listener.ora will not be visible unless the variable is set in the environment used to start the instance (and thus inherited by PMON).

This behaviour is different from 8.1.5. In 8.1.5, the existance of a SID_DESC section results in the listener NOT registering PMON's and therefore the instances' environment (note that the instance is still registered).

Therefore, in 8.1.5, any environment variables set in the listener.ora would be retained even after dynamic registration.

If there is no SID_DESC section, then the listener WILL register PMON's environment (ie, behaves as 8.1.6).

Friday, April 3, 2009

Managing Listeners

Managing Listeners with lsnrctl:
$ lsnrctl

LSNRCTL for Solaris: Version 9.2.0.1.0 - Production on 30-JAN-2003 11:54:13

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

Welcome to LSNRCTL, type "help" for information.
LSNRCTL> help

The following operations are available
An asterisk (*) denotes a modifier or extended command:

start stop status
services version reload
save_config trace spawn
dbsnmp_start dbsnmp_stop dbsnmp_status
change_password quit exit
set* show*

The following commands are used to manage the listener:
· start – Starts the listener with the name specified, otherwise LISTENER will be used. For Windows systems, the listener can also be started from the Control Panel.
· stop – Stops the listener. For Windows systems, the listener can also be stopped from the Control Panel.
· status – Provides status information about the listener, including start date, uptime, and trace level.
· services – Displays each service available, along with the connection history.
· version – Displays the version information of the listener.
· reload – Forces a read of the configuration file in order for new settings to take effect without stopping and starting the listener.
· save_config – Creates a backup of the existing listener.ora file and saves changes to the current version.
· trace – Sets the trace level to one of the following – OFF, USER, ADMIN, or SUPPORT.
· spawn – Spawns a program that runs with an alias in the listener.ora file.
· dbsnmp_start – Starts the DBSNMP subagent.
· dbsnmp_stop – Stops the DBSNMP subagent.
· dbsnmp_status – Displays the status of the DBSNMP subagent.
· change_password – Sets a new password for the listener.
· quit and exit – Exits the utility.
· set – Changes the value of any parameter. Everything that can be shown can be set.
. show – Displays current parameter settings.