Oracle Listener Dynamic registration and static registration _oracle

Source: Internet
Author: User

A What is registration

Registration is the registration of the database as a service to the listener. The client does not need to know the database name and instance name, just know that the database can be used to connect to the database with the service name provided externally. This service name may or may not be the same as the instance name.

During the database server startup process, the database server registers the appropriate service with the listener (whenever a database is started, two messages are registered to the listener by default): The database server's corresponding instance and service. )

This is equivalent to: there is a listener (Listener) between the database server and the client, and in the Listener, the corresponding service name (one database may have multiple service names) is logged, and when the client needs to connect to the database, only the service name is provided. You can establish a connection between the client and the server.

Second, dynamic registration

Dynamic registration is when the instance is started Pmon the process dynamically registers instances and services into listener according to the Instance_name,service_names two parameters in Init.ora.

First you specify the values of the Instance_name,service_names two parameters in Init.ora. The values of these two parameters can be viewed under sqlplus by the show parameter Service_names, and the parameter instance_name.

The instance value registered to the listener is obtained from the instance_name parameter in the Init.ora file. If the parameter is not set, it takes the value of the db_name in the Init.ora file. If configured in RAC, you must set the instance_name parameter of each instance in the cluster to a unique value.

The service value registered to the listener is obtained from the parameter Service_names in the Init.ora file. If the parameter is not set, the database will splice the values of db_name and Db_domain in the Init.ora file to register itself. If you choose to provide a service_names value, you can use a fully qualified name (such as a orcl.oracle.com) or an abbreviated name (such as ORCL). If you select an abbreviated name and set the Db_domain parameter, the service registered to the listener will be a concatenation of the service_name value and the Db_domain value. For example, the following settings will cause the service orcl.oracle.com to be registered in the listener:

Db_domain=oracle.com
SERVICE_NAMES=ORCL;

When a dynamic registration method is adopted, the contents of the Listener.ora are as follows:

Sid_list_listener =
(sid_list = (
Sid_desc =
(sid_name = Plsextproc)
(oracle_home = d:/oracle/product/ 10.2.0/db_1)
(program = extproc)
)


Optionally, you can specify multiple service values in the Service_names parameter, with commas between the values, which is useful for shared server configuration.

Dynamic registration By default only registers to the default listener (name is listener, port is 1521, protocol is TCP), because Pmon only dynamically registers the port equals 1521 listens, otherwise Pmon cannot dynamically register listener, if needs to not the default listens for registration, You need to configure the Local_listener parameter!

Adds the listening information to the Tnsnames.ora file. Note that this is the Tnsnames.ora file because Pmon reads the information from the Tnsnames.ora when it is dynamically registering for listening.

LISTENER =
(DESCRIPTION = (Address
= (PROTOCOL = TCP) (HOST = Davedai) (PORT = 1522))

Then run with the SYS user:

Sql> alter system set Local_listener=listener;
Sql> alter system register;

Or:

Sql> alter system set local_listener= ' (address = (PROTOCOL = TCP) (HOST = Davedai) (PORT = 1522)) ';
Sql> alter system register;

The system has changed.

$LSNRCTL Status Listener

If the values for Service_names and instance_name are not explicitly set, dynamic registration occurs only if the database is started after the listener is run, in which case the dynamic registration information will be lost if the listener subsequently restarts. Obviously, it is best to start the listener before all databases are started, so that you avoid the loss of dynamic registration information that is caused by restarting the listener without explicitly setting the values for Service_names and instance_name.

It is a good practice to set explicit values for initialization parameters Service_names and instance_name, although if you do not set them, Oracle generates default values (based on db_name and Db_main) for dynamic registration. The reason for this is that if the listener restarts after the database is started, there will be subtle differences in their dynamic registration behavior. If the listener restarts after the database is run, you can only explicitly set the Service_names and Instance_ in the Init.ora file Name, the Pmon process for each database automatically registers the database after a short period of time.

If you need to perform a connection with failover or load balancing, or if you want to configure a transparent distribution of connections between instances in the RAC, then using the Service_names parameter will be necessary. To enable these features, you only need to set the Service_names in the database parameter file for each instance to the same value and reference the value in the Service_Name setting of the client connection request.

If the values for Service_names and instance_name are not explicitly set, dynamic registration occurs only if the database is started after the listener is run, in which case the dynamic registration information will be lost if the listener subsequently restarts. Obviously, the listener on the server is finally started before any database is started, and the listener reboot is completely avoided.

In addition, you can use commands in Sql*plus:

Sql>alter SYSTEM REGISTER;

At any time when the database is open, the hand site registers the service value with the listener. This command is useful for replacing a service value that is lost because of a listener reboot, and its registered value is exactly the same as the value set by dynamic registration when the database is started.

Dynamic monitoring:

Once an Oracle listener is running, the Oracle instance dynamically registers its service_names and instance_name with the listener when it is open.

Where instance_name default is: db_name

and service_names default is: Db_name.db_domain

Third, static registration

Static registration is the configuration that reads the Listener.ora file when the instance is started, registering the instance and service to the listener. Whenever you start a database, two messages are registered to the listener by default: the instance and service corresponding to the database server.

When statically registered, the Global_dbname in Listener.ora provides the service name, and the Sid_name in Listener.ora provides the registered instance name.
When a static registration method is adopted, the contents of the Listener.ora are as follows:

Sid_list_listener =
(sid_list = (
Sid_desc =
(sid_name = Plsextproc)
(oracle_home = d:/oracle/product/ 10.2.0/db_1) (Program
= extproc)
)
(Sid_desc =
(global_dbname =orcl)
(oracle_home = d:/oracle/ product/10.2.0/db_1) (
sid_name =ORCL)
)
(Sid_desc =
(global_dbname =orcl1)
(Oracle_home = d:/oracle/product/10.2.0/db_1)
(sid_name =orcl)
)

This file indicates that the database is single-instance, with an instance named ORCL, providing two services outside: ORCL and ORCL1

Static monitoring:

When the Oracle instance is running, the listener starts by registering the appropriate service according to the Listener.ora configuration.

Where Global_dbname corresponds to Oracle's external service name, which is service_names in initialization parameters.

And sid_name corresponds to the name of the Oralce instance, that is, the instance_name in the initialization parameter

Since there is dynamic monitoring why still need static monitoring? The reasons are as follows:

1. The listener is not the first boot, the Oracle instance starts first

2. Listener reboot

3.oracle instance without open

Four, query a service is static registration or dynamic registration

You can use the command Lsnrctl status to see whether a service is statically registered or dynamically registered.

The instance state is a unknown value indicating that the service is a statically registered setting. When the listener is used to indicate that it does not know any information about the instance, it checks that the instance exists only if the client issues a connection request.

Dynamically registered databases are indicated by state ready or state blocked (for an alternate database) in state information. Regardless of when the database is closed, the dynamically registered database is dynamically logged off from the listener, and the information associated with it disappears from the status list. This way, the listener always knows its state, regardless of whether the database is running or closed. This information will be used for the fallback (fallback) and load balancing of the connection request.

Related Article

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.