1. What is TNS?
TNS is part of Oracle NET, a tool dedicated to managing and configuring Oracle Database and client connections, and in most cases the client and database must be configured for TNS, but in rare cases, you can connect to an Oracle database without having to configure TNS. For example, through JDBC. If you connect to Oracle through TNS, the client must install the Oracle clients program.
2. What are the configuration files for TNS?
The TNS profile includes both the server (the machine where the Oracle database is installed) and the client side. The server has Listener.ora,sqlnet.ora,tnsnames.ora if OCM (Oracle Connection Manage) and the Domain Name Service Management client connection, the server side may also include Cman.ora and other files; the client has Tnsnames.ora,sqlnet.ora.
Listener.ora: Listener profile, after successful startup, is a service that resides on the server side. What is a listener? A listener is a service program that listens for client connection requests and establishes client and server-side connection channels. By default, Oracle listens for database connection requests on port 1521.
Sqlnet.ora: A configuration used to manage and constrain or restrict TNS connections, which can be managed by setting some parameters in the file. Depending on the parameters, you need to configure the server and client separately.
Tnsnames.ora: Configure client-to-server connection services, including configuration information for the server and database to which the client is connecting.
3. Where all of the TNS configuration files are stored in Oracle
Unix/linux: $ORACLE _home/network/admin
Windows:%oracle_home%\network\admin
4. What are the configuration tools for TNS?
We can configure it manually or through the Oracle Net configuretion assitant.
5. Oracletns Configuration Process
First, after the Oracle server-side installation is complete, the first step is to configure Listener,listenerr to be the primary component for Oracle Communications, followed by installing the Oracle client on clients and configuring the Tnsnames.ora file.
LISTENER (Listener) configuration:
The listener consists of two parts: the address, port, and communication protocol to be monitored by Oracle; the DB instance to which Oracle listens. Listener can only listen to the address and instance of the server in a non-RAC environment, Listener can also listen to remote servers. Configure at least one listener per database.
Listener= (description= (address_list=) (address= (PROTOCOL=TCP) (Host=sales-server) (port=1521) ) ( Address= (PROTOCOL=IPC) (Key=extproc))) sid_list_listener= (sid_list= (sid_desc= ( sid_name= Plsextproc) ( oracle_home=/oracle10g) ( program=extproc) ) (sid_desc= (SID_NAME=MAYP) (oracle_home=/oracle10g) ) )
The listener section configures the address information that Oracle listens to; The Sid_list_listener section configures the instances that Oracle needs to listen on. The host parameter can be either hostname or an IP address. On a multi-IP server, 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=192.168.0.10) (port=1521) ) ( Address= (PROTOCOL=TCP) (host=192.168.2.1) (port=1521))))
Alternatively, you can configure multiple listeners to listen to different IP addresses, respectively.
The communication protocols supported by Oracle NET are:
TCP/IP
TCP/IP with SSL
Named Pipes
Sdporacle 9i introduces the dynamic Monitoring service registration, which means that we do not need to configure the database instance information that Oracle listens to in Listener.ora, when the database is started, The Pmon process can automatically register the current DB instance to the Listener listener list. That is to say, the sid_list_listener part above is not configured. The following conditions must be met to use the dynamic listener server side:
The database must have the instance_name and service_name parameters set;
The listener uses the default TCP protocol and listens with Port 1521;
If other communication protocols or listening ports are used when configuring the listener, the following settings are used to tell Oracle to adopt a custom listener:
The currently used listener is explicitly set by the Local_listener parameter,
The configuration information for the custom listener is added to the server-side Tnsnames.ora file. If OCM is used, the listener configuration information can also be added to the Cman.ora.
Local_listener can be set dynamically via the alter system.
ALTER SYSTEM SET local_listener= ' Listener_alias '; an example of a dynamic listener configuration:
6. TNS configuration File specific configuration
Configuration of the Listener.ora file:
LISTENER1 = (DESCRIPTION = ( address_list = ( ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.205.73) (PORT = 1421))
(address = (PROTOCOL = TCP) (HOST = 192.168.200.64) (PORT = 1421)) (address = (PROTOCOL = IPC) (KEY = Extproc)) ) c7/>)
TNS Configuration:
We say that the TNS configuration is actually the configuration of the Tnsnames.ora file, Tnsnames.ora has the client configuration, There is also a server-side configuration. The difference between client and server-side configuration is that the server-side configuration is related to the configuration of listener. Here is a simple configuration example:
MAYP = (DESCRIPTION = ( address_list = ( ADDRESS = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421)) (CON Nect_data = (service_name = MAYP) (SERVER = dedicated) )
The same tnsnames.ora also includes two parts, the Address_list section contains the remote database server listening address information, that is, to tell the TNS remote database through the address and client communication; Connect_data defines the database to which the client connects, as well as how the database is connected (private or shared).
In a multi-IP environment, TNS can also configure multiple remote IP addresses:
MAYP = (DESCRIPTION = ( address_list = ( ADDRESS = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421)) (Addre SS = (PROTOCOL = TCP) (HOST = 192.168.200.64) (PORT = 1421)) ) (Connect_data = (service_name = MAYP) (S erver = dedicated)))
Typically in a multi-IP environment, load_balance and failover features can also be configured on the TNS side. These features are popular in RAC environments, and the Load_balance feature allows the client to connect to any address in the connection database. is the connection equalization for each address. Failover opens the Oracle-specific TAF feature, TAF is the abbreviation for transparent application failover. Load_balance can be configured on the client or on the server side.
The following is a sample configuration for a client:
MAYP = (DESCRIPTION = ( address_list = (load_balance=on) (failover=on) ( ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.205.73) (port = 1421)) ( ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.200.64) (port = 1421)) (connect_d ATA = (SERVER = dedicated) ( service_name = MAYP) ( Failover_mode = (TYPE = SELECT) (METHOD = BASIC ) ) ))
Configuration of the Sqlnet.ora:
Sqlnet.ora is a very important configuration that can control and manage the properties of an Oracle connection, depending on whether the parameters are configured on the client or server side. The configuration of the Sqlnet.ora is global, It's also said that Sqlnet.ora is configured to function on all connections, and if you want to constrain or restrict a particular connection or service, you can configure the appropriate parameters in TNS. Detailed parameters can be consulted: oracle®database Net Services Reference
Analysis of Oracle TNS configuration