问题描述:
虚拟机win7上Oracle11g安装完成后,修改虚拟机系统和宿主机之间的网络连接为NAT类型,两边ip均可相互ping通,并且虚拟机上Oracle的139端口也可以telnet通过,但宿主机访问虚拟机
telnet 虚拟机IP 1521无法连接。
环境说明:
宿主机环境:win10_64bit专业版 虚拟机安装环境:VMware11虚拟机上的Win7-32bit旗舰版环境,核心1核,内存3G,硬盘空间35G 安装版本:Oracle Database 11g Release 2 (11.2.0.1.0) for Microsoft Windows (x86) 安装文件为:win32_11gR2_database_1of2.zip和win32_11gR2_database_2of2.zip 宿主机与虚拟机网络连接类型:NAT连接
现象分析:
需要修改oracle监听文件
解决方案:
- 打开防火墙,看1521端口是否在
inbound
和outbound
中。如果不在,加入1521
端口。(最简单的方法就是关闭宿主机和虚拟机内系统的防火墙) - 运行
cmd
,进入控制台,netstat -a -n
看一下1521
端口的ip是0.0.0.0
还是127.0.0.1
,如果是后者,就需要修改listener.ora
和tnsnames.ora
文件, - 修改监听文件:将两个文件里的localhost替换为自己的主机名
- 文件位置:
D:\oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN
目录下
listener.ora
(共一处)
# listener.ora Network Configuration File: F:\oracle\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 = F:\oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:F:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost
) ) ADR_BASE_LISTENER = F:\oracle
tnsnames.ora
(共两处)
# tnsnames.ora Network Configuration File: F:\oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Young-PC)(PORT = 1521))//Young-PC原为localhost
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)