- Where to find tnsname.ora — Debian
- 2 Answers 2
- Tnsnames oracle где лежит linux
- 6.1 Overview of Local Naming Parameters
- 6.2 General Syntax of tnsnames.ora
- 6.3 Multiple Descriptions in tnsnames.ora
- 6.4 Multiple Address Lists in tnsnames.ora
- 6.5 Connect-Time Failover and Client Load Balancing with Oracle Connection Managers
- 6.6 Connect Descriptor Descriptions
- 6.6.1 DESCRIPTION
- 6.6.2 DESCRIPTION_LIST
- 6.7 Protocol Address Section
- 6.7.1 ADDRESS
Where to find tnsname.ora — Debian
In a Debian machine, I can use tnsping to identify a tnsname. But I can not found any tnsnames.ora in this machine. (nothing in $ORACLE_HOME/network/admin/ ) So, how can I find the tns name config file used by tnsping command ? Is there any command (similar with tnsping) to locate the tnsnames file? UPDATE: tnsping command result: Thanks in advance
2 Answers 2
There is no common location and different applications/drivers apply various search paths with different order and precedences.
Check following locations:
- $ORACLE_HOME/network/admin/
- Current directory of application
- $TNS_ADMIN (where TNS_ADMIN is environment variable settings)
Just for completeness in case of Windows check also
- Registry key HKLM\SOFTWARE\ORACLE\KEY_\TNS_ADMIN (for 64 bit)
- Registry key HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_\TNS_ADMIN (for 32 bit)
- .NET config file (i.e. machine.config and/or web.config )
In ideal case all of them should point to the same location, consider to create symbolic links if needed.
NB, maybe file tnsnames.ora simply does not exist. Create such file in location mentioned above.
Thanks for your answer. But in this machine $TNS_ADMIN is not config. I have to config $ORACLE_HOME and $PATH ; $LD_LIBRARY_PATH to run tnsping.
You tell us the tnsping is working. At my place the tnsping tool gives the exact location of the sqlnet.ora it is using. The tnsnames.ora should be in the same directory.
When your environment is correctly configured the tnsnames should be in the mentioned directory. When it does not exist you could try running the netca command and configure «Naming Methods configuration» and add a destination with «Locale Net Service Name configuration». This utility will create sqlnet.ora en tnsnames.ora in the default location.
[oracle@somedir]$ tnsping test TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 27-JUL-2016 22:00:24 Copyright (c) 1997, 2011, Oracle. All rights reserved. Used parameter files: /home/oracle/app/oracle/product/11.2.3/dbhome_1/network/admin/sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TEST))) OK (0 msec)
Tnsnames oracle где лежит linux
This chapter provides a complete listing of the tnsnames.ora file configuration parameters. This chapter contains the following topics:
- Overview of Local Naming Parameters
- General Syntax of tnsnames.ora
- Multiple Descriptions in tnsnames.ora
- Multiple Address Lists in tnsnames.ora
- Connect-Time Failover and Client Load Balancing with Oracle Connection Managers
- Connect Descriptor Descriptions
- Protocol Address Section
- Optional Parameters for Address Lists
- Connection Data Section
- Security Section
- Timeout Parameters
- Compression Parameters
6.1 Overview of Local Naming Parameters
The tnsnames.ora file is a configuration file that contains network service name s mapped to connect descriptor s for the local naming method, or net service names mapped to listener protocol addresses.
A net service name is an alias mapped to a database network address contained in a connect descriptor. A connect descriptor contains the location of the listener through a protocol address and the service name of the database to which to connect. Clients and database servers (that are clients of other database servers) use the net service name when making a connection with an application.
By default, the tnsnames.ora file is located in the ORACLE_HOME/network/admin directory. Oracle Net will check the other directories for the configuration file. For example, the order checking the tnsnames.ora file is as follows:
- The directory specified by the TNS_ADMIN environment variable. If the file is not found in the directory specified, then it is assumed that the file does not exist.
- If the TNS_ADMIN environment variable is not set, then Oracle Net checks the ORACLE_HOME/network/admin directory.
On Microsoft Windows, the TNS_ADMIN environment variable is used if it is set in the environment of the process. If the TNS_ADMIN environment variable is not defined in the environment, or the process is a service which does not have an environment, then Microsoft Windows scans the registry for a TNS_ADMIN parameter.
- Oracle Database Global Data Services Concepts and Administration Guide for information about management of global services
- Oracle operating system-specific documentation
6.2 General Syntax of tnsnames.ora
The basic syntax for a tnsnames.ora file is shown in Example 6-1.
Example 6-1 Basic Format of tnsnames.ora File
net_service_name= (DESCRIPTION=(ADDRESS=(
protocol_address_information
))
(CONNECT_DATA= (SERVICE_NAME=service_name
)))
In the preceding example, DESCRIPTION contains the connect descriptor, ADDRESS contains the protocol address, and CONNECT_DATA contains the database service identification information.
6.3 Multiple Descriptions in tnsnames.ora
A tnsnames.ora file can contain net service names with one or more connect descriptors. Each connect descriptor can contain one or more protocol addresses. Example 6-2 shows two connect descriptors with multiple addresses. DESCRIPTION_LIST defines a list of connect descriptors.
Example 6-2 Net Service Name with Multiple Connect Descriptors in tnsnames.ora
net_service_name= (DESCRIPTION_LIST= (DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales1-svr)(PORT=1521)) (ADDRESS=(PROTOCOL=tcp)(HOST=sales2-svr)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us.example.com))) (DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=hr1-svr)(PORT=1521)) (ADDRESS=(PROTOCOL=tcp)(HOST=hr2-svr)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=hr.us.example.com))))
Oracle Net Manager does not support the creation of multiple connect descriptors for a net service name when using Oracle Connection Manager.
6.4 Multiple Address Lists in tnsnames.ora
The tnsnames.ora file also supports connect descriptors with multiple lists of addresses, each with its own characteristics. In Example 6-3, two address lists are presented. The first address list features client load balancing and no connect-time failover , affecting only those protocol addresses within its ADDRESS_LIST . The second protocol address list features no client load loading balancing, but does have connect-time failover, affecting only those protocol addresses within its ADDRESS_LIST . The client first tries the first or second protocol address at random, then tries protocol addresses three and four sequentially.
Example 6-3 Multiple Address Lists in tnsnames.ora
net_service_name= (DESCRIPTION= (ADDRESS_LIST= (LOAD_BALANCE=on) (FAILOVER=off) (ADDRESS=(protocol_address_information
)) (ADDRESS=(protocol_address_information
))) (ADDRESS_LIST= (LOAD_BALANCE=off) (FAILOVER=on) (ADDRESS=(protocol_address_information
)) (ADDRESS=(protocol_address_information
))) (CONNECT_DATA= (SERVICE_NAME=service_name
)))
- Oracle Net Manager supports only the creation of one protocol address list for a connect descriptor.
- Oracle Net Services supports the IFILE parameter in the tnsnames.ora file, with up to three levels of nesting. The parameter is added manually to the file. The following is an example of the syntax:
IFILE=/tmp/listener_em.ora IFILE=/tmp/listener_cust1.ora IFILE=/tmp/listener_cust2.ora
6.5 Connect-Time Failover and Client Load Balancing with Oracle Connection Managers
When a connect descriptor in a tnsnames.ora file contains at least two protocol addresses for Oracle Connection Manager , parameters for connect-time failover and load balancing can be included in the file.
Example 6-4 illustrates failover of multiple Oracle Connection Manager protocol addresses.
Example 6-4 Multiple Oracle Connection Manager Addresses in tnsnames.ora
sample1= (DESCRIPTION= (SOURCE_ROUTE=yes) (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=1630)) # 1 (ADDRESS_LIST= (FAILOVER=on) (LOAD_BALANCE=off) # 2 (ADDRESS=(PROTOCOL=tcp)(HOST=host2a)(PORT=1630)) (ADDRESS=(PROTOCOL=tcp)(HOST=host2b)(PORT=1630))) (ADDRESS=(PROTOCOL=tcp)(HOST=host3)(PORT=1521))) # 3 (CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))
In Example 6-4, the syntax does the following:
- The client is instructed to connect to the protocol address of the first Oracle Connection Manager, as indicated by:
(ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=1630))
(ADDRESS_LIST= (FAILOVER=on) (LOAD_BALANCE=off) (ADDRESS=(PROTOCOL=tcp)(HOST=host2a)(PORT=1630)) (ADDRESS=(PROTOCOL=tcp)(HOST=host2b)(PORT=1630)))
(ADDRESS=(PROTOCOL=tcp)(HOST=host3)(PORT=1521))
Example 6-5 illustrates client load balancing among two Oracle Connection Managers and two protocol addresses:
Example 6-5 Client Load Balancing in tnsnames.ora
sample2= (DESCRIPTION= (LOAD_BALANCE=on) # 1 (FAILOVER=on) (ADDRESS_LIST= (SOURCE_ROUTE=yes) (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=1630)) # 2 (ADDRESS=(PROTOCOL=tcp)(HOST=host2)(PORT=1521))) (ADDRESS_LIST= (SOURCE_ROUTE=yes) (ADDRESS=(PROTOCOL=tcp)(HOST=host3)(port=1630)) (ADDRESS=(PROTOCOL=tcp)(HOST=host4)(port=1521))) (CONNECT_DATA=(SERVICE_NAME=sales.us.example.com))) # 3
In Example 6-5, the syntax does the following:
- The client is instructed to pick an ADDRESS_LIST at random and to fail over to the other if the chosen ADDRESS_LIST fails. This is indicated by the LOAD_BALANCE and FAILOVER parameters being set to on .
- When an ADDRESS_LIST is chosen, the client first connects to Oracle Connection Manager, using the Oracle Connection Manager protocol address that uses port 1630 indicated for the ADDRESS_LIST .
- Oracle Connection Manager then connects to the database service, using the protocol address indicated for the ADDRESS_LIST .
6.6 Connect Descriptor Descriptions
Each connect descriptor is contained within the DESCRIPTION parameter. Multiple connect descriptors are characterized by the DESCRIPTION_LIST parameter. These parameters are described in this section.
6.6.1 DESCRIPTION
To specify a container for a connect descriptor.
When using more than one DESCRIPTION parameter, put the parameters under the DESCRIPTION_LIST parameter.
net_service_name= (DESCRIPTION= (ADDRESS=. ) (CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))
6.6.2 DESCRIPTION_LIST
To define a list of connect descriptors for a particular net service name.
net_service_name= (DESCRIPTION_LIST= (DESCRIPTION= (ADDRESS=. ) (CONNECT_DATA=(SERVICE_NAME=sales.example.com))) (DESCRIPTION= (ADDRESS=. ) (CONNECT_DATA=(SERVICE_NAME=sales2.us.example.com))))
6.7 Protocol Address Section
The protocol address section of the tnsnames.ora file specifies the protocol addresses of the listener. If there is only one listener protocol address, then use the ADDRESS parameter. If there is more than one address, then use the ADDRESS_LIST parameter.
6.7.1 ADDRESS
To define a single listener protocol address.
Put this parameter under either the ADDRESS_LIST parameter or the DESCRIPTION parameter.
net_service_name= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-svr)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=sales.us.example.com))
Protocol Address Configuration for descriptions of the correct parameters to use for each protocol
6.7.1.1 HTTPS_PROXY
To specify HTTP proxy host name for tunneling SSL client connections.
The clients can tunnel secure connections over forward HTTP proxy using HTTP CONNECT method. This helps in accessing the public cloud database service as it eliminates the requirement to open an outbound port on a client side firewall. This parameter is applicable only to the connect descriptors where PROTOCOL=TCPS . This is similar to the web browser setting for intranet users who want to connect to internet hosts. Increase the forward web proxy read timeout for requests to a higher value depending on client queries. Otherwise, the forward web proxy closes the connection assuming that no requests are made from the client.
Successful connection depends on specific proxy configurations. The performance of data transfers depends on proxy capacity. Oracle recommends not to use this feature in production environments where performance is critical.
Configuring tnsnames.ora for the HTTP proxy may not be enough depending your organization’s network configuration and security policies. For example, some networks require a username and password for the HTTP proxy.
Oracle Client versions earlier than 18c does not support connections through HTTP proxy.
Contact your network administrator to open outbound connections to hosts in the oraclecloud.com domain using the relevant port, without going through an HTTP proxy. For example, port 1522.
HTTP proxy host name that can make an outbound connection to the internet hosts.