Vous êtes sur la page 1sur 5

http://www.chenjunlu.

com/2011/05/introduction-of-oracle-network-configuration-fi
les/
Dwell in Oracle Network Configuration File
by ROBIN on 2011?05?13? LEAVE A COMMENT in DATABASE , INFORMATION WORLD | IT
1 Overview
In the Oracle installation directory $ HOME / network / admin ,, often see sqlne
t.ora tnsnames.ora listener.ora these three documents, in addition to tnsnames.o
ra, the other two documents in detail the use of a lot of people do not understa
nd.
sqlnet.ora used in the Oracle client side, configure the connection parameters f
or the Oracle server.
tnsnames.ora used in the Oracle client-side, user configuration alias database c
onnection parameters, like the system hosts file.
listener.ora used in the Oracle server side, configure Oracle server process mon
itoring methods, such as restrictions on certain ip and other parameters.
In the installation directory $ HOME / network / admin / samples, will see these
three documents sample file, there will be relevant parameters and usage instru
ctions, if you encounter any problems, you can control these sample documents re
lated parameters instructions to resolve.
If you connect to the database out what the problem is, to ensure the network is
normal, there is no firewall interference, find the problem steps are:
In order to check the client sqlnet.ora, tnsnames.ora if there are problems.
Check listener.ora configuration on the server side, and to ensure the listener
starts, the database service load.
2. know sqlnet.ora file
The following describes only a few common configuration parameters, detailed inf
ormation, you can refer to the sample sqlnet.ora file.
sqlnet.ora can be removed, so that when the Oracle client connection to the data
base, the default configuration file using tnsnames.ora.
1) .NAMES.DEFAULT_DOMAIN
Name domain definition, when you access the database using sqlplus will alias ba
ck in tns plus ".domain"
Example:
NAMES.DEFAULT_DOMAIN = COM
tnsnames.ora in tns is defined as follows:
local_dev =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.111) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = linuxdb)
)
)
When the client executes sqlplus connect command, the following error message ma
y appear:
#sqlplus username / password @ local_dev
"ORA-12154: TNS: unable to handle service name" or "ORA-12154: TNS: could not re
solve service name"
Because sqlplus username / password @ local_dev when the tns alias "local_dev" c
onverted "local_dev.com", so local_dev.com in tnsnames.ora not found on the erro
r.
Modify the tnsnames.ora file is defined as follows:
local_dev.com =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.111) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = linuxdb)
)
)
Then execute sqlplus username / password @ local_dev, the connection is successf
ul.
2) .NAMES.DIRECTORY_PATH
Defines when the client connect to the database, what kind of matching.
Sample sqlnet.ora file as follows:
NAMES.DIRECTORY_PATH = (TNSNAMES, ONAMES, HOSTNAME)
So when the client performs sqlplus username / password @ local_dev connection t
o the database,
first used the alias tnsnames.ora configuration connect to the database; on if t
he connection;
then using ONAMES be resolved, finally resolved using the host name;
ONAMES said Oracle uses its own Name Server (Oracle Name Server) to resolve the
current Oracle recommends using Lightweight Directory Access Protocol LDAP to re
place ONAMES;
HOSTNAME that the use hosts file, DNS, NIS, etc. to resolve;
3) .SQLNET.AUTHENTICATION_SERVICES
Define the authentication method to log database.
NONE indicates Oracle database authentication, NTS represents operating system a
uthentication, and can be used in two ways.
Can be set to SQLNET.AUTHENTICATION_SERVICES = (NONE, NTS) to verify the priorit
y sequence showed the way.
Example sqlnet.ora as follows:
SQLNET.AUTHENTICATION_SERVICES = (NONE)
Execute the following command on the command line:
when sqlplus "/ as sysdba", execution failed.
An error message ORA-01031: insufficient privileges
by default this parameter is not set.
Recognizes tnsnames.ora file
Provides detailed information about the client to connect to a database, host ad
dress, port, database instance name and so on.
Here's an example to illustrate the problem:
local_dev =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.111) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = linuxdb)
)
)
PROTOCOL parameter is usually TCP, you can select a configuration based on the s
erver situation.
HOST is generally ip address or host name, the host name can ping hostname long
pass on the line, usually in the host file on the client system with a good mapp
ing between host names and ip addresses.
ORT standard is 1521, according to the server listening port may be.
SERVICE_NAME is the service name of the database, using the system after user lo
gin, sqlplus> show parameter service_name command.
This configuration file usually everyone with more than most people would, I bel
ieve there will not be a big problem.
Recognizes listener.ora file
tnslsnr process is to listen and to accept remote connections monitoring process
database requests, listener.ora configuration file tnslsnr process, monitoring
parameters are read from the configuration file.
This file is located in the service side, if you install only the Oracle client,
generally do not exist in this file.
If you only need to connect to the database locally, does not accept remote conn
ections, you do not need to start tnslsnr process does not need to maintain list
ener.ora file.
Start the listener process commands in command mode, execute lsnrctl start comma
nd to start the monitoring process tnslsnr.
Listeners can have multiple, that is, you can simultaneously monitor multiple Or
acle instances, you can define multiple listeners listen in listener.ora in.
Here's a simple example listener.ora file content:
LISTENER_CSB =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.70.9.14) (PORT = 1621))
)
)
)
SID_LIST_LISTENER_CSB =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = / u02 / Oracle /app/oracle/product/10.2.0/db)
(SID_NAME = zjdevcsb)
)
)
############################## ###############
LISTENER_CSA =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.70.9.14) (PORT = 1521))
)
)
)
SID_LIST_LISTENER_CSA =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u02/oracle/app/oracle/product/10.2.0/db)
(SID_NAME = zjdevcsa)
)
)
In the example above:
. 1) LISTENER_CSB, LISTENER_CSA defines the listener listens two names, and thes
e two parameters listener is listening: ip, port and so on.
. 2) SID_LIST_LISTENER_CSB, SID_LIST_LISTENER_CSA defines two monitoring service
s, the service name format SID_LIST_, lsnrname is above the two listeners name,
specify the service will accept service will be presented to the listener; insta
nce name zjdevcsb listening, zjdevcsa is SERVICE_NAME parameter in the tnsnames.
ora file corresponding need to specify.
Detailed parameter description can see an example of the listener.ora file.
5. Oracle user login hosts
1) Start the database instance
First, execute the command sqlplus "/ as sysdba" login with the database system
administrator role, and then start the database instance to perform startup, shu
t down the database instance to perform with the shutdown command. If you do not
connect to the database remotely, then you can log in the database in this mach
ine. Execute sqlplus username / password you can log into the database correctly
.
2) monitor
Start listening, execute the command lsnrctl start, you can use lsnrctl status v
iew listening state, if the listener starts successfully, then you can remotely
connect to the database, and execute the command sqlplus username / password @ t
nsname;
close monitoring, execute the command lsnrctl stop.
3) Remote connection to the database
When you execute the command sqlplus username / password @ tnsname Hou, general
process is as follows:
Sqlnet.ora look at ways to resolve the query name, found TNSNAME, or hostname.
The query tnsnames.ora file, find tnsname records from the inside, and find the
host name, port and service_name.
If the listener process is not a problem, the connection is established with the
listener process.
Depending on the server model, such as a dedicated server mode or shared server
mode, listener to take the next action. The default is dedicated server mode, th
ere is no problem if the client to connect to the database server process.
This time the network connection has been established, the historical mission li
stener process is complete.
If at the time of connection to the database, there is nothing wrong, you can fi
nd the appropriate configuration in accordance with the above order to solve the
problem.
Several commands in the form of a database used to connect:
sqlplus "/ as sysdba" This is a typical operating system authentication, no list
ener process, even if the database is unavailable you can login.
sqlplus username / password does not require the listener process, log on the lo
cal database, the database instance startup can.
sqlplus username / password @ tnsname need listener process, the most common rem
ote login mode, you need to start the database instance and listener processes.
6.-related terms used herein
Db_domain: domain where the definition of a database, the domain name with the I
nternet 'domain' does not have any relationship, only a database administrator i
n order to better manage the distributed database and determined according to th
e actual situation. Of course, in order to facilitate the management, it can be
equal to the Internet domain.
Global_name: a database (Oracle database) unique identifier, Oracle recommends u
sing this method command to the database. The value is in the decision to create
the database, the default value Db_name. Db_domain. After any changes to the pa
rameter file Db_name and Db_domain parameter does not affect the value of Global
_name, if you want to modify Global_name, can only be modified with the ALTER DA
TABASE RENAME GLOBAL_NAME TO command, and then modify the parameters.
Service_name: This parameter is oracle8i newly introduced. In 8i ago, we used to
represent an instance SID identifies the database, but Oracle's parallel enviro
nment, a database corresponding to multiple instances, so you need more than one
network service name, set up cumbersome. In order to facilitate the setting in
a parallel environment, the introduction of Service_name parameter, which corres
ponds to a database, rather than an instance, and the parameter has many other b
enefits. The default for this parameter is Db_name. Db_domain, which equals Glob
al_name. A database can correspond to multiple Service_name, in order to achieve
a more flexible configuration. This parameter has no direct relationship with t
he SID, that do not have Service name must be the same SID.

Vous aimerez peut-être aussi