700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > oracle数据库连接时报12514_Oracle连接数据库报错 ORA-12514

oracle数据库连接时报12514_Oracle连接数据库报错 ORA-12514

时间:2021-03-27 16:43:00

相关推荐

oracle数据库连接时报12514_Oracle连接数据库报错 ORA-12514

前几天重新安装了数据库服务器,在服务器上使用都一切正常。然后在我的客户端配置一个tns服务名,通过sqlplus命令来连接,确报错:

C:\Documents and Settings\myname>sqlplussys/password@orcl118

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 3月 1 18:41:06

Copyright (c) 1982,,Oracle.All rights reserved.

ERROR:

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.

SID_LIST_LISTENER =

(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

NAMETYPE

------------------------------------

---------------------------------

VALUE

------------------------------

service_namesstring

orcl

没有发现问题,再看客户端的tnsnames.ora,如下:

ORCL118 =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.118)(PORT =

1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)

也没发现问题了,客户端删除再重建了几次“本地net服务名配置”,没有任何作用。对比了tnsnames文件中其他的连接,配置信息几乎完全一致,其他连接确可以正常连接。

然后我通过

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月 - 11:00:

Copyright (c) 1997, , Oracle.All rights

reserved.

已使用的参数文件:

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: 协议适配器错误

C:\Documents and Settings\myname>tnsping

orcl118

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 -

Production on 02-3月 - 11:18:

Copyright (c) 1997, , Oracle.All rights

reserved.

已使用的参数文件:

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都不行,肯定就不要指望连接使用了。

再用

C:\Documents and Settings\myname>telnet

192.168.0.118 1521

正在连接到192.168.0.118 ...不能打开到主机的连接, 在端口 1521: 连接失败

进一步证实,应该就是1521端口问题了。

通过

服务器端:

LSNRCTL forLinux:

Version 10.2.0.1.0 - Production on 02-3æ - 14:15:46

Copyright (c) 1991, , 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

$ lsnrctl start 启动监听

$ lsnrctl status 查看监听状态

客户端:

C:\Documents and Settings\myname>sqlplussys/password@orcl118as

sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 15:47:50

Copyright (c) 1982, , Oracle.All rights

reserved.

连接到:

Oracle Database10gEnterprise

Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

若数据库的服务没有启动,远程连接还是会报错:

C:\Documents and Settings\myname>sqlplussys/password@orcl118as

sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 18:18:14

Copyright (c) 1982, , Oracle.All rights

reserved.

ERROR:

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.

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)

))

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION

=

(ADDRESS = (PROTOCOL = TCP)(HOST = oraclesvr)(PORT =

1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

重启监听后,再连接。

C:\Documents and Settings\myname>sqlplussys/password@orcl118as

sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 3月 2 18:23:48

Copyright (c) 1982, , 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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。