溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何理解sqlnet.ora文件中EZCONNECT參數(shù)與Easy Connect Naming Method方法

發(fā)布時間:2021-11-04 10:39:24 來源:億速云 閱讀:283 作者:柒染 欄目:建站服務(wù)器

如何理解sqlnet.ora文件中EZCONNECT參數(shù)與Easy Connect Naming Method方法,針對這個問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

如果對tnsnames.ora文件沒有做充分的配置,也可以使用Oracle的Easy Connect Naming Method方法測試數(shù)據(jù)庫是否可以訪問。
這里不對這種方法的原理和詳細(xì)用法展開描述,這方面的信息可以通過以下Oracle連接獲得。
http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/naming.htm#i498306
或直接訪問下屬文章進(jìn)行參考。
Net Services Administrator's Guide - 2 Quick Start to Oracle Net Connections - Task 3: Configure the Client for Connection to a Database
Net Services Administrator's Guide - 8 Configuring Naming Methods - Using the Easy Connect Naming Method

簡單列一下該方法的使用語法,供參考。
CONNECT username/password@host[:port][/service_name][/instance_name]
CONNECT username/password@[//]host[:port][/service_name]

本文想要強(qiáng)調(diào)指出的是,如果想要使用Easy Connect Naming Method方法測試數(shù)據(jù)庫的連通性,需要在sqlnet.ora文件中增加“NAMES.DIRECTORY_PATH= (EZCONNECT)”信息,否則該功能將無法使用。

1.sqlnet.ora文件的位置
該文件與listener.ora和tnsnames.ora文件處于同一目錄,具體目錄為:$ORACLE_HOME/network/admin。

2.體驗報錯,以此為鑒
如果是Windows客戶端沒有配置相應(yīng)的參數(shù),會收到如下報錯:
C:\Users\secooler>sqlplus sec/sec@10.17.193.211:1521/ora10g

SQL*Plus: Release 10.2.0.3.0 - Production on 星期一 8月 2 21:19:01 2010

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

ERROR:
ORA-12154: TNS: 無法解析指定的連接標(biāo)識符


請輸入用戶名:
ERROR:
ORA-12560: TNS: 協(xié)議適配器錯誤


請輸入用戶名:
ERROR:
ORA-12560: TNS: 協(xié)議適配器錯誤


SP2-0157: 在 3 次嘗試之后無法連接到 ORACLE, 退出 SQL*Plus

C:\Users\secooler>

如Linux服務(wù)器端的sqlnet.ora文件沒有設(shè)置相應(yīng)的參數(shù),將會收到如下錯誤:
sec@secdb /home/oracle$ sqlplus sec/sec@10.17.193.211:1521/ora10g

SQL*Plus: Release 10.2.0.3.0 - Production on Mon Aug 2 21:21:34 2010

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

兩種錯誤內(nèi)容是一樣的,從錯誤提示上看,很難直接定位是由于sqlnet.ora文件配置問題導(dǎo)致的。這就需要我們對Easy Connect Naming Method的原理深入了解。

3.向sqlnet.ora文件中添加“EZCONNECT”信息,解決該問題
“EZCONNECT”這個單詞很好理解,從發(fā)音上即可等同于“Easy Connect”。從此,該參數(shù)將不再陌生。
sec@secdb /home/oracle$ cat $ORACLE_HOME/network/admin/sqlnet.ora
# sqlnet.ora Network Configuration File: /oracle/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT)

在添加完參數(shù)后嘗試連接,成功。
sec@secdb /oracle$ sqlplus sec/sec@10.17.193.211:1521/ora10g

SQL*Plus: Release 10.2.0.3.0 - Production on Mon Aug 2 21:31:50 2010

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

sec@ora10g>


Oracle提供了很多類似文中提到的Easy Connect Naming Method小技巧。建議在使用這些便捷方法之前充分了解工具使用的前提和約束,這樣可以在提高效率的同時不至于帶來太多的障礙。

關(guān)于如何理解sqlnet.ora文件中EZCONNECT參數(shù)與Easy Connect Naming Method方法問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI