Oracle TNS Brief
What is TNS?
TNS is part of Oracle NET, dedicated to managing and configuring Oracle databases and client connections, and in most cases the client and the database must be configured with TNS, and of course, in a few cases, the Oracle database can be connected without having to configure TNS. For example, through JDBC. If Oracle is connected through TNS, then the client must install the Oracle client program.
What are the configuration files for TNS?
The TNS profile includes both the server (the machine that installs the Oracle database) and the client side. Server has Listener.ora,sqlnet.ora,tnsnames.ora if passed OCM (Oracle Connection Manage) and Domain Name Service Management client connection, server side may also include files such as Cman.ora, the client has Tnsnames.ora,sqlnet.ora.
Listener.ora: Listener profile, which is a service that resides on the server side after successful startup. What is a listener? A listener is a service program that listens for connection requests from clients and establishes client and server-side connection channels. By default, Oracle listens for database connection requests on port 1521.
Sqlnet.ora: Used to manage and constrain or restrict the configuration of TNS connections, you can manage TNS connections by setting some parameters in the file. Depending on the function of the parameter, it is necessary to configure the server and client separately.
Tnsnames.ora: Configure client to server-side connection services, including configuration information for the server and database to which the client is connected.
All of the TNS profiles for Oracle are stored in
Unix/linux: $ORACLE _home/network/admin
Windows:%oracle_home%/network/admin
What configuration tools does TNS have?
We can configure it manually or through the Oracle Net configuretion assitant configuration.
Oracletns configuration Process
First, after the Oracle server-side installation is complete, the first step in configuring Listener,listenerr is the primary component of Oracle Communications, followed by the installation of Oracle client on the client and the configuration of Tnsnames.ora files.
LISTENER (Listener) configuration
First the listener consists of two parts: the address, port, communication protocol that Oracle listens to, and the database instance that Oracle listens to. Non-RAC environment, listener can only listen to the address and instance of this server, in the RAC Environment, Listener can also listen to remote servers. At least one listener is configured 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 part is configured with the address information that Oracle will listen to; The Sid_list_listener section is configured with instances where Oracle needs to listen.
The host parameter can be either a hostname or an IP address. On a multiple-IP server, you can configure listener to listen for 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))
)
Or you can configure multiple listeners to listen separately for different IP addresses.
The communication protocols for Oracle NET support are:
TCP/IP
TCP/IP with SSL
Named Pipes
Sdporacle 9i introduced dynamic listening service registration, which means that we do not need to configure Oracle to listen to the database instance information in Listener.ora, when the database is started, The Pmon process can automatically register the current database instance to the Listener listener list. That is to say, the sid_list_listener part of the above is not configured. The following conditions must be met to use the dynamic listener server side:
The database must set instance_name and service_name parameters;
The listener uses the default TCP protocol and uses 1521 ports for listening;
If other communication protocols or listening ports are used when configuring the listener, make the following settings to tell Oracle to adopt a custom listener:
1, through the Local_listener parameter explicitly set the current use of the listener,
2, in the server-side Tnsnames.ora file to add custom listener configuration information. If you use OCM, you can also add the configuration information for the listener in Cman.ora.
. Local_listener can be set dynamically through alter system.
ALTER SYSTEM SET local_listener= ' Listener_alias '; an example of a dynamic listening configuration:
Configuration of Listener.ora Files:
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))
)
The configuration of the Local_listener parameter (because it uses a port that is not 1521):
Sql> Show Parameter Local_listener
name type VALUE
-----------------------------------------------------------
local_listener string Listener1tnsnames.ora Configuration:
listener1=
(address_list=
(address = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421) (IP = i)
& nbsp (address = (PROTOCOL = TCP) (HOST = 192.168.205.73) (PORT = 1421))
(address = (PROTOCOL = TCP) (HOST = 192.168.200.64) (PORT = 1421))
)
Mayp =
(DESCRIPTION =< br> (address_list =
(address = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421))
(address = (PROTOCOL = TCP) (HOST = 192.168.200.64) (PORT = 1421))
& nbsp; )
(connect_data =
(service_name = MAYP)
(SERVER = dedicated)
)
) TNS configuration
The TNS configuration we are talking about 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 listener configuration. The following is a simple configuration example:
Mayp =
(DESCRIPTION =
(address_list =
address = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421))
)
(connect_data =
(service_name = MAYP)
(SERVER = dedicated)
)
Tnsnames.ora also includes two parts, address_list The part contains the remote database server's listening address information, which is to tell TNS that the remote database can be communicated by some address and client; Connect_data defines the database to which the client will connect, as well as how the database is connected (private or shared). In a multiple-IP environment, TNS can also configure multiple remote IP addresses:
Mayp =
(DESCRIPTION =
(address_list =
address = (PROTOCOL = TCP) (HOST = dbtest) (PORT = 1421))
(address = (PROTOCOL = TCP) (HOST = 192.168.200.64) (PORT = 1421))
)
(connect_data =
(service_name = MAYP)
(SERVER = dedicated)
)
) typically in a multiple-IP environment, you can also configure Load_ at the TNS end Balance and failover characteristics. These features are more prevalent in the RAC environment, and the Load_balance feature allows the client to connect in the connection database by selecting any address, which is the connection balance of each address. Failover open Oracle-specific TAF features , TAF is the abbreviation for transparent application failover. Load_balance can be configured either on the client or on the server side. The following is an example of a client configuration:
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_data =
(SERVER = dedicated)
(service_name = MAYP)
(Failover_mode =
(TYPE = SELECT)
(method = BASIC)
)
)
) Configuration of Sqlnet.ora
Sqlnet.ora is an important configuration that allows you to control and manage the properties of the Oracle connection, depending on whether the parameters are configured at the client or server-side. The Sqlnet.ora configuration is global, It is also said that the configuration of Sqlnet.ora is useful for all connections, and if you want to constrain or restrict a particular connection or service, you can configure the corresponding parameters in TNS. Detailed parameters can be referred to:
Oracle®database Net Services Reference