sqlnet.ora listener.ora tnsnames.ora

$ORACLE_HOME/network/admin
sqlnet.ora(客户及服务器端)作用类似于linux或者其他unix的nsswitch.conf文件,通过这个文件来决定怎么样找一个连接中出现的连接字符串。
tnsnames.ora(客户及服务器端)类似于unix 的hosts文件,提供的tnsname到主机名或者ip的对应,只有当sqlnet.ora中类似NAMES.DIRECTORY_PATH= (TNSNAMES) 这样,也就是客户端解析连接字符串的顺序中有TNSNAMES时,才会尝试使用这个文件。
listener.ora(服务器端)listener监听器进程的配置文件。接受远程对数据库的接入申请并转交给oracle的服务器进程。所以如果不是使用的远程的连接,listener进程就不是必需的,同样的如果关闭listener进程并不会影响已经存在的数据库连接。
sqlplus / as sysdba典型的操作系统认证,不需要listener进程
sqlplus sys/oracle只能连接本机数据库,不需要listener进程
sqlplus sys/oracle@orcl需要listener进程处于可用状态。最普遍的通过网络连接。
1
2
3
4
5
6
7
# 本地连接数据库,服务器进程显示如下:
ps -ef | grep LOCAL
oracle 2878 2814 0 09:46 ? 00:00:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

# 通过监听连接数据库,服务器进程显示如下
ps -ef | grep LOCAL
oracle 3124 1 0 09:48 ? 00:00:00 oracleorcl (LOCAL=NO)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
[grid@StandaloneOracle admin]$ echo $ORACLE_HOME
/u01/app/grid/product/11.2.0/grid
[grid@StandaloneOracle admin]$ pwd
/u01/app/grid/product/11.2.0/grid/network/admin
[grid@StandaloneOracle admin]$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/grid/product/11.2.0/grid/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

ADR_BASE = /u01/app/grid

[grid@StandaloneOracle admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = StandaloneOracle)(PORT = 1522))
)

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER1 = ON

SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = susu)
(ORACLE_HOME = /u01/app/grid/product/11.2.0/grid)
(SID_NAME = orasidsusu)
)
)

ADR_BASE_LISTENER1 = /u01/app/grid

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = StandaloneOracle)(PORT = 1521))
)

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

[grid@StandaloneOracle admin]$
[grid@StandaloneOracle admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-DEC-2019 11:28:23

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=StandaloneOracle)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 07-MAY-2019 10:28:41
Uptime 0 days 0 hr. 59 min. 42 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/StandaloneOracle/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=StandaloneOracle)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "orasidsusuXDB" has 1 instance(s).
Instance "orasidsusu", status READY, has 1 handler(s) for this service...
Service "susu" has 1 instance(s).
Instance "orasidsusu", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@StandaloneOracle admin]$
[grid@StandaloneOracle admin]$ lsnrctl status LISTENER1

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-DEC-2019 11:30:16

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=StandaloneOracle)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 07-DEC-2019 10:28:41
Uptime 0 days 1 hr. 1 min. 35 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/product/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/StandaloneOracle/listener1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=StandaloneOracle)(PORT=1522)))
Services Summary...
Service "susu" has 1 instance(s).
Instance "orasidsusu", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[grid@StandaloneOracle admin]$



[oracle@StandaloneOracle trace]$ tnsping susu

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-MAY-2019 11:26:06

Copyright (c) 1997, 2009, Oracle. All rights reserved.

Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = StandaloneOracle)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = susu)))
OK (0 msec)
[oracle@StandaloneOracle trace]$