Oracle Database TNS, oracletns

Source: Internet
Author: User

Oracle Database TNS, oracletns

TNS is a part of Oracle Net. It is a tool used to manage and configure the connection between the Oracle database and the client. In most cases, to communicate with the database, TNS must be configured, let's take a look at how to configure it:

Brief introduction and application of TNS:
The complete definition of TNS in Oracle: the bottom layer of the transparence Network Substrate transparent Network. The Listener service is an important part of it, not all of which should not regard TNS as just a listener.
TNS is a part of Oracle Net. It is a tool used to manage and configure the connection between the Oracle database and the client. In most cases, to communicate with the database, TNS must be configured, of course, in a few cases, you can connect to the Oracle database without configuring TNS, such as through JDBC. If you use TNS to connect to Oracle, the Oracle client must be installed on the client.

In Oracle, if you want to access a SERVER, you must set TNS. Unlike SQL SERVER, TNS automatically lists all online servers in the LAN on the client. You only need to select the desired SERVER on the client, then, log on with your account and password. However, Oracle cannot automatically list servers in the network. You must read the TNS configuration file to list the configured server names.
The configuration file name is generally tnsnames. ora, and the default path is % ORACLE_HOME % \ network \ admin \ tnsnames. ora.

The CGDB and STDCG in are the corresponding TNS, and the HOST is the IP address of the database server. Of course, the computer name in the LAN can also be used. When creating a connection service connected to the database server through the client Net Manager, a TNS content is added to the tnsnames. ora file.
Detailed configuration file of TNS
The TNS configuration file consists of the server and client. The server has a listener. ora, sqlnet. ora and tnsnames. ora. If you connect to the Domain Name Service management client through OCM (Oracle Connection Manage), the server may also include cman. ora and other files; the client has tnsnames. ora, sqlnet. ora. Default path of all the TNS configuration files in Oracle: % ORACLE_HOME % \ network \ admin
Listener. ora: listener Configuration File. After the listener is successfully started, it is a service that resides on the server. A listener is a service program used to listen for client connection requests and establish a connection channel between the client and the server. By default, Oracle listens for client connection requests on port 1521.
Sqlnet. ora: used to manage and restrict the configuration of tns connections. You can manage TNS connections by setting some parameters in this file. The parameters must be configured on the server and client, respectively ..
Tnsnames. ora: configure the Connection Service from the client to the server, including the configuration information of the server and database to which the client connects.
TNS Configuration
You can configure TNS through Oracle Net Configuretion Assitant or manually. After the installation on the Oracle server is complete, configure LISTENER first. LISTENER is the primary component for Oracle communication. Then, install the Oracle client on the client and configure the tnsnames. ora file.
The LISTENER includes two parts: the address, port, and communication protocol to be listened on by Oracle; the database instance to be listened on by Oracle. In non-RAC environments, the LISTENER can only listen on the address and instance of the current server, in the RAC environment, LISTENER can also listen to remote servers. Each database must have at least one listener. (Note: The RAC environment refers to the Environment configured by the Oracle server cluster)

The LISTENER part is configured with the address and port information to be listened to by Oracle. This file also contains the SID_LIST_LISTENER part, which is configured with the instance to be listened to by Oracle. (Note: There is no SID_LIST_LISTENER in the above section. This is because the dynamic listener service registration is introduced in Oracle 9i. When the database is started, it automatically registers the current database instance to the listener list, therefore, you do not need to configure the SID_LIST_LISTENER part)
The HOST parameter can be an Oracle server HOST name or an IP address. On a server with multiple IP addresses, you can configure listener to listen to multiple addresses at the same time. For example, the following configuration: LISTENER = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = tcp) (HOST = (PORT = 1521) (ADDRESS = (PROTOCOL = tcp) (HOST = (PORT = 1521), or you can configure multiple listeners, listen for different IP addresses.
Generally, the TNS configuration is the configuration of the tnsnames. ora file. tnsnames. ora has client configuration and server configuration. The difference between client and server configuration is that the server configuration is related to the LISTENER Configuration. The following is a simple configuration example:

Tnsnames. ora also includes two parts. ADDRESS_LIST contains information about the listening address of the Oracle database server, that is, to tell the TNS database to communicate with the CLIENT through this address; CONNECT_DATA defines the database to be connected by the CLIENT, and the connection mode of the database (dedicated or shared ).
In a multi-IP environment, TNS can also configure multiple remote IP addresses: CGDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = (PORT = 1521) (ADDRESS = (PROTOCOL = TCP) (HOST = (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = CGDB) (SERVER = DEDICATED )))
Sqlnet. ora is a very important configuration. It can control and manage the attributes of Oracle connections, and decide whether to configure it on the client or on the server based on the parameter. Sqlnet. the configuration of ora is global, that is, sqlnet. the configuration of ora works for all connections. to restrict or restrict a special connection or service, you can configure the corresponding parameters in TNS.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.