tnsnames.ora 是什麼

Tnsnames.ora

TNSNAMES.ORA is a SQL*Net configuration file that defines databases addresses for establishing connections to them. This file normally resides in the ORACLE HOME\NETWORK\ADMIN directory.

tnsnames.ora 是一個oracle數據庫網絡配置文件,通過這個配置文件才能建立對數據庫的連接。這個文件通常位於"ORACLEHOME(oracle數據庫的安裝目錄)\NETWORK\ADMIN\ 目錄下

Contents

 [show

[edit]Configuring TNSNAMES.ora

[edit]Text editor

Add the following entry in your TNSNAMES.ORA file and change the values shown in brackets to suit your environment:

<addressname> =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(Host = <hostname>)(Port = <port>))
   )
 (CONNECT_DATA =
   (SERVICE_NAME = <sid>)
 )
)

<addrssname>是自定義的名字。就是把下面的連接特定IP+端口+數據庫實例的這個連接命名一下,連接時就直接用該名字來指定連接。

<hostname>可以是主機名,可以是IP.填寫數據庫服務器所在機器IP。如在本機則爲127.0.0.1或localhost

<port>默認爲1521.這個端口是oracle數據庫服務端口號

<service_name>是數據庫實例名,你要連接的數據庫實例。

Here is a completed example:下面是一個完整的例子

ORA11 =
  (DESCRIPTION = 
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
 (CONNECT_DATA =
   (SERVICE_NAME = ORA11)
 )
)

The TNSNAMES.ORA files are located on both client and server systems. If you make configuration changes on the server ($ORACLE_HOME/network/admin/tnsnames.ora) ensure you can connect to the database through the listener if you are logged on to the server. If you make configuration changes on the client (c:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora) ensure you can connect from your client workstation to the database through the listener running on the server.

tnsnames.ora同時存在於數據庫客戶端與服務器端(客戶端與服務端不在同一臺主機中)。如果在客戶端連遠程的數據庫服務器,你就要編輯客戶機上的tnsnames.ora。數據庫服務端主機上的tnsnames.ora則可以不編輯。如果你在數據庫服務端所在機器上登錄連接數據庫,你就要編輯服務端的tnsnames.ora。客戶端的可以不編輯。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章