It is a parameter that points to the listener running on the local server.
What is the purpose of the local_listener parameter?
It is used for dynamic listener registration, which is the process of the database contacting the listener and registrering the services it offers automatically.
How is the database registering its services with the listener?
From Oracle 12c and onwards, this registration process is handled by the LREG process.
The lreg process is easy to spot from the operating system:
ps -fu oracle |grep lreg oracle 22023 1 0 Sep19 ? 00:00:30 ora_lreg_cdbHow is dynamic listener registration implemented?
Start the listener process with or without a parameter file. If you do not have a listener.ora parameter file, the listener will run using default values.
In either case, simply start the listener process by typing
lsnrctl startAfter a little while (usually within a minute) the database has registered its services with the listener.
You you do not want to wait, you can manually force a registration by logging onto the database as a dba and issue:
alter system register;How will the database find the listener process?
This is where the local_listener parameter comes in. It tells the database where to find it, and which port to use.
The value of my local_listener parameter is:
SYS@cdb>SQL>show parameter local NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string LISTENER_CDB
My $TNS_ADMIN/tnsnames.ora file has an entry that matches the value LISTENER_CDB:
LISTENER_CDB = (ADDRESS = (PROTOCOL = TCP)(HOST = testserver1.oric.no)(PORT = 1521))This makes it possible for the database to register its services with the listener.
Even if the local_listener is not set at all, dynamic registeration would still work if your listener runs with the default values, which is
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) where hostname is the network name of the local host.How does the database know which services that should be registered with the listener?
It will start to listen for services listed in the v$active_services view.
How does the local_listener parameter work under the multitenant architecture?
The local_listener works identically in both non-CDB and a multitenant database.
However, in a multitenant setup, remember that each pdb will have its own corresponding service.
This service you cannot stop unless you unplugg or shutdown your pdb.
If you attempt to stop the service of a running pdb you will receive
ORA-44793: cannot stop internal servicesAny other services created after this point can be stopped and started at will, and the listener will follow suit.
Let's see how it works:
First, list the services currently supported by the listener:
Services Summary... Service "cdb.oric.no" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service... Service "cdbXDB.oric.no" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service... Service "sales.oric.no" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service... The command completed successfullyThe listener supports the services for the root container ("cdb") and the pdb ("sales").
Let's try to create and start a new service in my pdb called "sales":
SQL> alter session set container=sales; Session altered. SQL> exec dbms_service.create_service(service_name=>'online_users', network_name=>'online_users'); PL/SQL procedure successfully completed. SQL> exec dbms_service.start_service('online_users'); PL/SQL procedure successfully completed.List the services supported by the listener now:
Services Summary...
Service "cdb.oric.no" has 1 instance(s).
Instance "cdb", status READY, has 1 handler(s) for this service...
Service "cdbXDB.oric.no" has 1 instance(s).
Instance "cdb", status READY, has 1 handler(s) for this service...
Service "online_users.oric.no" has 1 instance(s).
Instance "cdb", status READY, has 1 handler(s) for this service...
Service "sales.oric.no" has 1 instance(s).
Instance "cdb", status READY, has 1 handler(s) for this service...
For automatic restart of Pluggable databases and their services, please see this post.
Documentation: