不管是oracle数据库的监听还是网络服务名,都可以通过下面三种方法配置:
1、通过客户端计算机的Oracle Net Configuration Assistant配置
注意:配置完成进行测试时,默认的测试使用oracle的Scott用户,因为用户被锁或口令不对,一般都会测试不成功,这时候可以通过‘更改登录’使用其他用户名/口令来测试。
2、通过客户端计算机的Oracle Net Manager配置
共两步:
- 监听位置
- 数据库服务
3、通过配置文件配置
上面两种网络服务名的配置方法其实都是借助工具将远程连接配置自动写入到配置文件listener.ora 和 tnsnames.ora,所以手动修改配置文件同样可以配置,一般情况下,该文件都存放于$ORACLE_HOME/NETWORK/ADMIN中。
-
标准监听配置listener.ora示例:
# listener.ora Network Configuration File: D:\APP_oracle12c\product\12.1.0\dbhome_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = AML)
(ORACLE_HOME = D:\APP_oracle12c\product\12.1.0\dbhome_1)
(SID_NAME = AML)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
ADR_BASE_LISTENER = D:\APP_oracle12c\product\12.1.0\dbhome_1\log
-
标准监听配置tnsnames.ora示例:
# tnsnames.ora Network Configuration File: D:\app\ty\product\12.1.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)