linux下oracle远程连接的问题
oracle Error Code: 17002 错误
(2011-04-01 00:12:43)
当oracle外部链接出现Error Code: 17002的错误时,请检查/etc/hosts、/opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora 、/opt/oracle/product/10.2.0/db_1/network/admin/listener.ora这三个文件,我的机子配置如下:
[chubin@chub-rhel6-64 ~]$ vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.100.160 chub-rhel6-64 chub-rhel6-64-alias
tnsnames.ora、listener.ora文件根据个人oracle安装路径查找
启动时一定先启侦听,再启数据库
[oracle@chub-rhel6-64 ~]$ lsnrctl start
[oracle@chub-rhel6-64 ~]$ sqlplus '/as sysdba'
SQL> startup
[oracle@chub-rhel6-64 ~]$ vi /opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = chub-rhel6-64)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
[oracle@chub-rhel6-64 ~]$ vi /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = chub-rhel6-64)(PORT = 1521))
)
)
1、当tnsnames.ora、listener.ora文件中HOST = localhost.localdomain 时,出现如下报错:
An error occurred while establishing the connection:
Long Message:
Io 异常: The Network Adapter could not establish the connection
Details:
Type: java.sql.SQLException
Error Code: 17002
SQL State: null
2、当tnsnames.ora、listener.ora文件中HOST = 192.168.100.160 时,出现如下报错:
An error occurred while establishing the connection:
Long Message:
Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
Details:
Type: java.sql.SQLException
Error Code: 17002
SQL State: null
只有HOST = chub-rhel6-64时才能正确连接。