Back to: Oracle DBA Tutorials
Non-Default Port in Oracle with Examples
In this article, I am going to discuss the Non-Default Port in Oracle with Examples. Please read our previous article where we discussed Default Listener Examples in Oracle.
Non-Default Port in Oracle
Previously we have learned about local_listener. We learned that local_listener and listener.ora are not necessary in case we are using the default port number and the default protocol. Now, the listener.ora is very important if we are using the non-default port i.e. another port. Previously we have changed the name of listener.ora to abclistener.ora. Let us change the name back to the original.
Now, we will try to learn to change the port number from 1521 i.e. default port number to 1529.
Save the file. After making changes to the listener file let us go ahead and restart the listener file.
We can see the listener parameter file is mentioned in the status of the listener which indicates the listener is considering the listener.ora file as the name is back to the original. In the description as also the port number is mentioned as 1529.
We can see only one service because the LREG cannot register all the services. Even if we wait for 60 seconds, we will find only this service. If we want to register all the services, we have to make more changes. Let us try that as well. Let us connect to the database and register all the services.
Command: alter system register;
Now, that the LREG registered all the services, let us check the status of the listener.
We do not find all the services like before. In order to do that we have to change the port number in tnsnames.ora file as well. Open the tnsnames.ora file and change the port number in all entries and change it from 1521 to 1529. Let us go ahead and change the port number in tnsnames.ora file.
Even after changing the entries in tnsnames.ora file, we have too few more left to do. Let us connect to the database again and register the local listener again to save the changes. This is because whenever we make any changes to tnsnames.ora file and especially if we make any changes to the local listener file then we have to register the local listener again at the database level.
So, we have to register the local_listener with the same LISTENER_JAYADB. Let us go ahead and do that again.
Now, that we have made the necessary changes to the listener. Let us go ahead and restart the listener and check if we can register all the services to the listener.
Stop the listener.
Start the listener again.
Let us wait for 60 seconds and let’s check the status of the listener again.
All the services are registered to the listener and the port number is 1529. Now, that all the services are registered let us check the connectivity of the database using SQL developer. First, let us check with the old port number and see if we get any errors. Open SQL Developer and connect to the database as a sys user, and below are other details, and test the connection.
From the image, we can see there is an error saying “Failure- Test failed: Listener refused the connection with the following error: ORA- 12505: TNS listener does not currently…”. Let us change the value of the port number to 1529 and check the connection again.
We can see the status of the connection is successful as we have given the port number as 1529. Let us go ahead and change the value of the port number back to the original.
Listener.ora:
Tnsnames.ora:
So, we have made changes to the tnsnames.ora. Let us go ahead and register the local_listener again.
Command: alter system set local_listener=LISTENER_JAYADB;
Now, that we have made changes to the local_listener and listener files. Let us restart the listener.
Start the listener:
Let’s wait for 60 seconds and check whether the listener again whether it has registered all the services or not.
We can see all the services are registered to the listener. So, we have discussed how to work using the non-default port by changing the port number. We can use a different port number for different versions of the database.
In the next article, I am going to discuss Dynamic Listener in Oracle with Examples. Here, in this article, I try to explain the Non-Default Port in Oracle with Examples and I hope you enjoy this Non-Default Port in Oracle with Examples article.