4.4. Configuring Oracle Net on the Server

Now that you understand the basic features that Oracle Net provides, you need to understand how to configure the major components of Oracle Net. You must configure Oracle Net on the server in order for client connections to be established. This section will focus on how to configure the network elements of the Oracle server. It will also describe the types of connection methods that Oracle Net supports. We will then discuss how to manage Oracle Net on the server and troubleshoot connections from the server if clients experience connection problems.

4.4.1. Understanding the Oracle Listener

The Oracle listener is the main server-side Oracle networking component that allows connections to be established between client computers and an Oracle database. You can think of the listener as a big ear that listens for connection requests to Oracle services.

The type of Oracle service being requested is part of the connection descriptor information supplied by the process requesting a connection, and the service name resolves to an Oracle database. The listener can listen for any number of databases configured on the server, and it is able to listen for requests being transported on a variety of protocols. A client connection can be initiated from the same machine that the listener resides on, or it may come from some remote location.

The listener is controlled by a centralized file called listener.ora. Though only one listener.ora file is configured per machine, there may be numerous listeners on a server, and this file contains all the configuration information for every listener configured on the server. If multiple listeners are configured on a single server, they are usually set up for failover purposes or to balance connection requests and minimize the burden of connections on a single listener.

Multiple listeners may also be used when you configure Oracle Real Application Clusters. In a Real Application Clusters environment, these listeners typically span multiple server nodes, and all the corresponding nodes connect to a single database. Later in this chapter, in the section "Additional Configurations When Using Multiple Listeners," we'll discuss other reasons to configure multiple listeners.

NOTE

The content and structure of the listener.ora file is discussed later in this chapter, in the section "Managing Oracle Listeners."

Every listener is a named process that runs on either a middle-tier server or the database server. The default name of the Oracle listener is LISTENER, and it is typically created when you install Oracle. If you configure multiple listeners, each has a unique name. The following is an example of the contents of the listener.ora file:

# listener.ora Network Configuration File:
     D:oracleora10gNETWORKADMINlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
     (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:oracleora10g)
      (PROGRAM = extproc)
    )
     (SID_DESC =
      (GLOBAL_DBNAME = ORCL.COM)

(ORACLE_HOME = d:oracleora10g)
      (SID_NAME = ORCL)
     )
  )

LISTENER =
  (DESCRIPTION_LIST =
     (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = mjworn.corp.testenv.net)(PORT = 1521))
     )
     (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
     )
  )

Now that you have a basic understanding of the Oracle Listener, let's explore the main function of the Listener, responding to client connection requests.

4.4.1.1. How Do Listeners Respond to Connection Requests?

A listener can respond to a client request for a connection in several ways. The response depends on several factors, such as how the server-side network components are configured and what type of connection the client is requesting. The listener then responds to the connection request in one of two ways.

The listener can spawn a new process and pass control of the client session to the process. In a dedicated server environment, every client connection is serviced by its own server-side process. Server-side processes are not shared among clients. Two types of dedicated connection methods are possible: direct and redirect. Each method results in a separate process that handles client processing, but the mechanics of the actual connection initiation process are different. For remote clients to use dedicated connections, the listener process must be running on the same physical server as the database or databases for which it is listening.

The listener can also pass control of a connection request to a dispatcher. This type of connection takes place in an Oracle Shared Server environment. There are also two types of connection methods when using Oracle Shared Server: direct and redirect.

Let's take a look at each of these connection method types.

NOTE

We'll discuss Oracle Shared Server in detail in Chapter 5.

4.4.1.1.1. Dedicated Connections: Direct Handoff Method

Direct handoff connections are possible when the client and database exist on the same server. For example, a direct handoff method is used when the client connection request originates from the same machine on which the listener and database are running.

NOTE

Another name for direct handoff connections is bequeath connections.

The following steps, which show the connection process for the bequeath connections, are illustrated in Figure 4.6:

  1. The client contacts the Oracle listener after resolving the service name.

  2. The listener starts a dedicated process, and the client connection inherits the dedicated server process network connect endpoint from the listener.

  3. The client now has an established connection to the dedicated server process.

4.4.1.1.2. Dedicated Connections: Redirect Method

Redirect connections occur in a dedicated server environment when the client exists on a machine that is separate from the listener and database server. The listener must inform the client of the address of the spawned process in order for the process to contact the newly created dedicated server process.

The following steps, which show the connection process for redirect connections in a dedicated server environment, are illustrated in Figure 4.7:

  1. The client contacts the Oracle listener after resolving the service name.

  2. The listener starts a dedicated process.

  3. The listener sends an acknowledgment back to the client with the address of the dedicated server connect endpoint on the database server to which the client will connect.

  4. The client establishes a connection to the dedicated server connect endpoint.

Figure 4.6. Dedicated connection: direct handoff method

Figure 4.7. Dedicated connections: redirect method

4.4.1.1.3. Oracle Shared Server: Direct Handoff Method

When you are using Oracle Shared Server, the client connection can also be established using a direct handoff method. This would be the case, for example, when the client request originates from the same machine as the listener and the database are running. Figure 4.8 outlines the connection steps when using Oracle Shared Server and the direct handoff method:

  1. The client contacts the Oracle listener after resolving the service name.

  2. The Oracle Listener passes the connection request to the least loaded dispatcher.

  3. The client now has an established connection to the dispatcher process.

Figure 4.8. Oracle Shared Server: direct handoff method

4.4.1.1.4. Oracle Shared Server: Redirect Method

The listener can also redirect the user to a server process or a dispatcher process when using Oracle Shared Server. This type of connection can occur when the operating system does not directly support direct handoff connections or the listener is not on the same physical machine as the Oracle server.

The following steps are illustrated in Figure 4.9:

  1. The client contacts the Oracle server after resolving the service name.

  2. The listener sends information back to the client, redirecting the client to the dispatcher port. The original network connection between the listener and the client is disconnected.

  3. The client then sends a connect signal to the server or dispatcher process to establish a network connection.

  4. The dispatcher or server process sends an acknowledgment back to the client.

  5. PMON (process monitor) sends information to the listener about the number of connections being serviced by the dispatchers. The listener uses this information to maintain consistent loads between the dispatchers.

4.4.2. Managing Oracle Listeners

You can configure the server-side listener files in a number of ways. As part of the initial Oracle installation process, the installer prompts you to create a default listener. If you choose this method, the installer uses the set of screens that are a part of the Oracle Net Configuration Assistant to do the initial listener configuration. Figure 4.10 shows an example of the opening screen for this assistant.

Figure 4.9. Oracle Shared Server: redirect connection method

Figure 4.10. Oracle Net Configuration Assistant opening screen

If you want to set up more than just basic configurations of Oracle network files, you will have to use the Oracle Net Manager, the web-based tool Oracle Enterprise Manager (EM), or the command-line facility lsnrctl. In the next few sections, you will learn how to use these tools to configure the server-side network files.

4.4.2.1. Managing Listeners with Oracle Net Manager

Oracle Net Manager is a tool you can use to create and manage most client- and server-side configuration files. The Oracle Net Manager has evolved from the Oracle7 tool, Network Manager, to the latest Oracle 10g version. Throughout this evolution, Oracle has continued to enhance the functionality and usability of the tool.

If you are using a Windows environment, you can start the Oracle Net Manager by choosing Start Programs Your Oracle 10g Programs choice Configuration and Migration Tools Oracle Net Manager. In a Unix environment, you can start it by running ./netmgr from your $ORACLE_HOME/bin directory.

Figure 4.11 shows an example of the Oracle Net Manager opening screen.

4.4.2.1.1. Configuring Listener Services Using the Oracle Net Manager

Oracle Net Manager provides an easy-to-use graphical interface for configuring most of the network files that you will be using. By using Oracle Net Manager, you can ensure that the files are created in a consistent format, which will reduce the potential for connection problems.

When you first start the Oracle Net Manager, the opening screen displays a tree structure with a top level called Oracle Net Configuration. If you click the plus (+) sign next to this icon, you will see the Local folder. The choices under the Local folder relate to different network configuration files. Here are the network file choices and what each configures:

IconFile Configured
Profilesqlnet.ora
Service NamingTnsnames.ora
ListenersListener.ora

Figure 4.11. The opening screen for Oracle Net Manager

4.4.2.1.2. Creating the Listener

Earlier, we said that, by default, Oracle creates a listener called LISTENER when it is initially installed. The default settings that Oracle uses for the listener.ora file are shown here:

Section of the FileSetting
Listener NameLISTENER
Port1521
ProtocolsTCP/IP and IPC
Host NameDefault Host Name
SID NameDefault Instance

You can use Oracle Net Manager to create a non-default listener or change the definition of existing listeners. The Oracle Net Manager has a wizard interface for creating most of the basic network elements, such as the listener.ora and tnsnames.ora files.

Follow these steps to create the listener:

  1. Click the plus (+) sign next to the Local icon.

  2. Click the Listeners folder.

  3. Click the plus sign icon or choose Edit Create to open the Choose Listener Name dialog box.



  4. The Oracle Net Manager defaults to LISTENER or to LISTENER1 if the default listener is already created. Click OK if this is correct, or enter a new name and then click OK to open the Listening Locations screen, as shown in Figure 4.12.

  5. To configure the listening locations, click the Listening Locations drop-down list and make your selection. Then click the Add Address button at the bottom of the screen to open a new window.

    Figure 4.12. The Listening Locations screen

    The prompts on this screen depend on your protocol. By default, TCP/IP information is displayed. If you are using TCP/IP, the Host and Port fields are filled in for you. The host is the name of the machine in which the listener is running, and the port is the listening location for TCP/IP connections. The default value for the port is 1521.

  6. To save your information, choose File Save Network Configuration, and then look in the directory where the files was saved.

You can add additional listeners by following these steps. Listeners must have unique names and listen on separate ports, so assign the listener a new name and a new port (1522, for example). You also must assign service names to the listener. We'll see how to add service information in the next section.

NOTE

You always know where the files are stored by looking at the top banner of the Oracle Net Manager screen.

The Oracle Net Manager actually creates three files in this process: listener.ora, tnsnames.ora, and sqlnet.ora. The tnsnames.ora file does not contain any information. The sqlnet.ora file may contain a few entries at this point, but you can ignore them for the time being. The listener.ora file contains information as shown in the following code.

# listener.ora Network Configuration File:
     D:oracleora10g
etworkadminlistener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = mjworn.corp.testenv.net)
     (PORT = 1521))
       )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
       )
    )
  )

NOTE

We'll discuss the structure and content of the listener.ora file later in this chapter.

4.4.2.1.3. Adding Service Name Information to the Listener

After you create the listener with the name, protocol, and listening location information, you can define the network services to which the listener is responsible for connecting. This is called static service registration, because Oracle is not automatically registering the service with the listener. In releases of Oracle prior to Oracle 8i, static service registration was the only method to associate services with a listener.

A listener can listen to an unlimited number of network service names. Follow these steps to add the service name information:

  1. To select the listener to configure, click the Listeners icon and highlight the name of the listener that you want to configure.

  2. From the drop-down list at the top right of the screen, select Database Services.

  3. Click the Add Database button at the bottom of the screen. This opens the window that allows you to add the database (see Figure 4.13).

  4. Enter values in the Global Database Name, Oracle Home Directory, and SID fields. The entries for SID and Global Database Name are the same if you are using a flat naming convention.

  5. Choose File Save to save your configuration.

Figure 4.13. The Database Services screen

Here is an example of the completed listener.ora file:

# listener.ora Network Configuration File:
     D:oracleora10gNETWORKADMINlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
     (SID_DESC =
      (SID_NAME = PLSExtProc)
       (ORACLE_HOME = D:oracleora10g)
      (PROGRAM = extproc)
     )
     (SID_DESC =
      (GLOBAL_DBNAME = ORCL.COM)
       (ORACLE_HOME = d:oracleora10g)
      (SID_NAME = ORCL)
     )
  )

LISTENER =
  (DESCRIPTION_LIST =
     (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = mjworn.corp.testenv.net)(PORT = 1521))
     )
     (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
     )
  )

Table 4.1 lists and describes each of the listener.ora parameters for the Listening Location section of the listener.ora file.

Table 4.1. Parameters for the Listening Location Section of listener.ora
ParameterDescription
LISTENERIndicates the starting point of a listener definition. This is actually the name of the listener being defined. The default name is LISTENER.
DESCRIPTIONDescribes each of the listening locations.
ADDRESS_LISTContains address information about the locations where the listener is listening.
PROTOCOLDesignates the protocol for this listening location.
HOSTHolds the name of the machine on which the listener resides.
PORTContains the address on which the listener is listening.
SID_LIST_LISTENERDefines the list of Oracle services for which the listener is configured.
SID_DESCDescribes each Oracle SID.
GLOBAL_DBNAMEIdentifies the global database name. This entry should match the SERVICE_NAMES entry in the init.ora file for the Oracle service.
ORACLE_HOMEShows the location of the Oracle executables on the server.
SID_NAMEContains the name of the Oracle SID for the Oracle instance.

4.4.2.2. Optional listener.ora Parameters

You can set optional parameters that add functionality to the listener. To do so, select a parameter from the General Parameters drop-down list at the top right of the screen. Table 4.2 describes these parameters and where they can be found in the Oracle Net Manager.

Understanding Service Registration

Static service registration occurs when entries are added to the listener.ora file manually by using one of the Oracle tools. It is static because you are adding this information manually. Static service registration is necessary if you will be connecting to pre-Oracle8i instances using Oracle Enterprise Manager or if you will be connecting to external services.

Another way to manage listeners that does not require manual updating of service information in the listener.ora file is called dynamic service registration. Dynamic service registration allows an Oracle instance to automatically register itself with an Oracle listener. The benefit of this feature is that it does not require you to perform any updates of server-side network files when new Oracle instances are created. Dynamic service registration will be covered in more detail later in this chapter, in the section "Dynamically Registering Services."


Table 4.2. Optional listener.ora Parameter Definitions
Oracle Net Manager Promptlistener.ora ParameterDescription
Startup Wait TimeSTARTUP_WAIT_TIMEDefines how long a listener will wait before it responds to a STATUS command in the lsnrctl commandline utility.
(Unavailable from Net Manager)INBOUND_CONNECT_TIMEOUTDefines how long a listener will wait for a valid response from a client once a session is initiated. The default is 10 seconds.
Save Configuration On ShutdownSAVE_CONFIG_ON_STOPSpecifies whether modifications made during an lsnrctl session should be saved when exiting.
Log FileLOG_FILE. Will not be in listener.ora file if default setting is used. By default, listener logging is enabled with the log created in the default location.Specifies where a listener will write log information. This is ON by default and defaults to %ORACLE_HOME% etworkloglistener.log.
Trace LevelTRACE_LEVEL. Not present if tracing is disabled. Default is OFF.Sets the level of detail if listener connections are being traced. Valid values include Off, User, Support, and Admin.
Trace FileTRACE_FILESpecifies the location of listener trace information. Defaults to $ORACLE_HOME etwork race listener.trc.
Require A Password For Listener OperationsPASSWORDSSpecifies password required to perform administrative tasks in the lsnrctl command-line utility.

As you will see, you cannot add some parameters directly from the Oracle Net Manager and must do so manually. These optional parameters also have the listener name appended to them so that you can identify the listener definition to which they belong. For example, if the parameter STARTUP_ WAIT_TIME is set for the default listener, the parameter created is STARTUP_WAIT_TIME_LISTENER.

4.4.2.3. Managing Listeners with Oracle Enterprise Manager

Oracle Enterprise Manager (EM) is a web-based tool that allows you to manage many aspects of an Oracle 10g server. Being able to perform administrative functions via a web interface lets you administer the database from any location where a web browser is available.

You can also manage Oracle Net using EM. Once EM is installed and configured, you can invoke it via a URL from a web browser. Here is an example of a URL used to invoke the tool: http://mweishan-dell.corp.goxroads.net:5500/em

You are presented with a login screen, as shown in Figure 4.14. If you want to perform administrative functions such as administering the listener, log in as a user that has the SYSDBA privilege.

Once you are connected to the database, you are presented with the main database console. Oracle provides a wealth of information about your database configuration and performancerelated information within the EM framework. Figure 4.15 shows an example of the main EM console screen.

Notice under the General section a list of listeners that are available to manage. Click a listener to display a screen (see Figure 4.16) that gives you details about that listener, including when the listener was started, the net address and port information for the listener, and listening location information.

You can also add and edit listeners using the Database Control interface. Let's take a look at how to do so using the Oracle Enterprise Manager Database Control console.

Figure 4.14. The Oracle Enterprise Manager Login screen

Figure 4.15. The Oracle Enterprise Manager main console

Figure 4.16. The Oracle Enterprise Manager Listener console

4.4.2.3.1. Adding a Listener using Enterprise Manager Database Control

To add a new listener using the Database Control, select the Net Services Administration option listed under the Related Links section to open the Net Services Administration screen, as shown in Figure 4.17.

From the Administer drop-down list, select Listeners and click Go to open a login screen. Connect to the server with a valid operating system user ID and password to open the listener control screen, as shown in Figure 4.18.

In this example, a listener is already configured and named LISTENER. To create an additional listener, click the Create button to open the Create Listener screen, as shown in Figure 4.19.

Figure 4.17. The Oracle Enterprise Manager Net Services Administration screen

Figure 4.18. The Oracle Enterprise Manager listener control screen

Oracle will choose a new name for you and place that in the Listener Name field. In Figure 4.19, LISTENER0 is the new listener to be created.

You can fully configure the new listener using this interface. At a minimum, the listener needs listening address information. Click the Add button to open the Add Address screen, as shown in Figure 4.20.

Figure 4.19. The Oracle Enterprise Manager Create Listener screen

Figure 4.20. The Oracle Enterprise Manager Add Address screen

You can choose a protocol, such as TCP/IP, for which the listener will be listening. You also need to designate a listening port and host where the listener will be listening for connections. The other parameters, send and receive buffer size, are optional, advanced parameters. Click OK to save your information. You will then see the new listener listed on the Listeners screen, and you can control the listener from here (see Figure 4.21). To start the new listener, select Start/Stop from the Actions drop-down list and click Go.

4.4.2.3.2. Editing Existing Listeners Using Database Control

From the Oracle Enterprise Manager Listener console (shown earlier in this chapter in Figure 4.16), you can also make changes to an existing listener. Choose Edit to modify the listener.ora parameters, and save this information to the existing listener.ora file. To perform these functions, you must be logged in to the machine on which the listener file is located. From the login screen, enter the appropriate user ID and password for the machine and choose Login.

Once you are connected to the machine, you can administer all aspects of the listener. Figure 4.22 shows a snapshot of the main Enterprise Manager Oracle Net listener administration screen.

You use the tabs across the top of the listener administration screen to configure various aspects of the listener. You can manage logging and tracing, add listener services, and enter service name information to statically register new services with the listener. You can also manage the listening location and port information. If you choose to edit the port or listening location of the listener, click the Edit button to open the Edit Address screen, as shown in Figure 4.23. You can change the host name and port. Once you make a change, the listener is stopped and restarted with the new configuration information.

Figure 4.21. The Oracle Enterprise Manager listener control screen, with the new listener listed

Figure 4.22. The Oracle Enterprise Manager listener administration screen

Figure 4.23. The Oracle Enterprise Manager Edit Address screen

4.4.2.4. Managing Listeners with lsnrctl

You can also use a command-line interface, lsnrctl, to administer the listener. This tool gives you full configuration and administration capabilities. If you have been using Oracle, this tool should be familiar. This command-line interface has been around since the early releases of the Oracle product. Other Oracle network components, such as Connection Manager, also have command-line tools that are used to administer their associated processes.

NOTE

On Windows, the listener runs as a service. Services are programs that run in the background on Windows. You can start the listener from the Windows Services panel. Then select the name of the listener service from the list of services. If the name of your listener is Listener, for example, look for an entry such as OracleOra10gListener. Select the listener name and choose Start.

To invoke the command-line utility, type lsnrctl at the command line. The following code shows a resulting login screen:

D:oracleora10gBIN>lsnrctl

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on
     10-JUN-2004 09:57
:59

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL>

You can perform a variety of functions from within the lsnrctl utility. Let's take a look at the most common functions you'll perform on the listener using this utility.

4.4.2.4.1. Starting the Listener

The listener has commands to perform various functions. You can type help at the LSNRCTL> prompt to display a list of these commands. To start the default listener named LISTENER, type start at the prompt. To start a different listener, type start and then that listener name. For example, typing start listener1 starts the LISTENER1 listener.

The following code shows the results of starting the default listener:

D:oracleora10gBIN>lsnrctl start

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on
     10-JUN-2004 09:58
:45

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

Starting tnslsnr: please wait...

TNSLSNR for 32-bit Windows: Version 10.1.0.2.0 - Production
System parameter file is D:oracleora10g
etworkadminlistener.ora
Log messages written to D:oracleora10g
etworkloglistener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows:
     Version 10.1.0.2.0 - Production
Start Date                10-JUN-2004 09:58:47
Uptime                    0 days 0 hr. 0 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   D:oracleora10g
etworkadminlistener.ora
Listener Log File         D:oracleora10g
etworkloglistener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mweishan-
  dell.corp.goxroads.net)(POR
T=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.com" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

This listing shows a summary of information, including the services that the listener is listening for, the log locations, and whether tracing is enabled for the listener.

4.4.2.4.2. Reloading the Listener

If the listener is running and modifications are made to the listener.ora file manually, with Oracle Net Manager, or with Enterprise Manager, you must reload the listener to refresh the listener with the most current information. The reload command rereads the listener.ora file for the new definitions. As you can see, it is not necessary to stop and start the listener to reload it. Although stopping and restarting the listener can also accomplish a reload, using the reload command is better because the listener is not actually stopped, which makes this process more efficient. The following code shows an example of the reload command:

NOTE

Reloading the listener has no effect on clients connected to the Oracle server.

D:oracleora10gBIN>lsnrctl reload

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on
     10-JUN-2004 10:00:02

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-
   dell.corp.goxro
ads.net)(PORT=1522)))
The command completed successfully

In the code example above, Oracle has reread the listener.ora file and applied any changes that we made to the file against the currently running listener process. We can see the address, protocol, and port designation of the default listener. Notice that this listener is listening on a nondefault port of 1522.

4.4.2.4.3. Showing the Status of the Listener

You can display the status of the listener by using the status command. The status command shows whether the listener is active, the locations of the logs and trace files, how long the listener has been running, and the services for the listener. This is a quick way to verify that the listener is up and running with no problems.

The following code shows the result of the lsnrctl status command:

D:oracleora10gBIN>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on
   10-JUN-2004 10:00:36

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version
                          10.1.0.2.0 - Production
Start Date                10-JUN-2004 09:58:47
Uptime                    0 days 0 hr. 1 min. 50 sec
Trace Level                off
Security                  ON: Local OS Authentication
SNMP                       OFF
Listener Parameter File   D:oracleora10g
etworkadminlistener.ora
Listener Log File         D:oracleora10g
etworkloglistener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.com" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

This code example depicts a listener that has recently been started. We also see what the log file and parameter file locations are for the listener. This is a good facility to use to get a quick listing of vital information for the listener.

4.4.2.4.4. Listing the Services for the Listener

The lsnrctl services command displays information about the services, such as whether the services have any dedicated prespawned server processes or dispatched processes associated with them and how many connections have been accepted and rejected per service. Use this method to check if a listener is listening for a particular service.

The following code shows an example of running the services command:

D:oracleora10gBIN>lsnrctl services

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on
     10-JUN-2004 10:01:48
Copyright (c) 1991, 2004, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-dell.corp
   
.goxroads.net)(PORT=1522)))

Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
     Handler(s):
       "DEDICATED" established:0 refused:0
          LOCAL SERVER
Service "orcl.com" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
     Handler(s):
       "DEDICATED" established:0 refused:0
          LOCAL SERVER
The command completed successfully

In this example, you can see that the listener is listening for connections to the service ORCL. The line "DEDICATED" established:0 refused:0 shows us how many connections to this service have been accepted or rejected by the listener. One reason why a listener may reject servicing a request is if the database were not available.

4.4.2.4.5. Other Commands in lsnrctl

You can run other commands in lsnrctl. Table 4.3 summarizes these other commands. Type the command at the lsnrctl prompt to execute it.

Table 4.3. A Summary of the lsnrctl Commands
CommandDefinition
change_passwordAllows a user to change the password needed to stop the listener.
exitExits the lsnrctl utility.
quitPerforms the same function as exit.
reloadRereads the listener.ora file without stopping the listener. Refreshes the listener if the file changes.
save_configCopies the listener.ora file called listener.bak when changes are made to the listener.ora file from lsnrctl.
servicesLists a summary of services and details information on the number of connections established and the number of connections refused for each protocol service handler.
start listenerStarts the named listener.
status listenerShows the status of the named listener.
stop listenerStops the named listener.
traceTurns on tracing for the listener.
versionDisplays the version of the Oracle Net software and protocol adapters.

4.4.2.4.6. Using the set Commands in lsnrctl

The lsnrctl utility also has commands called set commands. To issue these commands, type set commandname at the LSNRCTL> prompt. You use the set commands to modify the listener.ora file. For example, you can use this command to set up logging and tracing. You can set most of these parameters using the Oracle Net Manager.

To display the current setting of a parameter, use the show command, which displays the current settings of the parameters set using the set command. Table 4.4 summarizes the lsnrctl set commands. Type set or show to display a listing of all the commands.

Table 4.4. A Summary of the lsnrctl set Commands
CommandDescription
current_listenerSets the listener to modify or shows the name of the current listener.
displaymodeSets display for the lsnrctl utility to RAW, COMPACT, NORMAL, or VERBOSE.
inbound_connect_timeoutSpecifies the time in seconds for a client to complete a connection request to the listener after the network connection is established. An ORA-12525 error will be generated if the listener fails to receive the request in the allotted time.
log_statusShows whether logging is on or off for the listener.
log_fileShows the name of listener log file.
log_directoryShows the log directory location.
rawmodeShows more detail on STATUS and SERVICES when set to ON. Values: ON or OFF.
startup_waittimeSets the length of time that a listener will wait to respond to a status command in the lsnrctl command-line utility.
save_config_on_stopSaves changes to the listener.ora file when exiting lsnrctl.
trc_levelSets the trace level to OFF, USER, ADMIN, SUPPORT.
trc_fileSets the name of the listener trace file.
trc_directorySets the name of the listener trace directory.

4.4.2.4.7. Stopping the Listener

To stop the listener, you must issue the lsnrctl stop command. This command stops the default listener. To stop a non-default listener, include the name of the listener. For example, to stop LISTENER1, type lsnrctl stop listener1. If you are in the lsnrctl> facility, you will stop the current listener defined by the current_listener setting. To see what the current listener is set to, use the show command. The default value is LISTENER.

Stopping the listener does not affect clients connected to the database. It only means that no new connections can use this listener until the listener is restarted.

The following code shows what the stop command looks like:

D:oracleora10gBIN>lsnrctl stop

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on 10-JUN-
   2004 10:05:51

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
The command completed successfully

4.4.3. Dynamically Registering Services

Oracle 10g databases can automatically register their presence with an existing listener. The instance registers with the listener defined on the local machine. Dynamic service registration allows you to take advantage of other features, such as load balancing and automatic failover. The PMON process is responsible for registering this information with the listener.

When dynamic service registration is used, you will not see the service listed in the listener.ora file. To see the service listed, run the lsnrctl services command. Be aware that if the listener is started after the Oracle instance, there may be a time lag before the instance actually registers information with the listener.

For an instance to automatically register with a listener, the listener must be configured as a default listener, or you must specify the init.ora parameter LOCAL_LISTENER. The LOCAL_ LISTENER parameter defines the location of the listener with which you want the Oracle server to register. A default listener definition is shown here:

Listener Name = LISTENER
Port = 1521
Protocol = TCP/IP

And here is an example of the LOCAL_LISTENER parameter being used to register the Oracle server with a non-default listener:

local_listener="(ADDRESS_LIST = (Address =
(Protocol = TCP) (Host=weishan) (Port=1522)))

In the previous example, the Oracle server registers with the listener listening on port 1522 using TCP/IP. This is a non-default port location, so you must use the LOCAL_LISTENER parameter in order for the registration to take place.

You must configure two other init.ora parameters to allow an instance to register information with the listener. Two parameters are used to allow automatic registration: INSTANCE_ NAME and SERVICE_NAMES.

The INSTANCE_NAME parameter is set to the name of the Oracle instance that you want to register with the listener. The SERVICE_NAMES parameter is a combination of the instance name and the domain name. The domain name is set to the value of the DB_DOMAIN initialization parameter. For example, if your DB_DOMAIN is set to GR.COM and your Oracle instance is DBA, set the parameters as follows:

Instance_name = DBA
Service_names = DBA.GR.COM

If you are not using domain names, set the INSTANCE_NAME and SERVICE_NAMES parameters to the same values.

4.4.4. Additional Configurations When Using Multiple Listeners

If you have a more complex network environment with a large number of simultaneous connection requests or if you are using an advanced database design such as Oracle Real Application Clusters, you can configure multiple listeners to better manage connection loads. You also gain functionality when multiple listeners service your database connection requests. These features include Connect-Time Failover, Transparent Application Failover, Client Load Balancing, and Connection Load Balancing.

4.4.4.1. Connect-Time Failover

The Connect-Time Failover feature allows clients to connect to another listener if the initial connection to the first listener fails. Multiple listener locations are specified in the clients tnsnames.ora file. If a connection attempt to the first listener fails, a connection request to the next listener in the list is attempted. This feature increases the availability of the Oracle service should a listener location be unavailable.

Here is an example of what a tnsnames.ora file looks like with connect-time failover enabled:

ORCL =
   (DESCRIPTION=
     (ADDRESS_LIST=
        (ADDRESS=(PROTOCOL=TCP)(HOST=DBPROD)(PORT=1521))
        (ADDRESS=(PROTOCOL=TCP)(HOST=DBFAIL)(PORT=1521))
      )
     (CONNECT_DATA=(SERVICE_NAME=PROD)(SERVER=DEDICATED)
      )
    )

NOTE

We will discuss the tnsnames.ora file in detail later in this chapter in the section "Configuring Oracle Net for the Client."

Notice the additional entry under the ADDRESS_LIST section. Two listeners are specified. If a connection is unsuccessful when attempting to connect to the DBPROD host on port 1521, a connection attempt is made to the DBFAIL host on port 1521. The time that the connection waits before attempting to failover is operating system dependent.

4.4.4.2. Transparent Application Failover

The Transparent Application Failover (TAF) feature is a runtime failover for high-availability environments, such as Oracle Real Application Clusters. TAF fails over and reestablishes application-to-service connections. It enables client applications to automatically reconnect to the database if the connection fails and, optionally, resume a SELECT statement that was in progress. The reconnection happens automatically from the OCI library.

The following code shows an example of the tnsnames.ora file setup for using Transparent Application Failover:

ORCL =
   (DESCRIPTION=
     (FAILOVER=ON)
     (ADDRESS_LIST=
        (ADDRESS=(PROTOCOL=TCP)(HOST=DBPROD)(PORT=1521))
        (ADDRESS=(PROTOCOL=TCP)(HOST=DBFAIL)(PORT=1521))
      )
     (CONNECT_DATA=(SERVICE_NAME=PROD)(SERVER=DEDICATED)
        (FAILOVER_MODE=(TYPE=select)(METHOD=basic))
      )
    )

In this example, notice additional entries in the tnsnames.ora file that enable the Transparent Application Failover. There are two hosts, DBPROD and DBFAIL. If DBPROD becomes unavailable, the connections will failover to the DBFAIL host and connect to the associated service. The database service of PROD must be the same on both the DBPROD and DBFAIL servers for this example to work properly.

4.4.4.3. Client Load Balancing

Client Load Balancing is a feature that allows clients to randomly select from a list of listeners. Oracle Net moves through the list of listeners and balances the load of connection requests across the available listeners. Here is an example of the tnsnames.ora entry that allows for load balancing:

ORCL =
   (DESCRIPTION=
     (LOAD_BALANCE=ON)
     (ADDRESS_LIST=
        (ADDRESS=(PROTOCOL=TCP)(HOST=MWEISHAN-DELL)(PORT=1522))
        (ADDRESS=(PROTOCOL=TCP)(HOST=MWEISHAN-DELL)(PORT=1521))
     )
     (CONNECT_DATA=
(SERVICE_NAME=ORCL)
     )
    )

Notice the additional parameter of LOAD_BALANCE. This enables load balancing between the two listener locations specified.

4.4.4.4. Connection Load Balancing

Connection Load Balancing is a feature that enables better distribution of connection among a group of dispatchers in an Oracle Shared Server environment. The next chapter explains this concept in more detail.

4.4.5. Troubleshooting Server-Side Connection Problems

Even if it seems that you have configured Oracle server-side components correctly, network errors can still occur that will require troubleshooting. You can experience a connection problem for a variety of reasons:

  • The client, middle-tier, or Oracle server is not configured properly.

  • The client cannot resolve the net service name.

  • The underlying network protocol is not active on the server; for example, the TCP/IP process on the server is not running.

  • The user enters an incorrect net service name, user ID, or password.

You can diagnose and correct these types of errors. In the next section, "Server-Side Computer and Database Checks," you will see how to diagnose and correct connection problems originating from the Oracle server. In the next chapter, we discuss troubleshooting problems with client-side network configuration.

When a client has a connection problem that is up to you to fix, it is helpful to first gather information about the situation. Make sure you record the following information:

  • The Oracle error that the client received.

  • The location of the client. Is the client connecting from a remote location, or is the client connected directly to the server?

  • The name of the Oracle server to which the client is attempting to connect.

  • Check to see if other clients are having connection problems. If so, are these clients in the same general location?

  • Ask the user what is failing. Is it the application being used or the connection?

We will now look at the particular network areas to check and the methods used to further diagnose connection problems from the Oracle server. We will also look at the Oracle error codes that will help identify and correct the problems.

4.4.5.1. Server-Side Computer and Database Checks

You can perform several server-side checks if a connection problem occurs. Before running such checks, be sure that the machine is running, that the Oracle server is available, and that the listener is active. In the following sections, we'll summarize the checks to perform on the server.

4.4.5.1.1. Check the Server Machine

Make sure that the server machine is active and available for connections. On some systems, it is possible to start a system in a restricted mode that allows only supervisors or administrators to log in to the computer. Make sure that the computer is open and available to all users.

On a TCP/IP network, you can use the ping utility to test for connectivity to the server. Here is an example of using ping to test a network connection to a machine called matt:

C:usersdefault>ping matt

Pinging cupira03.cmg.com [10.69.30.113] with 32 bytes of data:

Reply from 10.69.30.113: bytes=32 time=10ms TTL=248
Reply from 10.69.30.113: bytes=32 time=10ms TTL=248
Reply from 10.69.30.113: bytes=32 time<10ms TTL=248
Reply from 10.69.30.113: bytes=32 time=10ms TTL=248

The reply indicates that the machine can be seen on the network.

4.4.5.1.2. Check the Database

Make sure that the database is running. Connect to the Oracle server and log in to the database using a tool such as SQL*Plus. First attempt a local connection, which does not use the Oracle listener.

To connect to the Oracle server using a local connection, set your ORACLE_SID environmental variable to the name of the Oracle instance that you want to connect to. Then, attempt to connect to SQL*Plus.

The following example is a connection sequence on Windows that fails because the database is not running. For example, if the database that you are attempting to connect to is named MJW, you can use the following code example in a Windows environment for your test:

D:oracleora10gBIN>sqlplus system/manager

SQL*Plus: Release 10.1.0.2.0 - Production on Thu Jun 10 10:08:16 2004

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist

An ORA-01034 error indicates that the Oracle instance is not running. You need to start the Oracle instance. The ORA-27101 error indicates that no instance is currently available to connect to for the specified ORACLE_SID.

4.4.5.1.3. Verify That the Database Is Open to All Users

You can open a database in restricted mode. This means that only users with restricted mode access can use the system. This is not a networking problem, but it will lead to clients being unable to connect to the Oracle server. Here is an example of a connection that fails because the user does not have the restricted session privilege.

D:>sqlplus scott/tiger@ORCL

SQL*Plus: Release 10.1.0.2.0 - Production on Thu Jun 10 10:09:19 2004

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

ERROR:
ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege

As we can see, the user Scott is attempting to connect to the ORCL service. The error message tells us that user Scott does not have the restricted session privilege and cannot log in until the DBA either grants this privilege to Scott or takes the database out of restricted session mode.

4.4.5.1.4. Check User Privileges

Make sure that the user attempting to establish the connection has been granted the CREATE SESSION privilege to the database. This privilege is needed for a user to connect to the Oracle server. If the client does not have this privilege, you must grant it to the user. To do so, follow this example:

D:oracleora10gBIN>sqlplus matt/matt
SQL*Plus: Release 10.1.0.2.0 - Production on Thu Jun 10 10:09:19 2004
Copyright (c) 1982, 2004, Oracle.  All rights reserved.
ERROR:
ORA-01045: user MATT lacks CREATE SESSION privilege; logon denied

Here is an example of how you can grant the CREATE SESSION privilege to a user:

SQL> grant create session to matt;
Grant succeeded
SQL>

In this example, the DBA has granted the CREATE SESSION privilege to user Matt. Matt now has the ability to make a connection to the database.

4.4.5.2. Server-Side Network Checks

After you validate that the server where the database is located is up and available and you verify that the user has proper privileges, begin checking for any underlying network problems on the server. In the following sections, we will detail some of the common areas of the server to check when you are experiencing connection problems.

4.4.5.2.1. Check Listener

Make sure that the listener is running on the Oracle server. Make sure that you check the services for all the listeners on the Oracle server; you can use the lsnrctl status command to do this. The following command shows the status of the default listener named LISTENER:

D:oracleora10gBIN>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on 10-JUN-
   2004 10:00:36

Copyright (c) 1991, 2004, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version
                          10.1.0.2.0 - Production

Start Date                10-JUN-2004 09:58:47
Uptime                    0 days 0 hr. 1 min. 50 sec
Trace Level                off
Security                  ON: Local OS Authentication
SNMP                       OFF
Listener Parameter File   D:oracleora10g
etworkadminlistener.ora
Listener Log File         D:oracleora10g
etworkloglistener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.com" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successful

Also check the services for which the listener is listening. You must see the service to which the client is attempting to connect. If the service is not listed, the client may be entering the wrong service, or the listener may not be configured to listen for this service.

4.4.5.2.2. Check GLOBAL_DBNAME

If the client is using the hostnaming method, make sure that the GLOBAL_DBNAME parameter is set to the name of the host machine. You can find this parameter in the service definition of the listener.ora file. Verify the setting by reviewing the listener.ora configuration. In the following sample code, we can see that the GLOBAL_DBNAME parameter has been set to mweishan-dell.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = mweishan-dell) − machine listener is on
      (ORACLE_HOME = d:oracleora10g)
      (SID_NAME = orcl)

4.4.5.2.3. Check Listener Protocols

Check the protocols for which the listener is configured. This is displayed by the lsnrctl services command. You can see an example of this command in the section, "Listing the Services for the Listener," earlier in this chapter. Make sure that the protocol of the service matches the protocol the client is using when requesting a connection. If the client is requesting to connect with a protocol that the listener is not listening for, the user will receive an ORA-12541 "No Listener" error message.

4.4.5.2.4. Check Server Protocols

Make sure that the underlying network protocol on the server is active. For systems that run TCP/IP, you can attempt to use the ping command to ping the server. This will verify that the TCP/IP daemon process is active on the server. You can also check this by verifying the services on Windows or using the ps command on Unix. An example of the ping command can be found earlier in this chapter in the section "Check Server Machine."

4.4.5.2.5. Check Server Protocol Adapters

Make sure that the appropriate protocol adapters are installed on the server. On most platforms, you can invoke the Oracle Universal Installer program and check the list of installed protocols. On Unix platforms, you can use the adapter utility to ensure that the appropriate adapters are linked to Oracle. The following example shows how to run this utility, which is located in the $ORACLE_HOME/bin directory.

The following adapters summarize all of the protocol adapters that have been installed as part of this Oracle installation. You can see that we have installed four types of adapters.

[root@localhost] ./adapters oracle

Net protocol adapters linked with oracle are:

    BEQ
    IPC
    TCP/IP
    RAW

Net Naming Adapters linked with oracle are:

  Oracle TNS Naming Adapter
  Oracle Naming Adapter
Advanced Networking Option/Network Security products
 linked with oracle are:

   Oracle Security server Authentication Adapter

If the required protocol adapter is not listed, you have to install the adapter. You can do so by using the Oracle Installer, installing the Oracle Net Server software, and choosing the appropriate adapters during the installation process.

4.4.5.2.6. Check for Connection Timeouts

If the client is receiving an ORA-12535 or an ORA-12547 error message, the client is timing out before a valid connection is established. This can occur if you have a slow network connection. You can attempt to solve this problem by increasing the time that the listener will wait for a valid response from the client; simply set the INBOUND_CONNECT_TIMEOUT parameter to a higher number. This is the number of seconds that the listener waits for a valid response from the client when establishing a connection.

4.4.6. Oracle Net Logging and Tracing on the Server

If a network problem persists, you can use logging and tracing to help resolve it. Oracle generates information into log files and trace files that can assist you in tracking down network connection problems. You can use logging to find out general information about the success or failure of certain components of the Oracle network. You can use tracing to get in-depth information about specific network connections.

NOTE

By default, Oracle produces logs for clients and the Oracle listener. You cannot disable client logging.

Logging records significant events, such as starting and stopping the listener, along with certain kinds of network errors. Errors are generated in the log in the form of an error stack. The listener log records information such as the version number, connection attempts, and the protocols for which it is listening. You can enable logging at the client, middle-tier, and server locations.

Real World Scenario: Use Tracing Sparingly

Use tracing only as a last resort if you are having connectivity problems between the client and server. Complete all the server-side checks described earlier before you resort to tracing. The tracing process generates a significant amount of overhead, and, depending on the trace level set, it can create some rather large files. This activity will impede system I/O performance because of all the information that is written to the logs, and if left unchecked, it could fill your disk or file system.

I was once involved with a large project that was using JDBC to connect to the Oracle server. We were having difficulty with connections being periodically dropped between the JDBC client and the Oracle server. We enabled tracing to try to find the problem. We did eventually correct the problem (it was with how our DNS names server was configured), but the tracing was left on inadvertently. When the system eventually went into production, the trace files grew so large that they filled the disk where tracing was being collected. To prevent this from happening, periodically ensure that the trace parameters are not turned on, and if they are, turn them off.


Tracing, which you can also enable at the client, middle-tier, or server location, records all events that occur on a network, even when an error does not occur. The trace file provides a great deal of information that logs do not, such as the number of network round-trips made during network connection or the number of packets sent and received during a network connection. Tracing enables you to collect a thorough listing of the actual sequence of the statements as a network connection is being processed. This gives you a much more detailed picture of what is occurring with connections that the listener is processing.

Use the Oracle Net Manager to enable most logging and tracing parameters. Many of the logging and tracing parameters are found in the sqlnet.ora file. Let's take a look at how to enable logging and tracing for the various components in an Oracle network.

4.4.6.1. Server Logging

By default, the listener is configured to enable the generation of a log file. The log file records information about listener startup and shutdown, successful and unsuccessful connection attempts, and certain types of network errors. By default, the listener log location is $ORACLE_ HOME/network/log on Unix and %ORACLE_HOME% etworklog on Windows. The default name of the file is listener.log.

Information in the listener.log file is a fixed-length, delimited format with each field separated by an asterisk. If you want to further analyze the information in the log, you can load the data into an Oracle table using a tool such as SQL*Loader. Notice in the following sample listing that the file contains information about connection attempts, the name of the program executing the request, and the name of the client attempting to connect. The last field contains a zero if a request was successfully completed.

TNSLSNR for 32-bit Windows: Version 10.1.0.2.0 - Production on 27-APR-
   2004 16:05:13

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

Log messages written to D:oracleora10g
etworkloglistener.log
Trace information written to
   D:oracleora10g
etwork	racelistener.trc
Trace level is currently 0

Started with pid=2260
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mweishan-
   dell.corp.goxroads.net)(PORT=1521)))

TIMESTAMP * CONNECT DATA [* PROTOCOL INFO] * EVENT [* SID] * RETURN CODE
27-APR-2004 16:05:17 *
   (CONNECT_DATA=(CID=(PROGRAM=)(HOST=)(USER=mweishan))(COMMAND=status)
   (ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=168821248)) * status * 0

27-APR-2004 16:05:18 *
   (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))(SERVICE_NAME=or
   cl)) * (ADDRESS=(PROTOCOL=tcp)(HOST=206.122.131.90)(PORT=2021)) *
   establish * orcl * 12514
TNS-12514: TNS:listener does not currently know of service requested in
   connect descriptor

4.4.6.2. Server Tracing

As mentioned earlier, tracing gathers information about the flow of traffic across a network connection. Data is transmitted back and forth in the form of packets. A packet contains sender information, receiver information, and data. Even a single network request can generate a large number of packets.

In the trace file, each line file starts with the name of the procedure executed in one of the Oracle Net layers and is followed by a set of hexadecimal numbers. The hexadecimal numbers are the actual data transmitted. If you are not encrypting the data, sometimes you will see the actual data after the hexadecimal numbers.

Each of the Oracle Net procedures is responsible for a different action. The code type of each packet depends on the action being taken. All the packet types start with NSP. Here is a summary of the common packet types:

Packet KeywordPacket Type
NSPTACAccept
NSPTRFRefuse
NSPTRSResend
NSPDAData
NSPCNLControl
NSPTMKMarker

NOTE

If you are doing server-to-server communications and have a sqlnet.ora file on the server, you can enter information in the Server Information section located on the Tracing tab from the Profile screen in Oracle Net Manager tracing. This provides tracing information for server-to-server communications.

Several numeric codes are also used to help diagnose and troubleshoot problems with Oracle Net connections. These codes can be found in the trace files. Here is an example of a line from the trace file that contains a code value:

nspsend: plen=12, type=4

Here is a summary of the numeric codes that you could encounter in a trace file:

CodePacket Type
1Connect
2Accept
3Acknowledge
4Refuse
5Redirect
6Data
7Null, empty data
9Abort
11Resend
12Marker
13Attention
14Control information

4.4.6.3. Enabling Server Tracing

You can enable server tracing from the same Oracle Net Manager screens shown earlier. Simply click the Tracing Enabled radio button. The default filename and location is $ORACLE_HOME/ network/trace/listener.trc in Unix and %ORACLE_HOME% etwork racelistener.trc on Windows. You can set the trace level to OFF, USER, ADMIN, or SUPPORT. The USER level detects specific user errors. The ADMIN level contains all the user-level information along with installation-specific errors. SUPPORT is the highest level and can produce information that might be beneficial to Oracle Support personnel. This level also can produce large trace files. The following listing shows an example of a listener trace file:

nsglhfre: entry
nsglhrem: entry
nsglhrem: entry
nsglhfre: Deallocating cxd 0x4364d0.
nsglhfre: exit
nsglma: Reporting the following error stack:
TNS-01150: The address of the specified listener name is incorrect
 TNS-01153: Failed to process string:
   (DESCRIPTION=(ADDRESS=(PROTOCOL=TC)(HOST=mprntw507953)
   (PORT=1521)))
nsrefuse: entry
nsdo: entry

nsdo: cid=0, opcode=67, *bl=437, *what=10, uflgs=0x0, cflgs=0x3
nsdo: rank=64, nsctxrnk=0
nsdo: nsctx: state=2, flg=0x4204, mvd=0
nsdo: gtn=152, gtc=152, ptn=10, ptc=2019
nscon: entry
nscon: sending NSPTRF packet
nspsend: entry
nspsend: plen=12, type=4
ntpwr: entry
ntpwr: exit

You can tell which section of the Oracle Net the trace file is in by looking at the first two characters of the program names in the trace file. In the previous example, nscon refers to the network session (NS) sublayer of Oracle Net. A message is being sent back to the client in the form of an NSPTRF packet. This is a refuse packet, which means that the requested action is being denied.

You see the Oracle error number embedded in the error message. In the previous example, a TNS-01153 error was generated. This error indicates that the listener failed to start. It also shows the line of information on which the listener is failing. This error could be the result of a problem with another process listening on the same location, or it could be a syntax problem in the listener.ora file. Basically, this error message states that a syntax error has occurred because the protocol was specified as TC and not TCP. In addition to this error, there are some more recent ones. The most recent errors are at the bottom of the file.

The following example shows a section of the listener.ora file with the logging and tracing parameters enabled:

# D:ORACLEora10gNETWORKADMINLISTENER.ORA Configuration
# File:D:Oracleora10gNETWORKADMINlistener.ora
# Generated by Oracle Oracle Net Manager

TRACE_LEVEL_LISTENER = ADMIN
TRACE_FILE_LISTENER = LISTENER.trc
TRACE_DIRECTORY_LISTENER = D:Oracleora10g
etwork	race
LOG_DIRECTORY_LISTENER = D:Oracleora10g
etworklog
LOG_FILE_LISTENER = LISTENER.log

Table 4.5 summarizes the meaning of each of these parameters.

Table 4.5. listener.ora Log and Trace Parameters
ParameterDefinition
TRACE_LEVEL_LISTENERTurns tracing on and off. The levels are OFF, USER, ADMIN, and SUPPORT. SUPPORT generates the greatest amount of data.
TRACE_FILE_LISTENERThe name of the trace file.
TRACE_DIRECTORY_LISTENERThe directory where trace files are written.
LOG_DIRECTORY_LISTENERThe directory where log files are written.
LOG_FILE_LISTENERThe name of the listener log file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset