Oracle Network Configuration
Three configuration filesListener. ora,Sqlnet. ora,Tnsnames. oraAll are placed in$ ORACLE_HOME \ network \ adminDirectory.
1. sqlnet. ora ----- SimilarLinuxOr otherUnixOfNsswitch. confFile to determine how to find a connection string.
For example, we enter
Sqlplus sys/oracle @ orcl
Assume that mySqlnet. oraIt looks like this:
SQLNET. AUTHENTICATION_SERVICES = (CNT)
NAMES. DIRECTORY_PATH = (TNSNAMES, HOSTNAME)
Then, the client will firstTnsnames. oraFile SearchOrclRecords.If no corresponding record exists, tryOrclAs a host name, it is resolved through the networkIpThen connect toIpUpperGLOBAL_DBNAME = orclThis instance, of course, I am hereOrclIt is not a host name.
If I look like this
NAMES. DIRECTORY_PATH = (TNSNAMES)
Then the client will onlyTnsnames. oraSearchOrclRecords,There are other options in brackets, suchLDAPAnd so on.
2. Tnsnames. ora ------This file is similarUnixOfHostsFile, providedTnsnameTo the host name orIpOnly whenSqlnet. oraSimilar
NAMES. DIRECTORY_PATH = (TNSNAMES)In this way, the order in which the client parses the connection string isTNSNAMESYes.
PROTOCOL: The Protocol for communications between the client and the server, generallyTCPThis content does not need to be changed.
HOST: The name of the machine on which the database listensIPAddress, database listening is generally on the same machine as the database, so when I say that the machine where the database listening is located is generally the machine where the database is located. InUNIXOrWINDOWSYou can useHostnameCommand to get the machine name, or useIpconfig (for WINDOWS) or ifconfig(For UNIX) Command to getIPAddress. Note that no matter the machine name orIPAddress, which must be used on the clientPingCommandPingThe name of the machine on which the database listens. OtherwiseHostsFile.
PORT: The database listens on the listening port. You can view the server side.Listener. oraFile or runLnsrctl status [listener name]Command view. HerePortMust be the same as the database listening port.
SERVICE_NAME: On the server side, useSystemAfter the user logs in,Sqlplus> show parameter service_nameCommand view.
ORCL:Corresponding local machine,SALESCorresponding to anotherIPAddress, which also defines whether to use the master server or Shared Server Mode for connection.
# Input during connection TNSNAME
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
# Below isTNSNAMECorresponding host, port, Protocol
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
)
(CONNECT_DATA =
# When using the dedicated server mode to connect, it must match the server mode. If not, it is automatically adjusted according to the server mode.
(SERVER = DEDICATED)
# CorrespondingService_name,SQLPLUS>; show parameter service_name;View
(SERVICE_NAME = orcl)
)
)
# The following is similar
SALES =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = dg1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sales)
)
)
Note: If the database server usesMTS, The client program needs to useDatabase linkIt is best to explicitly specify the clientDedicatedDirect Connection,Otherwise, you will encounter many problems related to the distributed environment.ORACLE BUG. Generally, direct connection to the database server is better, unless your real-time database connection is close1000.
3. listener. ora ------ listener Configuration file of the listener process
AboutListenerThe process will not be said much. Accept Remote database access requests and transfer themOracle. Therefore, if the remote connection is not used and the OEM is not required,ListenerThe process is not required. If the process is disabledListenerThe process does not affect existing database connections.
Listener. oraFile example
# Listener. ora Network Configuration File: # E: \ oracle \ product \ 10.1.0 \ Db_2 \ NETWORK \ ADMIN \ listener. ora
# Generated by Oracle configuration tools.
#The following definitionLISTENERWhich instance does the process provide services? Here isORCLAnd it correspondsORACLE_HOMEAndGLOBAL_DBNAMEWhereGLOBAL_DBNAMENot required unless
#UseHOSTNAMEDatabase Connection
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = boway)
(ORACLE_HOME =/u01/app/oracle)
(SID_NAME = ORCL)
)
)
#Listener name. A database can have more than one listener.
#Next we will talk about the protocol, ip address, port, and so on listened by the listener. Here we use the tcp1521 port and use the # host name.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = dg1) (PORT = 1521 ))
)
The above example is the simplest, but also the most common. OneListenerProcess isInstance (SID)Provide services.
Listener Operation Command
$ ORACLE_HOME/bin/lsnrctl start,OtherStop, status. Complete oneLsnrctlSee help later.
The three files mentioned above can be configured through the graphical Configuration tool.
$ ORACLE_HOME/netcaWizard
$ ORACLE_HOME/netmgr
I preferNetmgr,
ProfileIs configuredSqlnet. oraThat is, the name resolution method.
Service nameIs configuredTnsnames. oraFile
ListenersIs configuredListener. oraFile, that is, the listener process
For more information about the configuration, see the configuration file.
In this way, the overall structure will be available.