Recently saw a lot of people talk about TNS or database can not log in and so on, simply summed up the following dongdong.
First of all, Oracle's network structure, to complex to say can add encryption, LDAP and so on. There is no discussion here, and the focus is on the basic network structure, which is what we use most often.
Three configuration files
Listener.ora, Sqlnet.ora, Tnsnames.ora, are placed in the $oracle_home\network\admin directory.
Focus: Role and use of three documents
#-----------------------
Sqlnet.ora-----function is similar to Linux or other Unix nsswitch.conf files, which determines how to find a connection string that appears in a connection.
such as our client input
Sqlplus SYS/ORACLE@ORCL
If my sqlnet.ora is like this
Sqlnet. Authentication_services= (NTS)
NAMES. Directory_path= (Tnsnames,hostname)
Then the client will first find the ORCL record in the Tnsnames.ora file. If there is no corresponding record, try to use ORCL as a host name, through the network to resolve its IP address and then to connect the IP GLOBAL_DBNAME=ORCL this instance, Of course I'm here ORCL is not a host name
If I were this way
NAMES. Directory_path= (TNSNAMES)
Then the client will only find ORCL records from Tnsnames.ora.
There are other options in parentheses, such as LDAP, which are not commonly used.
#------------------------
Tnsnames.ora------This file is similar to the Hosts file for UNIX, providing tnsname to host name or IP correspondence, only if Sqlnet.ora is similar
NAMES. Directory_path= (TNSNAMES) This means that the client resolves the connection string in the order in which it is TNSNAMES to try to use the file.
Examples of two, ORCL corresponding to the local, sales corresponding to another IP address, which also defines the use of the main server or shared server mode to connect, one sentence said
#你所要连接的时候输入得TNSNAME
ORCL =
(DESCRIPTION =
(Address_list =
#下面是这个TNSNAME对应的主机, Port, protocol
(address = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521))
)
(Connect_data =
#使用专用服务器模式去连接需要跟服务器的模式匹配, if not, based on the server's mode
#自动调节
(SERVER = dedicated)
#对应service_name, sqlplus>show parameter service_name;
#进行查看
(service_name = ORCL)
)
)