Dynamic Listener in Oracle with Examples
In this article, I am going to discuss Dynamic Listener in Oracle with Examples. Please read our previous article where we discussed Non-Default Port in Oracle with Examples.
Dynamic Listener in Oracle
Now, we will learn how to create a new dynamic listener. We can create as many as listeners we require. In order to create a new listener, we have to create follow steps.
Step 1: Create a new entry in tnsnames.ora
Go to the path where tnsnames.ora and listener.ora files are present.
Open the file tnsnames.ora. There will be many entries in the tnsnames.ora. We have to select the local_listener entry and copy that entry.
We have selected the entry LISTENER_JAYADB entry which is local_listener. Copy that entry and paste the entry above the LISTENER_JAYADB entry and make changes to that entry. I have changed the listener’s name to LISTENER19c and the port number is changed to 1527. You can change to any name and any port number as well.
We are creating another listener-to-listener from another port. Save the file after making changes.
Step 2: Make changes in listener.ora
As we had made changes in tnsnames.ora file with the LISTENER19c name. We have to add that entry to the listener.ora file as well. Let’s go ahead and open the listener.ora file.
We have selected the default listener entry. Copy that listener entry and paste it above the listener entry and make changes to it. We have to change the listener name to LISTENER19c and then change the port number to 1521.
Once the changes are done you can remove the DESCRIPTION_LIST, IPC protocol entry, and parenthesis for that entry. Make sure that it looks like LISTENER19c. Once all changes are done save the file. We have defined a new listener LISTENER19c with port number 1527.
Step 3: Add a new listener to local_listener in the database.
Connect to the database as “sqlplus / as sysdba”. Once the database is connected check for parameter local_listener using the command “show parameter local”.
We can see the parameter local_listener is having the value of LISTENER_JAYADB. We have to add our new listener value to that local_listener. So, we will have two local_listeners. Use the below command to add the new entry.
Command: alter system set local_listener =”LISTENER_JAYADB,LISTENER19C”;
Now, that we have added the entry let us go ahead and check the parameter again.
Command: show parameter local
Step 4: Start the new listener.
Connect to lsnrctl console.
We have to start our new listener LISTENER19c. Generally, we will start the listener start in the lsnrctl console. But here we have to mention the listener name. So, we will be using the command “start LISTENER19C”.
The listener is started. We can see from the description it is showing the port number is 1527 and the listener’s name is LISTENER19c. All the services are registered to the listener as well.
Step 5: Easy connect to the database using a new listener.
Connect to the database as sqlplus / as sysdba. Once connected we will try to connect to the database using the new port number 1527.
Command: connect email@example.com:1527/jayadb.com
Let us try the same with the old port number 1521.
Command: connect firstname.lastname@example.org:1521/jayadb.com
Step 6: Connection test using SQL developer.
Open SQL Developer and connect to the database using port 1527.
We can see success with port number 1527. Let us go ahead and check the connection with port number 1521 as well.
We can see the connection using port number 1521 is also successful. So, we understood that we can have multiple listeners connecting to the same database by the Dynamic Listener concept. We have learned how to create a new dynamic listener and connect to the dynamic listener using the easy connect method and using the SQL developer.
In the next article, I am going to discuss Static Listener in Oracle with Examples. Here, in this article, I try to explain Dynamic Listener in Oracle with Examples and I hope you enjoy this Dynamic Listener in Oracle article.