To correctly configure the tnsname. ora file, you can use the Oracle Net Configuration Assistant or Oracle Net Manager graphical Configuration tool on the client machine to configure the client. The Configuration tool actually modifies the tnsnames. ora file. Therefore, we can directly modify the tnsnames. ora file. The following example uses directly modifying the tnsnames. ora file :... Networkadmintnsnames. ora (for windows )... /Network/admin/tnsnames. ora (for unix) Here, assuming the server name is testserver, the service name is orcl.testserver.com, and the listening port used is 1521, tnsnams. A test network service name (Database alias) in the ora file is:
test = (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=testserver)(PORT=1521)) ) (CONNECT_DATA=(SERVICE_NAME=orcl.testserver.com) ) )
PROTOCOL: the PROTOCOL for communications between the client and the server, which is generally TCP. HOST: The name or IP address of the machine on which the database listens. The database listens on the same machine as the database, so when I say that the machine where the database listens is generally the machine where the database is located. In UNIX or WINDOWS, you can use the hostname command at the command prompt of the machine on which the database listens, or use ipconfig (for WINDOWS) or ifconfig (for UNIX) command to obtain the IP address. Note that, whether using the machine name or IP address, you must ping the Host Name of the machine where the database is listening on the client, otherwise, the host name of the machine where the database listening is located must be added to the hosts file. PORT: the PORT on which the database listens. You can view the listener. ora file on the server or run the lnsrctl status [listener name] command at the command prompt on the machine where the database listens. The Port value must be the same as the Port on which the database listens. SERVICE_NAME: on the server side, run the "sqlplus> show parameter service_name" command after logging on to the system.