前几天重新安装了数据库服务器,在服务器上使用都一切正常。然后在我的客户端配置一个tns服务名,通过sqlplus命令来连接,确报错:
C:\Documents and Settings\myname>sqlplus
sys/password@orcl118
SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 3月 1 18:41:06 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
查看服务器端的
listener.ora ,内容如下:
# listener.ora Network Configuration File: /usr/app/oracle/product/10.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(PROGRAM = extproc)
)
)
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = oraclesvr)(PORT = 1521))
)
)
SQL> show parameter service_name
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = oraclesvr)(PORT = 1521))
)
)
SQL> show parameter service_name
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
service_names string
orcl
------------------------------------ ---------------------------------
VALUE
------------------------------
service_names string
orcl
没有发现问题,再看客户端的
tnsnames.ora ,如下:
ORCL118 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.118)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.118)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
也没发现问题了,客户端删除再重建了几次“本地net服务名配置”,没有任何作用。对比了tnsnames文件中其他的连接,配置信息几乎完全一致,其他连接确可以正常连接。
然后我通过
tnsping 来ping数据库服务器Ip和端口:
C:\Documents and Settings\myname>tnsping 192.168.0.118
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 02-3月 -2011 11:00:
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的参数文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 EZCONNECT 适配器来解析别名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=192.168.0.118))(ADDRESS=(PRO
TNS-12560: TNS: 协议适配器错误
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=192.168.0.118))(ADDRESS=(PRO
TNS-12560: TNS: 协议适配器错误
C:\Documents and Settings\myname>tnsping orcl118
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 02-3月 -2011 11:18:
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的参数文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192
TNS-12560: TNS: 协议适配器错误
看来tnsping都不行,肯定就不要指望连接使用了。
再用
telnet 看看能不能连接这个IP的1521端口。
C:\Documents and Settings\myname>telnet 192.168.0.118 1521
正在连接到192.168.0.118 ...不能打开到主机的连接, 在端口 1521: 连接失败
进一步证实,应该就是1521端口问题了。
通过
netca 界面方式删除服务器端的监听,重新配置监听,重启机器。关闭服务器端的防火墙后,重启监听和数据库,再通过sqlplus连接成功。
服务器端:
$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 02-3æ -2011 14:15:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
$ which lsnrctl 查看使用的命令位置,在此没作用
/usr/app/oracle/product/10.2/db_1/bin/lsnrctl
The command completed successfully
$ which lsnrctl 查看使用的命令位置,在此没作用
/usr/app/oracle/product/10.2/db_1/bin/lsnrctl
$ lsnrctl start 启动监听
$ lsnrctl status 查看监听状态
客户端:
C:\Documents and Settings\myname>sqlplus
sys/password@orcl118 as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 15:47:50 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
若数据库的服务没有启动,远程连接还是会报错:
C:\Documents and Settings\myname>sqlplus
sys/password@orcl118 as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 18:18:14 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
请输入用户名:
要想在不启动数据库服务的时候能连接上,就需要修改数据库服务器端的监听配置文件
listener.ora,在里面增加以下段(加粗)
$ cat listener.ora
# listener.ora Network Configuration File: /usr/app/oracle/product/10.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
# listener.ora Network Configuration File: /usr/app/oracle/product/10.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(SID_NAME = orcl)
)
)
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /usr/app/oracle/product/10.2/db_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oraclesvr)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oraclesvr)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
重启监听后,再连接。
C:\Documents and Settings\myname>sqlplus
sys/password@orcl118 as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 18:23:48 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到空闲例程。
SQL>
附录:
linux下启动和关闭防火墙
1) 重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop
需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
在开启了防火墙时,做如下设置,开启相关端口,
修改/etc/sysconfig/iptables 文件,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9399028/viewspace-688278/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9399028/viewspace-688278/