1,一般认为是只要tnsping能通,那么数据库就应该可以连接上,但是下面的这种情况就连接不上。
D:\Users\xionglang619>tnsping orcl
TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 21-2月 -
2013 13:00:18
Copyright (c) 1997, 2010, Oracle. All rights reserved.
已使用的参数文件:
C:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.25.
30.77)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)
))
OK (100 毫秒)
D:\Users\xionglang619>sqlplus test/test@orcl
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 21 13:04:13 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
2,这是为啥呢?无法失败service_name么?登陆数据库查看
[oracle@rac1 ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Feb 21 12:05:44 2013
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter service_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string orcl
这里确实也是orcl啊!查看了下oracle文档,oracle连接串的service_name 其实是net service name。如果domain的值非空,则它的值为service_name+'.'+domain
For example, if the client tnsnames.ora file contains a net service name of sales.us.acme.com, the user can enter the following connect string:
CONNECT scott/tiger@sales
In this example, sales gets searched as sales.us.acme.com.
If the connect string includes the domain extension, such as in CONNECT scott/[email protected], the domain is not appended. If a net service name in a tnsnames.ora file is not domain qualified and this parameter is set, the net service name must be entered with a dot ("."). For example, if domain is set to us.acme.com and the client tnsnames.ora file contains a net service name of sales, the user would enter the following connect string:
CONNECT scott/tiger@sales
这样tnsping连接不上,多半是设置了domain,查看数据库中domain的值
SQL> show parameter domain
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_domain string WORLD
3,修改连接串的值,修改后应该就可以了
D:\Users\xionglang619>tnsping orcl
TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 21-2月 -
2013 13:16:35
Copyright (c) 1997, 2010, Oracle. All rights reserved.
已使用的参数文件:
C:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.25.
30.77)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.
world)))
OK (90 毫秒)
D:\Users\xionglang619>sqlplus test/test@orcl
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 21 13:16:42 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
4,附上不能连通的原因:
因监听程序识别的service_name 没有一个orcl,而是orcl.world.
这是我的一点理解,如果有问题,还请提出来共同探讨。
SQL> host lsnrctl status orcl
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 21-FEB-2013 12:28:30
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 18-OCT-2012 11:32:53
Uptime 126 days 1 hr. 55 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/ora10g/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/ora10g/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl.WORLD" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.WORLD" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_XPT.WORLD" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully