listener.ora/sqlnet.ora/tnsnames.ora configuration file

 

1. sqlnet.ora 

sqlnet.ora is used on the oracle client side to configure the relevant parameters for connecting to the server side oracle. 1).NAMES.DEFAULT_DOMAIN: domain name domain definition, when you use sqlplus to access the database, ".domain" will be added after the tns alias 

Example: .NAMES.DEFAULT_DOMAIN=.com 

When the client executes the command: sqlplus username/password@local_dev, the following error message will appear: "ORA-12154: TNS: could not resolve service name" or "ORA-12154: TNS: could not resolve service name" information. Because when sqlplus username/password@orcl, the tns alias "orcl" is converted into "orcl.com", so orcl.com cannot be found in tnsnames.ora, and an error is reported.

Modify the definition in tnsnames.ora as follows:

ORCL.com =   

(DESCRIPTION =   

 (ADDRESS_LIST = 

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.147)(PORT = 1521)) 

   ) 

    (CONNECT_DATA = 

     (SERVICE_NAME = orcl)   

 )   ) 

Then execute sqlplus username/password@orcl to connect successfully. 

2) NAMES.DIRECTORY_PATH: defines what matching method is used when the client connects to the database.

示例:NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME) 

Then when the client executes sqlplus username/password@local_dev to connect to the database, first use the alias configuration of tnsnames.ora to connect to the database; if connected, then use ONAMES for parsing, and finally use the host name for parsing. ONAMES indicates that Oracle uses its own name server (Oracle Name Server) for resolution. Currently, Oracle recommends using the Lightweight Directory Access Protocol LDAP to replace ONAMES; HOSTNAME indicates that the host file, DNS, NIS, etc. are used for resolution; 3) SQLNET.AUTHENTICATION_SERVICES: Definition The authentication method for logging in to the database. This parameter is not set by default. Example: SQLNET.AUTHENTICATION_SERVICES=(NONE,NTS) 

NONE means Oracle database authentication, and NTS means operating system authentication. The two methods can be used together, and the order indicates the priority method of authentication. 

4) tcp.validnode_checking=yes: Indicates that the IP check of the client is enabled, and the illegal IP will be denied access to Oracle. 5) tcp.invited_nodes=(IP1, IP2, IP3...): Indicates which IPs are allowed to access Oracle.

6) tcp.excluded_nodes=(IP1, IP2, IP3...): Indicates which IPs are denied access to Oracle.

 

Two, tnsnames.ora 

tnsnames.ora is used on the oracle client side, and the user configures the alias parameters for connecting to the database, just like the hosts file in the system.

Provides detailed information, host address, port, database instance name, etc. for the client to connect to a database.

Example:

ORCL =

   (DESCRIPTION =

     (ADDRESS_LIST = 

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.147)(PORT = 1521))

     )

      (CONNECT_DATA =

        (SERVICE_NAME = orcl) 

   )

   ) 

The PROTOCOL parameter is generally TCP, and a configuration method can be selected according to the server situation.

HOST is generally an ip address. If it is a host name, the mapping relationship between the host name and the ip address should be configured in the host file of the client system. 

The PORT standard is 1521, depending on the listening port on the server side.

SERVICE_NAME is the service name of the database. 

 

3. The listener.ora tnslsnr process is a listening process that monitors and accepts remote connection database requests. listener.ora is the configuration file of the tnslsnr process. The listening parameters are read from the configuration file, which is located on the server side. If you only need to connect to the database locally and do not accept remote connections, then you do not need to start the tnslsnr process, nor do you need to maintain the listener.ora file. The command to start the monitoring process. In command mode, executing the lsnrctl start command starts the monitoring process tnslsnr.

Example: 

SID_LIST_LISTENER = 

 (SID_LIST =

     (SID_DESC =

        (SID_NAME = PLSExtProc)

        (ORACLE_HOME = /oracle/product/10.2.0/db_1) 

        (PROGRAM = extproc)

     )

      (SID_DESC = 

      (GLOBAL_DBNAME = orcl) 

      (ORACLE_HOME = /oracle/product/10.2.0/db_1)

       (SID_NAME = orcl)

     )      

LISTENER =

    (DESCRIPTION_LIST = 

   (DESCRIPTION = 

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.147)(PORT = 1521))

       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

     )

   ) 

The LISTENER section contains a list of protocol addresses, one entry per instance.

 The SID_LIST_LISTENER section identifies the global database name, the Oracle software home directory and instance or SID identifying each instance the listener is serving. 

When you execute the command sqlplus username/password@tnsname, the general process is as follows:

1) Query sqlnet.ora to see how the name is resolved, and find that it is TNSNAME, or hostname. 

2) Then query the tnsnames.ora file, find the record of tnsname from it, and find the host name, port and service_name.

3) If there is no problem with the listener process, establish a connection with the listener process. 

4) According to different server modes such as dedicated server mode or shared server mode, the listener takes the next action. The default is dedicated server mode. If there is no problem, the client will connect to the server process of the database.

5) At this time, the network connection has been established, and the historical mission of the listener process is completed.

Several command forms used to connect to the database: 

1) sqlplus "/ as sysdba" This is a typical operating system authentication, no listener process is required, and the database can be logged in even if it is unavailable. 

2) sqlplus username/password does not need a listener process, log in to the local database, and the database instance can be started.

3) sqlplus username/password@tnsname requires the listener process, the most common remote login mode, needs to start the database instance and the listener process.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326076732&siteId=291194637