深入探讨Oracle网络服务解析

近来,浏览BBS时,常看到“Oracle网络服务解析”的疑问,针对以上这类问题,我归纳总结了5种常用的方法。具体如下:
1、Oracle Internet Directory
2、External Naming
3、主机命名
4、Oracle Easy Connect
5、本地命名

下面分别介绍这五种方法:
第一种:Oracle Internet Directory管理复杂的Oracle网络服务器时有优势,管理员可以在一个比较集中位置配置和管理Net Service Names
第二种:External Naming 使用非Oracle工具管理和解析Oracle网络服务名称
第三种:主机命名方法(客户端为windows xp,服务器端为linux+oracle 9i)

1、配置客户端的sqlnet.ora

 
 
 
  1. # sqlnet.ora Network Configuration File: D:oracleproduct10.2.0client_1NETWORKADMINsqlnet.ora
  2. # Generated by Oracle configuration tools.
  3. # This file is actually generated by netca. But if customers choose to 
  4. # install "Software Only", this file wont exist and without the native 
  5. # authentication, they will not be able to connect to the database on NT.
  6. SQLNET.AUTHENTICATION_SERVICES= (NTS)
  7. NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME)

2、配置服务器端的listener.ora

 
 
 
  1. [oracle@linuxoracle admin]$ vi listener.ora
  2. # LISTENER.ORA Network Configuration File: /u01/app/oracle/product/9.2.0/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.
  4. LISTENER =
  5. (DESCRIPTION =
  6. (ADDRESS = (PROTOCOL = TCP)(HOST = linuxoracle)(PORT = 1521)) #注意HOST配置为主机名
  7. )
  8. SID_LIST_LISTENER =
  9. (SID_LIST =
  10. (SID_DESC =
  11. (GLOBAL_DBNAME = linuxoracle) #注意GLOBAL_DBNAME为主机名
  12. (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
  13. (SID_NAME = dg1)
  14. )
  15. (SID_DESC =
  16. (GLOBAL_DBNAME = linuxoracle)
  17. (ORACLE_HOME = /u01/app/oracle/product/9.2.0)
  18. (SID_NAME = OEMREP)
  19. )
  20. )

说明:
如果没有正确配置GLOBAL_DBNAME,sqlplus连接时,会报如下错误:

 
 
 
  1. C:Documents and Settings ew>sqlplus system/lijie123@linuxoracle
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 9月 19 17:31:52 2007
  3. Copyright (c) 1982, 2005, Oracle. All rights reserved.
  4. ERROR:
  5. ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务

3、配置完后,sqlplus连接
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

 
 
 
  1. C:Documents and Settings ew>sqlplus system/lijie123@linuxoracle
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 9月 19 17:19:48 2007
  3. Copyright (c) 1982, 2005, Oracle. All rights reserved.
  4. ERROR:
  5. ORA-12154: TNS: 无法解析指定的连接标识符

报这样的错误,说明sqlplus不能正确解析linuxoracle,可能hosts或DNS的问题!!!
用记事本打开hosts
内容如下(省略了一部分):

 
 
 
  1. ..............................................................
  2. # 102.54.94.97 rhino.acme.com # source server
  3. # 38.25.63.10 x.acme.com # x client host
  4. 127.0.0.1 localhost
  5. 修该为:
  6. ...............................................................
  7. # 102.54.94.97 rhino.acme.com # source server
  8. # 38.25.63.10 x.acme.com # x client host
  9. 127.0.0.1 localhost
  10. 192.168.1.61 linuxoracle

4、sqlplus连接oracle服务器#p#

 
 
 
  1. C:Documents and Settings ew>sqlplus system/lijie123@linuxoracle
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 9月 19 18:37:51 2007
  3. Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:

 
 
 
  1. Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
  2. With the Partitioning, OLAP and Oracle Data Mining options
  3. JServer Release 9.2.0.4.0 - Production

SQL>
成功!!!

第四种:Oracle Easy Connect
只在oracle 10g以上版本使用
Oracel Easy Connect Naming
使用oracle easy connect naming必须满足以下要求
1、oracle net services 10g必须安装在客户端
2、客户端及服务器端必须支持TCP/IP,并启用
3、不允许高级连接描述符特性,如:连接池、外部过程调用
配置oracle easy connect naming
在sqlnet.ora增加下面这行:

 
 
 
  1. NAMES.DIRECTORY_PATH=(EZCONNECT,TNSNAMES) #注意增加了EZCONNECT

oracle easy connect naming方法示例
eg:

 
 
 
  1. connect scott/tiger@hostname:port/servicesname
  2. connect scott/tiger@//hostname/servicesname

解释:
语法构件 描述
// 任选:通过URL连接时使用
hostname 必选: 主机名或IP
port 任选:端口号
servicesname 必选:oracle网络服务的名称

第五种:本地命名法
本地命名方法也被称为tnsnames.ora方法
可用Oracle net manager配置本地命名方法(当然也可以用OEM)
打开Oracle net manager,在Local选项中选择Service Naming进行添加,添加好的tnsnames.ora内容如下:

 
 
 
  1. eg:
  2. TEST =
  3. (DESCRIPTION =
  4. (ADDRESS_LIST =
  5. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.61)(PORT = 1521))
  6. )
  7. (CONNECT_DATA =
  8. (SERVICE_NAME = dg1)
  9. )
  10. )
  11. TEST为网络服务名,SERVICE_NAME为oracle的服务名

以上就探讨了些Oracle网络服务一般常用的解析方法,要想了解的更多相关问题的解决方案,请留意站上的相关论坛。

当前标题:深入探讨Oracle网络服务解析
浏览路径:http://www.hantingmc.com/qtweb/news28/479278.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联