Oracle listener (altersystemregister)

Source: Internet
Author: User
Tags time 0
I always wanted to write a listener. Oracle listener is an important database server component and plays an important role in the entire Oracle architecture. The Listener Lisener function is based on the current Oracle version. Listener is mainly responsible for the following functions: 1. Listening for client requests. Listener runs on Data

I always wanted to write a listener. Oracle listener is an important database server component and plays an important role in the entire Oracle architecture. The Listener Lisener function is based on the current Oracle version. Listener is mainly responsible for the following functions: 1. Listening for client requests. Listener runs on Data

Always wanted to writeListener.

OracleListener is an importantDatabaseServerComponents play an important role in the entire Oracle architecture.

Listener Lisener Function

From the current Oracle version, Listener is mainly responsible for the following functions:

1. Listen to client requests. The listener runs on the database server and is associated with Oracle instances (multiple). It is a specialized processWindowsIn the service project or Linux running process list, the corresponding running process is displayed. The name is TNSLSNR on Windows and lsnrctl on Linux/Unix platforms. The listener is waiting on the server to set the port (default: 1521) and listen on client requests.

2. Allocate for client requestsServerProcess. The listener is only responsible for answering requests, and then transfers the requests to the Oracle Server Process. In Oracle service mode, the client Process does not allow direct operations on database instances and data, but uses a service Process Server Process (also known as the shadow Process) as a proxy. After the listener receives the request, it asks the operating system (or the Dispatcher component) to fork (or assign) a Server Process to connect to the client.

3. register the instance service. Essentially, listener is a bridge between an instance and a client process. The connection between Listener and the instance is implemented through the registration process. The registration process is that the instance tells the listener that its database instance name instance_name and service name service_names. The listener registers such information, and finds the correct service instance name for client requests based on the listener registration information. Currently, the Oracle version provides dynamic registration and static registration methods.

4. Transfer failover by mistake. Failover isRACAn important feature of fault tolerance, which is a feature that automatically transfers requests to other available instances when the database instance crashes. It provides a high degree of Availability (Availability. In this process, it is a listener function to find that the instance has crashed and the request is transferred to another instance.

5. load balancing. In the RAC architecture, Oracle implements load balancing. When a customer request arrives, Oracle will avoid high-load instances based on the load of all instances in the current RAC cluster environment, and transfer the request to a lower-load instance for processing. In earlier RAC versions, the load severity is determined based on the number of connections currently maintained by the listener, rather than viewing the load of multiple instances in real time. Communication between listeners in the RAC environment.

The following section briefly introduces the listener from several aspects.

Listener operation

Listeners can be directly operated on Windows and Linux/Unix platforms. The following uses operations on Windows as an example. Operations on other platforms are similar.

In the command line window (CMD), enter lsnrctl to enter the Listener Control Window.

C: \ Documents ents and Settings \ Administrator> lsnrctl

LSNRCTL for 32-bit Windows: Version10.2.0.1.0-Production on-2010

3:04

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

Welcome to LSNRCTL. Enter "help" for information.

LSNRCTL>

Run the help command to view supported listener operations. The following describes only a few common examples.

1. view the current listener status

Click status to view the status of the listener, corresponding operation logs, service registration information, and other information. As follows:

LSNRCTL> status

// Name and information of the connection listener: Host Name + listening port number

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = www-0e6111dff74) (PORT = 1521)

))

LISTENER STATUS

------------------------

Alias LISTENER

Version TNSLSNR for 32-bit Windows: Version10.2.0.1.0-Production // Listener version information, which is important when multiple instances exist on one machine! Because the version is backward compatible

Start Date: 26-12 months-2010 19:38:03 // start service time

Normal operation time: 0 days, 2 hours, 23 minutes, 51 seconds

Trace Level off // debug information, which can be set for listener tracking

Security ON: Local OS Authentication // indicates that the Operation permission for starting and disabling listeners is implemented through OS verification. This means that you can set a password project for the listener, which is also an important aspect of Oracle Security configuration;

Snmp off // SNMP protocol enabled

Parameters Used by the listener parameter file D: \ oracle \ network \ admin \ listener. ora //

Listener log file D: \ oracle \ network \ log \ listener. log // operation log location

Listener endpoint overview...

(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = www-0e6111dff74) (PORT = 1521 )))

Service summary .. // list of services currently registered in the listener

The Service "PLSExtProc" contains one routine.

Routine "PLSExtProc", status UNKNOWN, contains one handler of this service...

The Service "orcl" contains one routine.

Routine "orcl", status READY, contains 1 handler of this service...

The Service "orclXDB" contains one routine.

Routine "orcl", status READY, contains 1 handler of this service...

The Service "orcl_XPT" contains one routine.

Routine "orcl", status READY, contains 1 handler of this service...

Command executed successfully

The above uses the red letter to explain the result to a certain extent. Note the following items.

Parameters Used by the listener parameter file D: \ oracle \ network \ admin \ listener. ora //

When the listener is started, it can be started based on the parameter file. Of course, the listener can be started without the parameter file listener. At that time, the listener operates based on the default behavior. This parameter specifies the location of the listener parameter file, listener. ora. This file is a text parameter file that describes the listener port, host name, and static registration information. Listener. ora is dynamically configured when a Listener is created after the database instance is created.

Listener log file D: \ oracle \ network \ log \ listener. log // operation log location

Listener logs are information libraries that record and describe the listener's work and errors. By carefully studying the log Content, we can find the problem of the current listener, solve the connection fault, and gain a deep understanding of the working principle of the listener.

The Service "orcl" contains one routine.

Routine "orcl", status READY, contains 1 handler of this service...

As mentioned above, the listener has the registration function, and uses the status command (services Command has the same effect ). You can see which services are currently registered and used to check connection service failures. This is a common tool.

2. enable/disable listeners

The behavior of the listener is controlled by the parameter file. Sometimes we need to adjust the parameter of the listener. You can adjust the listener parameters through the GUI provided by Oracle or manually modify listener. ora.

Because the parameter file listener. ora is a text file. Oracle does not support hot loading for parameter files of the text type in most cases. This is true for both Pfile and listener. ora.

You can use the Net Configuration Assistant to configure the GUI. After the configuration is complete, the configuration program automatically restarts the listener program to load the modified parameter file. If you manually modify listener. ora, you must manually disable and start the listener.

LSNRCTL> stop

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = www-0e6111dff74) (PORT = 1521)

))

Command executed successfully

LSNRCTL> start

Start tnslsnr: Please wait...

TNSLSNR for 32-bit Windows: Version10.2.0.1.0-Production

The system parameter file is D: \ oracle \ network \ admin \ listener. ora.

Log information written to D: \ oracle \ network \ log \ listener. log

Listen: (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = www-0e6111dff74) (PORT = 1521 )))

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = www-0e6111dff74) (PORT = 1521)

))

LISTENER STATUS

------------------------

Alias LISTENER

Version TNSLSNR for 32-bit Windows: Version10.2.0.1.0-Production

Start Date: 26-12-2010 22:32:34

Normal operation time 0 days 0 hours 0 minutes 2 seconds

Tracking level off

Security ON: Local OS Authentication

SNMP OFF

Listener parameter file D: \ oracle \ network \ admin \ listener. ora

Listener log file D: \ oracle \ network \ log \ listener. log

Listener endpoint overview...

(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = www-0e6111dff74) (PORT = 1521 )))

Service summary ..

The Service "PLSExtProc" contains one routine.

Routine "PLSExtProc", status UNKNOWN, contains one handler of this service...

Command executed successfully

Here we will talk about the parameter configuration of the listener. You can use the GUI to handle most of the situations and avoid listener faults caused by misspelling (the listener does not check whether the configuration items are correct or not ). However, in some complex cases, such as when a machine is bound with multiple IP addresses or the complex function configuration of RAC, the listener. ora method is usually written manually.

In addition, the lsnrctl prompt line also provides the reload command to reload the file and SID information when the listener is started. However, I still prefer the combination of stop + start.

If you enable or disable listeners on windows, you can also perform operations in the System Service Project List. The effect is the same.

After learning about the listener tool, let's see how the listener works in the next phase.

Oracle listener (2)

/23:21:39/personal classification: oracle Working Mechanism

View (709)/comment (6)/score (35/0)

ListenerWork Process

Next we will talk about the working process of the listener. Generally, the listener runs in the operating system as an independent process and waits for the request from the client on a specific network port (1521 by default. Note: When configuring the Naming Service on the client, we enter 1521 to establish a connection with the listener program.

When a request arrives on schedule, the listener checks the list of registered services to find the correspondingDatabaseInstance information to obtain the ORACLE_HOME path of the specified instance. It indicates that a connection can be established.

The interaction between the client and the instance is not direct.ServerProcess is implemented as a proxy intermediary. All commandsSQLAll are sent to the instance by the client through the Server Process. This architecture isOracleProvides protection for instances and database files.

After obtaining the request, the listener allocates a Server Process from the Oracle instance. There are some differences between different Oracle connection methods.

In dedicated connection mode, a client connection corresponds to a Server Process. The listener requests fork (created) a Server Process from the OS and tries to interact with the listener.

In the shared connection mode, multiple clients share a Server Process (note: this is not a connection pool ). The listener is directed to the Dispatcher process (ManagementA Process connected in the sharing mode) requests a Server Process to interact with it.

The connection between Server Process and listener is actually the exchange of information. Server Process sends Process numbers and connection addresses in the OS to the listener. The listener transmits client information to the Server Process.

After obtaining the Server Process information, the listener returns it to the Client Connection Program. After the client obtains the information, it reconnects and works with the Server Process according to the returned information.ServerPort.

At this time, the client sends the connection username, password, and other information to Server Process for login verification and other operations. This is the end of the listener.

There isTechnologyThe details are that port 1521 is not allowed when the Server Process is connected to the client. The specific connection port is random. In 9i Windows, ifInstallThe firewall only allows 1521 port communication, which may cause some connection problems. Fortunately, a Port Sharing Technology is implemented on other platforms and later versions, and the connection can use port 1521 together with the listener.

The working principle of the listener is introduced. Next we will talk about the dynamic and static registration mechanism.

Dynamic and Static registration mechanism

In the above content, we have initially understood the role of registration, that is, to register the database instance name and service name to the running listener program. Currently, Oracle supports static registration and dynamic registration.

Static registration, as its name implies, is to display the service name of the specified listener program for that instance. When the listener is started, the listener does not know whether the monitored instance service exists. Until a client requests the specified service.

The static registration location is specified in the listener. ora parameter file. The following is the structure of a typical parameter file.

# Listener. ora Network Configuration File: D: \ oracle \ product \ 10.2.0 \ db_1 \ network \ admin \ listener. ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = D: \ oracle)

(PROGRAM = extproc)

)

(SID_DESC =

(GLOBAL_DBNAME = orcl)

(ORACLE_HOME = D: \ oracle)

(SID_NAME = orcl)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC0 ))

(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))

)

)

The SID_DESC in the SID_LIST configuration node is the node project configured for static registration. SID_LIST is used to configure the service items registered by the current listener. It is configured through multiple SID_DESC. Each SID_DESC is basically a configuration item. By default, only the PLSExtProc project is supported during dynamic registration.

In the static configuration project, configure the service project through GLOBAL_NAME, specify the name of the database instance through SID_NAME, and configure the Oracle database through ORACLE_HOME.SoftwareThe basic directory for installation.

Dynamic registration is a registration method corresponding to static registration. It is also configured through listener. ora. The following is a typical configuration parameter file.

# Listener. ora Network Configuration File: D: \ oracle \ product \ 10.2.0 \ db_1 \ network \ admin \ listener. ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = D: \ oracle)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = www-0e6111dff74) (PORT = 1521 ))

)

)

Comparing the static registration file above, we can find that the project with the specified service name and database instance name is missing. Only the local address and listener port information are available.

Dynamic Registration is performed on the database instance on the host where the listener is located. Dynamic registration is a function that cannot be disabled on Oracle. The background process PMON of the Instance registers the parameter information of the instance to the listener every one to two minutes for Dynamic Registration.

The registered information is the database parameters service_name and instance_name. You can run the Show Parameter command.

SQL> show parameter instance_name;

NAME TYPE VALUE

-----------------------------------------------------------------------------

Instance_name string orcl

SQL> show parameter service_names;

NAME TYPE VALUE

-----------------------------------------------------------------------------

Service_names string orcl

When a database is created, these two parameters are already set and will not be changed easily.

If the instance_name parameter is not set, db_name is selected as the Instance name. If service_names is not set, the parameters db_name and db_domain are combined into the service name for registration.

It is worth noting that the service_names parameter is a parameter that can specify multiple service names, separated by commas. That is to say, an Oracle instance can provide services externally as multiple service names at the same time. Service_name is a concept proposed by Oracle in the latest version to replace SID_NAME. By specifying the Service, multiple Oracle instances can provide consistent data access services (that isRAC).

We recommend that you set the instance_name and service_name parameters. Because it will affect the Dynamic Registration effect to a certain extent.

If the two parameters are not specified, the database instance will be dynamically registered only after the listener instance is started. Once the listener is restarted, the dynamic registration information will not exist and it is difficult to register it again. Therefore, we recommend that you set these two parameters.

PMON periodically registers registration information only when two values are displayed. You can also use the command line to force PMON to immediately perform a registration operation.

SQL> alter system register

2;

System altered

Finally, let's talk about the function of Dynamic Registration and support error transfer failover. The initiator of the registration operation is the PMON background process, and PMON is the most important background process of the Oracle instance. Many documents and DBAs determine the status of the database instance based on the status of the process. PMON is responsible for dynamic registration. If dynamic registration is not available, it means that PMON has lost its working capacity, which means that the instance served by the listener cannot work.

Through the dynamic registration mechanism, the listener can know that the server instance of the Service has crashed, and the client requests can be transferred by mistake.

Of course, the crash we are talking about here is the crash of the instance. If the listener program crashes, the situation is different.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.