本地为例
服务端配置
1、listener.ora 服务器端监听文件
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl) -- 实例名称
(ORACLE_HOME = F:\app\sen.qiao\product\11.2.0\dbhome_1) -- ORACLE_HOME
(SID_NAME = orcl) -- 实例名称
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
2、客户端配置,不常用 (既为服务端又为客户端,才会配置这两个文件)
2.1 sqlnet.ora 输入别名时判断去哪里获取连接串
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES)
2.2 tnsnames.ora 给连接串起别名
尽量写为一行,避免无法识别 , joe即为别名
JOE =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL= TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =orcl)))
2.3 配置之后检验:
C:\Users\sen.qiao>tnsping joe
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 04-11月-2021 14:28:57
Copyright (c) 1997, 2010, Oracle. All rights reserved.
已使用的参数文件:
F:\app\sen.qiao\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL= TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =orcl)))
OK (0 毫秒)
2.4 连接步骤
sqlplus sys/123456@joe
先去sqlnet.ora 找到连接模式 tnsname模式
然后在tnsname.ora文件中找到字符串
3、tnsnames.ora 在plsql中应用
如下图目录中新增文件
一个连接串写一行