First, overview:
Oracle Registration is the registration of the database as a service to the listener. The client does not need to know the name of the database and the instance name, just know the name of the service provided by the database can request to connect to this 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 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, 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:oracleproduct 10.2.0db_1) (Program
= extproc)
)
(Sid_desc =
(global_dbname =orcl)
(oracle_home = D:oraclep roduct10.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 single-instance, with an instance named ORCL, providing two services outside: ORCL and ORCL1
Third, 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.
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 adopting dynamic registration method, the contents of Listener.ora are as follows:
Sid_list_listener =
(sid_list = (
Sid_desc =
(Sid_name = plsextproc) c7/> (oracle_home = d:oracleproduct10.2.0db_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 defaults to the default listener only (name is listener, port is 1521, protocol is TCP), you need to configure Local_listener parameters if you need to register with a Non-default 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.
Setting explicit values for initialization parameters Service_names and instance_name is a desirable method and recommendation. Because if the listener restarts during the database run, the Pmon process for each database will complete dynamic registration in a very short time only if you explicitly set the Service_names and instance_name values in the Init.ora file.
Four, query a service is static registration or dynamic registration method:
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.