现在有两台电脑 A 和 B ;
电脑 A 上有 Oracle11G服务端; ip地址 192.168.1.120; 端口1521 ;
电脑 A 本机连接数据库 正常,可以登录及操作等 ;
电脑 B 配置访问电脑 A 时报错:The Network Adapter could not establish the connection
报这种错的话,网上有说法, 说是防火墙没关,或者是 服务端服务没启好等..
按本人的实际情况解说:
因为oracle服务端访问配置是需要配置访问地址监听的,具体见Oracle安装路径:
% product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
这个是我的oracle监听服务的配置文件,内容为
# listener.ora Network Configuration File: E:\app\rcfeng\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = E:\app\rcfeng\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\app\rcfeng\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = E:\app\rcfeng
可以看到有LISTENER 配置
其中
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
是指监听的地址;
由于本机的服务端一般都是自己做测试的时候访问 ;
而为什么我们写localhost:1521 的时候可以访问到,就是因为
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
这一句,我们监听了localhost,所以可以访问到..
如果需要被局域网访问的话,我们只需要加入监听访问地址就可以了,如:
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
这样局域网的机子就可以访问我们的oracle服务了..完整内容为:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
)
)
参考URL:http://blog.sina.com.cn/s/blog_510fdc8b0100w23j.html