萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mssql數據庫 >> 監聽中sqlnet.ora的作用

監聽中sqlnet.ora的作用

  sqlnet.ora最常用的兩個功能是:
客戶端起作用==連接方式 用於指定客戶端的名稱解析查詢的命名方法的順序。==>> NAMES.DIRECTORY_PATH=(tnsnames, onames, hostname)
服務端與客戶端同時起作用==認證方式==>> SQLNET.AUTHENTICATION_SERVICES

sqlnet.ora內容作用詳見官方文檔:http://docs.oracle.com/cd/B19306_01/network.102/b14213/sqlnet.htm#NETRF006
配置sqlnet.ora限制IP訪問Oracle http://blog.csdn.net/leshami/article/details/6629141
一些重要參數及解釋:
1.BEQUEATH_DETACH
控制unix系統中signal handling 的開關,默認是no,即signal handling 打開。
2.DEFAULT_SDU_SIZE
指定session data unit (SDU) 的大小,單位是bytes,建議在client端和server端都設置這個參數,確保鏈接的時候使用相同的SDU size,如果client端和server端配置的值不匹配會使用較小的。
3.LOG_DIRECTORY_CLIENT/LOG_DIRECTORY_SERVER
指定客戶端/server端log日志文件的位置
4.NAMES.DEFAULT_DOMAIN
設定客戶端解析名字的域
5.NAMES.DIRECTORY_PATH
指定client name解析方法的次序,默認是NAMES.DIRECTORY_PATH=(tnsnames, onames, hostname)
取值可以是tnsnames,ldap(dictionary server),hostname/ezconnect,cds (分布式環境下),nis (Network Information Service (NIS)
6.SQLNET_ALLOWED_LOGON_VERSIONS
指定運行鏈接的oracle的版本SQLNET_ALLOWED_LOGON_VERSIONS=(10,9,8)
7.SQLNET.AUTHENTICATION_SERVICES
指定啟動一個或多個認證服務
Authentication Methods Available with Oracle Net Services:
none for no authentication methods. A valid username and password can be used to access the database.
all for all authentication methods
nts for Windows NT native authentication
8.SQLNET.INBOUND_CONNECT_TIMEOUT
指定客戶端沒有鏈接成功超時的時間。超時之後oracle會中斷鏈接,同時報錯。
9.SSL_VERSION
指定ssl鏈接的版本
10.TCP.EXCLUDED_NODES
指定不允許訪問oracle的節點,可以使用主機名或者IP地址
11.TCP.INVITED_NODES
指定允許訪問db的客戶端,他的優先級比TCP.EXCLUDED_NODES高。
12.TCP.VALIDNODE_CHECKING
使用這個參數來啟用上邊的兩個參數。
13.TNSPING.TRACE_DIRECTORY
使用這個參數指定tnsping trace文件的目錄,默認是$ORACLE_HOME/network/trace目錄
更多參數信息參見:Oracle Database Net Services Reference

##################

連接時解析查詢的順序方式實驗: ==>> NAMES.DIRECTORY_PATH=(tnsnames, onames, hostname)

官方文檔上的說明:Use the parameter NAMES.DIRECTORY_PATH to specify the order of the naming methods used for client name resolution lookups.
NAMES.DIRECTORY_PATH==>>指定用於客戶端命名方法的名稱解析查詢的順序。不在此參數中的連接方式將不能用。
[oracle@ocm1 admin]$ cat tnsnames.ora
bys3 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT =1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bys3)
)
)

1.配置sqlnet.ora中包含:NAMES.DIRECTORY_PATH=(tnsnames),此時只能使用tnsnames中本地名,簡易連接將報錯

示例:
[oracle@ocm1 admin]$ vi sqlnet.ora
NAMES.DIRECTORY_PATH=(tnsnames)
~
[oracle@ocm1 admin]$ sqlplus bys/bys@bys3 --使用本地名可以連接
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:13:16 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit

[oracle@ocm1 admin]$ sqlplus bys/[email protected]:1521/bys3 --使用簡易連接的方法,不能連
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:13:27 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

2.配置sqlnet.ora中包含:NAMES.DIRECTORY_PATH=(tnsnames,ezconnect),此時使用tnsnames中本地名和簡易連接都可以

[oracle@ocm1 admin]$ cat sqlnet.ora
NAMES.DIRECTORY_PATH=(tnsnames,ezconnect)
使用tnsnames中本地名和簡易連接都可以
[oracle@ocm1 admin]$ sqlplus bys/bys@bys3
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:18:47 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>

[oracle@ocm1 admin]$ sqlplus bys/[email protected]:1521/bys3
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:13:59 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
#################################################

服務端與客戶端同時起作用==認證方式==>> SQLNET.AUTHENTICATION_SERVICES

有三個參數:
none for no authentication methods. A valid username and password can be used to access the database.
all for all authentication methods
nts for Windows NT native authentication ---這個只對WINDOWS上有用了。

當客戶端與服務端SQLNET.AUTHENTICATION_SERVICES=(ALL)無法 用AA/BB用戶名密碼登陸。有一邊是NONE即可連接。

1.服務器端不配置SQLNET.ORA文件,在客戶端配置SQLNET.AUTHENTICATION_SERVICES=(ALL),可以正常登陸。

[oracle@ocm1 admin]$ cat sqlnet.ora
NAMES.DIRECTORY_PATH=(tnsnames,ezconnect)
SQLNET.AUTHENTICATION_SERVICES=(ALL)
[oracle@ocm1 admin]$ sqlplus bys/bys@bys3
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:24:45 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

2.當客戶端與服務端同時配置:SQLNET.AUTHENTICATION_SERVICES=(ALL)無法用AA/BB用戶名密碼登陸

--接上一步實驗:
[oracle@bys3 admin]$ cat sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES=(ALL)
從OCM1主機上測試:登陸報錯:ORA-12641:
[oracle@ocm1 admin]$ sqlplus bys/bys@bys3
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 17 11:27:29 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12641: Authentication service failed to initialize
此時,將客戶端或服務器的之一的sqlnet.ora 改為SQLNET.AUTHENTICATION_SERVICES=(NONE),即可連接--道理同上一步實驗。

copyright © 萬盛學電腦網 all rights reserved