Oracle Database — Create a custom Listener and register it to a PDB in Oracle Database 19.3c

Kalana Eranda Jayasuriya
Level Up Coding
Published in
5 min readNov 5, 2020

--

In a previous story, we have covered creating CDB and PDBs.

  1. Part 1Install Oracle Database 19.3c on CentOS 7 -: https://kalanaejayasuriya.medium.com/install-oracle-database-19-3c-on-centos-7-52036876436
  2. Part 2Oracle Database 19.3c — Multitenant Architecture, Create CDB and PDB -: https://kalanaejayasuriya.medium.com/oracle-database-multitenant-architecture-create-cdb-and-pdb-4a9bb954803b

In this part, I am going to talk about listeners and how we register PDB with a listener. Before we begin let us talk about listeners.

What is a listener in oracle?

If we simply explain, a Listener is the middleware between the user and the servers.

If we discuss in advance, Listener is a server-side process that can listen to incoming requests from client side and manage traffic to the database.

Without a Listener, client cannot communicates with the server.

Also, one listener can listen to one or more than databases and one database can listen by one or more than databases.

Functions of listener

To establish a connection using listener; listener needs complete below requirements.

  1. Host -: the place that the listener is running.
  2. Port -: listener is monitoring by using this.
  3. Protocol -: method that the listener is using.
  4. Name of the service -: place that the listener is handling.

By studying above, I think you have gotten some knowledge of the listener. Not let us talk about how to create a listener manually in Oracle databases. In the previous part, we did not create a listener because later, there can be multiple errors occurred.

Step 1 -: navigate to the “database/bin” and there is a file called “netca”. By executing it we can open the network wizard.

Step 2 -: to execute “netca”, we have to use terminal. Study below image. Click next

Step 3 -: In the next step, we have to give a name to our listener. In my case, I have named it as “LISTENER_TST”.

Step 4 -: now we have to set a port number to our listener. We can setup the default port number which is 1521. But in this case, let us try out a custom port number. Therefor select “Use another port number:” and enter “1522” as the custom port number.

Step 5 -: now the listener creation task is over. Then we can try out whether listener is working or not. Therefore, open the terminal and type “lsnrctl start LISTENER_TST”. That command will start your custom listener. You will see end of the image “The listener supports no services”. This happens because we did not register ani PDB with our listener.

Step 6 -: to stop the listener type “lsnrctl stop LISTENER_TST”.

Now we configured our custom listener. The next step is registering our PDB with our listener. Unless the client cannot make a connection with the server.

Register PDB with the listener

Step 1 -: First, we have to startup our instance. Type “sqlplus / as sysdba”.

Step 2 -: open PDB that you created in the dbca wizard called “PDBTEST”.

Step 3 -: now define our custom listener and register to the instance. Our custom listener is “LISTENER_TST”.

You can see I have underlined the host because host is not same in every system. Therefore, you must find your own hostname. For that, open another terminal and try out these commands.

  1. hostname
  2. hostnamectl
  3. cat /proc/sys/kernel/hostname

Step 4 -: now you have registered your PDB with the listener. But, to apply changes, you must close your PDB and open it again. After that, you can exit from sqlplus. Remember do not shut down your instance.

Step 5 -: now you can start your listener again by typing “lsnrctl start LISTENER_TST”.

Step 6 -: now check the status of listener to make sure whether our PDB is registered or not. To check the status type “lsnrctl status LISTENER_TST”.

You can see our PDBTEST is registered. Likewise, following from tutorial one to tutorial three you can create multiple PDBs, Listeners in anytime. I hope my tutorials will helpful your studies. I will see you with another tutorial soon. Thank you!

--

--

Software Engineer at Kodez | Former Research Analyst at CoinGuru | Specialize in Data Science