Explanation of Oracle Static Registration and Dynamic Registration

  • 2021-11-10 11:12:05
  • OfStack

1. Overview:

The registration of Oracle is to register the database as a service to the listener. The client does not need to know the database name and instance name, but only needs to know the service name provided by the database to apply for connection to the database. 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 corresponding service with the listener (whenever a database is started, by default, two pieces of information are registered to the listener: the instance corresponding to the database server and the service. )
It is equivalent to this: There is a listener (Listener) between the database server and the client. In the listener, the service name corresponding to the corresponding database will be recorded (one database may correspond to multiple service names). When the client needs to connect to the database, it only needs to provide the service name to establish the connection between the client and the server.

2. Static registration:

Static registration is the configuration that reads the listener. ora file when the instance starts, registering the instance and service to the listener. Whenever a database is started, two pieces of information are registered in the listener by default: the instance corresponding to the database server and the service.
In static registration, GLOBAL_DBNAME in listener. ora provides the service name, and SID_NAME in listener. ora provides the registered instance name.
When adopting the static registration method, the contents in listener. ora are as follows:


SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = D:oracleproduct10.2.0db_1)
    (PROGRAM = extproc)
    )
    (SID_DESC =
    (GLOBAL_DBNAME =orcl)
    (ORACLE_HOME = D:oracleproduct10.2.0db_1)
    (SID_NAME =orcl)
    )
    (SID_DESC =
    (GLOBAL_DBNAME =orcl1)
    (ORACLE_HOME = D:oracleproduct10.2.0db_1)
    (SID_NAME =orcl)
    )
    )

This file indicates that the database is a single instance named orcl and provides two services: orcl and orcl1

3. Dynamic registration:

Dynamic registration means that when instance is started, the PMON process dynamically registers instances and services into listener according to two parameters of instance_name and service_names in init. ora.
You first specify the values of the parameters instance_name and service_names in init. ora. The values of these two parameters can be viewed under sqlplus through show parameter service_names and show parameter instance_name.
The instance value registered in the listener is obtained from the instance_name parameter in the init. ora file. If there is no set value for this parameter, it takes the value of db_name in the init. ora file.
The value of the service registered in the listener is obtained from the parameter service_names in the init. ora file. If there is no set value for this parameter, the database registers itself by splicing the values of db_name and db_domain in the init. ora file. If you choose to provide the service_names value, you can use a fully qualified name (such as orcl. oracle. com) or an abbreviated name (such as orcl). If the abbreviated name is selected and the db_domain parameter is set, the service registered in the listener will be a splice 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 adopting the dynamic registration method, listener.ora The contents in: 
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = D:oracleproduct10.2.0db_1)
    (PROGRAM = extproc)
    )
    )

Alternatively, you can specify multiple service values in the service_names parameter, separated by commas, which is useful for shared server configuration.
Dynamic registration only registers on the default listener by default (name is LISTENER, port is 1521, protocol is TCP). If you need to register with a non-default listener, you need to configure the local_listener parameter!
If the values of service_names and instance_name are not explicitly set, dynamic registration occurs only when the database is started after the listener is running; In this case, if the listener is restarted later, the dynamic registration information will be lost. Obviously, it is best to start the listener before all databases are started, so as to avoid the loss of dynamic registration information if the listener is restarted without explicitly setting the values of service_names and instance_name.
Setting explicit values for the initialization parameters service_names and instance_name is a desirable approach and recommendation. Because if the listener is to be restarted while the database is running, the PMON process of each database will be dynamically registered in a short time only if you explicitly set the values of service_names and instance_name in the init. ora file.

4. Query whether a service is statically registered or dynamically registered:

You can use the command lsnrctl status to see if a service is statically or dynamically registered.
When the instance state is UNKNOWN value, it indicates that this service is a statically registered setting. The listener is used to indicate that it does not know anything about the instance and only checks if the instance exists when the client makes a connection request.
The dynamically registered database is indicated by either status READY or status BLOCKED (for 1 standby database) in the status information. Whenever the database is shut down, the dynamically registered database is dynamically logged out of the listener, and the information associated with it disappears from the status list. In this way, whether the database is running or closed, the listener always knows its status. This information will be used for connection request fallback (fallback) and load balancing.


Related articles: