Oracle uses three files listener.ora, tnsnames.ora & sqlnet.ora for network configuration.
listener.ora
Listener is used to listen to network requests to connect and pass them on to the instance. Any Remote connection to the database instance are established by the listener. Single listener can connect to multiple instances, and a single instance can be connected by multiple listeners.
The “listerner.ora” file contains server side network configuration parameters.
- Location: $ORACLE_HOME/network/admin
- Default name for the listener is “LISTENER”.
- Default port for TCP listening is 1521.
- HOST parameter is the server name or IP address of the server.
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) (ADDRESS = (PROTOCOL = TCP)(HOST = serv.exp.com)(PORT = 1521)) ) )
Stop-Start listener service:
$ lsnrctl stop $ lsnrctl start $ lsnrctl reload
Listener Registration:
The process in which the listener gets to know the instance with which it is connecting is called registration. This can be done in two ways Static registration and Dynamic registration.
(i) Static listener registration: Static listener configuration is done in the listener.ora file by updating instance details. File is divided in two parts, one starts with the listener name, host and port number. The other starts with SID_LIST_ which includes information about the static registration.
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) (ADDRESS = (PROTOCOL = TCP)(HOST = serv.exp.com)(PORT = 1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = TEST) (ORACLE_HOME = /u01/app/oracle/product/12.0.1/dbhome_1) (SID_NAME = TEST) ) )
(ii) Dynamic listener registration: Dynamic registration is performed by PMON process with the ssociated listener. Dynamic registration does not require any manual configuration in the listener.ora file.
Set the LOCAL_LISTENER parameter in the init.ora or spfile of the instance.
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST= serv.exp.com)(PORT=1521)))’; System altered. SQL> alter system register; System altered.
tnsnames.ora
The “tnsnames.ora” file contains client side network configuration parameters. This file will also be present on the server if client style connections are used on the server itself.
- Location: $ORACLE_HOME/network/admin
- SERVICE_NAME is the database name.
- Port number will be same at which the database instance is registered in listener.ora file.
- HOST parameter is the server name or IP address of the server.
TEST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = serv.exp.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = TEST) ) )
sqlnet.ora
The “sqlnet.ora” file contains client side network configuration parameters. This file will also be present on the server if some additional server connection configuration is required.
- Location: $ORACLE_HOME/network/admin
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME) NAMES.DEFAULT_DOMAIN = exp.com # The following entry is necessary on Windows if OS authentication is required. SQLNET.AUTHENTICATION_SERVICES= (NTS)