Oracle: listener. ora, sqlnet. ora, tnsnames. ora configuration and example
1. Solve the problem: TNS or the database cannot log on.
The simplest and most effective method: use the tool netca provided by the Oracle System to configure (delete the original one and reconfigure it)
$ Netca 2. However, I still have questions: how do I specify the directory where 'listener. ora 'is stored? Do not default directory ($ ORACLE_HOME/network/admin)
Add in '. profile'
- TNS_ADMIN =/f01/oracle11/app/oracle/product/8.0.6/network/admin
- Export TNS_ADMIN
3. Three configuration files
1) listener. ora
2) sqlnet. ora
3) tnsnames. ora
These three files are all stored in the $ ORACLE_HOME/network/admin directory.
1) sqlnet. ora (client and server)
The function is similar to the nsswitch. conf file of linux or other unix systems. This file is used to determine how to find a connection string that appears in the connection,
For example, we enter
Sqlplus sys/oracle @ orcl
Assume that my sqlnet. ora is like the following:
- SQLNET. AUTHENTICATION_SERVICES = (CNT)
-
- NAMES. DIRECTORY_PATH = (TNSNAMES, HOSTNAME)
Then, the client will first be in tnsnames. find the orcl record in the ora file. If there is no corresponding record, try to treat orcl as a host name, resolve the ip address through the network and connect to the instance GLOBAL_DBNAME = orcl on the ip address. Of course, here, orcl is not a host name.
If I look like this
- NAMES. DIRECTORY_PATH = (TNSNAMES)
Then the client will only search for orcl records from tnsnames. ora
There are other options in brackets, such as LDAP, which are not commonly used.
2) Tnsnames. ora (customer and server)
This file is similar to the unix hosts file. It provides the tnsname to the host name or ip address, only when the sqlnet. ora file is similar
NAMES. DIRECTORY_PATH = (TNSNAMES), that is, the file will be used only when the client parses the order of the connection string that contains TNSNAMES.
In this example, there are two local IP addresses corresponding to ORCL and another IP address corresponding to SALES, which also defines whether to use the master server or Shared Server Mode for connection. The sentence is as follows:
- # Enter TNSNAME when you want to connect
-
- ORCL =
-
- (DESCRIPTION =
-
- (ADDRESS_LIST =
-
- # The host, port, and Protocol corresponding to this TNSNAME
-
- (ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
-
- )
-
- (CONNECT_DATA =
-
- # Use the dedicated server mode to connect to the server. The connection mode must match the server mode. If not, the connection is based on the server mode.
-
- # Automatic Adjustment
-
- (SERVER = DEDICATED)
-
- # Corresponding service_name, SQLPLUS> show parameter service_name;
-
- # View
-
- (SERVICE_NAME = orcl)
-
- )
-
- )
-
- # The following is similar
-
- SALES =
-
- (DESCRIPTION =
-
- (ADDRESS_LIST =
-
- (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.188.219) (PORT = 1521 ))
-
- )
-
- (CONNECT_DATA =
-
- (SERVER = DEDICATED)
-
- (SERVICE_NAME = sales)
-
- )
-
- )
3) listener. ora (server side) -- configuration file of listener process
The listener process is not much said. The listener process accepts remote database access requests and transfers them to the oracle server process. Therefore, if you do not use a remote connection, the listener process is not required. Similarly, disabling the listener process does not affect the existing database connection.
Example of Listener. ora File
- # Listener. ora Network Configuration File: # E:/oracle/product/10.1.0/Db_2/NETWORK/ADMIN/listener. ora
-
- # Generated by Oracle configuration tools.
-
- # The following defines the instance for which the LISTENER process provides services
-
- # Here Is ORCL, And it corresponds to ORACLE_HOME and GLOBAL_DBNAME
-
- # GLOBAL_DBNAME is not required unless you use HOSTNAME for database connection
-
- SID_LIST_LISTENER =
-
- (SID_LIST =
-
- (SID_DESC =
-
- (GLOBAL_DBNAME = boway)
-
- (ORACLE_HOME = E:/oracle/product/10.1.0/Db_2)
-
- (SID_NAME = ORCL)
-
- )
-
- )
-
- # Listener name. A database can have more than one listener.
-
- # Next we will talk to the listener about the protocol, ip address, port, etc. Here we use the tcp1521 port and use the # Host Name
-
- LISTENER =
-
- (DESCRIPTION =
-
- (ADDRESS = (PROTOCOL = TCP) (HOST = boway) (PORT = 1521 ))
-
- )
The above example is the simplest, but also the most common. A listener process provides services for an instance (SID.