oracle database connection configuration

This example uses win 7 as the database test server, and mainly introduces the three major configuration files of the oracle database: sqlnet.ora, tnsnames.ora, and listener.ora.

 

sqlnet.ora is used on the oracle client side to configure the relevant parameters for connecting to the server oracle
tnsnames.ora is used on the oracle client side, the user configures the alias parameters for connecting to the database, just like the hosts file in the system
listener.ora is used on the oracle server side to configure the monitoring method of the oracle server program, such as restricting some parameters such as ip

 

1 、 sqlnet.ora

 

sqlnet.ora can be deleted, so that when the oracle client connects to the database, the configuration in tnsnames.ora is used by default. There are two parameters set by default in this configuration file

 

SQLNET.AUTHENTICATION_SERVICES= (NTS)

 Defines the authentication method for logging into the database. NONE means Oracle database authentication, NTS means operating system authentication, and the two methods can be used together. can be set to

 

 

SQLNET.AUTHENTICATION_SERVICES=(NONE,NTS)

 

The order of precedence indicates the preferred method of authentication.

 

2 、 tnsnames.ora

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

 

LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.1.17)(PORT = 1521))

#LOCAL
ORCL_LOCAL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.1.17)(PORT = 1521))
    )
    (CONNECT_DATA =
      #(SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

#10.10.1.107
ORCL_107 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.1.107)(PORT = 1521))
    (CONNECT_DATA =
      #(SERVER = DEDICATED)
      (SERVICE_NAME = orcl.10.1.107)
    )
  )

 ADDRESS_LIST indicates that the client wants to connect to one or more servers via multiple protocols. In the style file, it is indicated that the client should use the TCP/IP protocol to connect with the server.

 

PROTOCOL indicates the protocol to be used for connection, the parameter is generally TCP, and a configuration method can be selected according to the server situation.

HOST is generally an ip address, or a host name. The host name can be used as long as ping hostname can be used. Generally, the mapping relationship between the host name and the ip address is configured in the host file of the client system.

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

SERVICE_NAME is the service name of the database (Global Database Name), log in with the system user to view service_name

 

-- Login as system account
sqlplus /nolog
conn system/orcl
--command to view service_name
show parameter service_name

SID Specifies the ORACLE_SID of the ORACLE database on the server to connect to.

 

SERVER=DEDICATED indicates that a dedicated server is used to connect to the ORACLE database.

ORCL_LOCAL/ORCL_107 is a connection descriptor, which is specified when logging in remotely. For example, connecting to ORCL_107 can be accessed through sqlplus login

sqlplus dev/dev@orcl_107

 Note: sqlplus remote access needs to set the TNS_ADMIN environment variable first

Environment variable name: TNS_ADMIN
Environment variable value: D:\orcl\product\11.2.0\dbhome_1\NETWORK\ADMIN

 The specific configuration address is subject to the local installation address.

 

3、listener.ora

The 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 parameters of the monitoring are read from the configuration file.

This file is located on the server side. If only the oracle client is installed, this file generally does not exist. 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. Example of listening configuration:

 

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = d:\orcl\product\11.2.0\dbhome_1)
      (SID_NAME = orcl)
    )
  )
  
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.1.17)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = d:\orcl

 After the listening service is configured, the database service instance needs to be restarted. The command is as follows:

 

#Login through sqlplus
sqlplus /nolog
conn dev/dev
#Stop the database instance
shutdown immediate
#Start instance service
startup

 

The command to start the monitoring process. In command mode, executing the lsnrctl start command starts the monitoring process tnslsnr.

 

#View monitoring service status
lsnrctl status
#Enable listening service
lsnrctl start
#Close the listening service
lsnrctl stop

 

 

Guess you like

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