客户机为了和服务器连接,必须先和服务器上的监听进程联络。ORACLE通过tnsnames.ora文件中的连接描述符来说明连接信息。一般tnsnames.ora 是建立在客户机上的。如果是客户机/服务器结构,整个网络上只有一台机器安装了ORACLE数据库服务器,那么只需在每个要访问ORACLE服务器的客户机上定义该文件,在服务器上无需定义。但是,如果网络上有多台机器均安装了ORACLE数据库服务器,并且服务器之间有数据共享的要求,那么在每台服务器上都必须定义该文件。tnsnames.ora文件缺省放在/ORACLE_HOME/ product/8.1.7/network/admin目录下。下面是tnsnames.ora的文件样式:
ORA817 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = sun62)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = ora817.huawei.com) ) ) INST1_HTTP = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = sun62)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = SHARED) (SERVICE_NAME = ora817.huawei.com) (PRESENTATION = http://admin) ) ) EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )