B.1 Net Service Name Definitions The primary purpose of an entry in the tnsnames.ora file is to link a net service name with a set of attributes that can be used to connect a client to an Oracle database. These attributes are loosely organized into the following two major categories: The protocol address for a net service name points the client to the physical server on which a database instance is running. You might also refer to a protocol address as a network address. The connection data identifies the specific database instance or service, running on that server, to which the client is to connect. B.1.1 Descriptions and Description Lists Taken together, the combination of a protocol address and connection data is referred to as a description . Most net service name definitions are fairly simple and consist of just one description. Here's an example: DONNA.GENNICK.ORG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) You can see that the two major components of the description are the address list and the connection data. If you're using an advanced Net8 feature such as load balancing, you may need to have multiple descriptions for a single net service name. You accomplish that by writing multiple descriptions and placing them in a description list. The following example shows a description list being used to implement connect-time failover: DONNA.GENNICK.ORG = (DESCRIPTION_LIST = (FAILOVER = true) (LOAD_BALANCE = false) (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = jonathan.gennick.org)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = herman.gennick.org) ) ) ) When a connection is attempted to donna.gennick.org , as defined in this example, Net8 first attempts the connection using the first description. If that connection attempt fails, Net8 then transparently switches to the second. Connect-time failover is discussed in Chapter 8. B.1.2 Protocol Addresses and Address Lists Within a description, you need to list one or more protocol addresses. These should normally be enclosed within an address list. However, Net8 confuses things by not requiring the use of an ADDRESS_LIST parameter when only one address list is used. The following two entries are equivalent: DONNA_CM.GENNICK.ORG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1630)) (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) ) (SOURCE_ROUTE = yes) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) DONNA_CM2.GENNICK.ORG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1630)) (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) (SOURCE_ROUTE = yes) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) The presence of the (SOURCE_ROUTE = YES) parameter tells you that connections made using these two net service names are routed through Connection Manager. Read Chapter 9, to learn more about that particular Net8 feature. | Prior to the release of Oracle8 i , you had to use an ADDRESS_LIST even for one address. | | It's more common to leave off the ADDRESS_LIST parameter when only one address is used than it is when multiple addresses are used. The following example shows two equivalent net service name definitions, each with one address: DONNA.GENNICK.ORG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) DONNA.GENNICK.ORG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = donna.gennick.org)(PORT = 1523)) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) A description may contain multiple address lists. The following definition shows such a description. When a connection is made, Net8 randomly chooses one address from the first list of addresses. If a listener can't be contacted at that address, Net8 then randomly chooses an address from the second list. If a listener still can't be contacted, Net8 returns an error, and the entire connection attempt fails. DONNA.GENNICK.ORG = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna01.gennick.org)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = donna02.gennick.org)(PORT = 1521)) (LOAD_BALANCE=ON) (FAILOVER=OFF) ) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = donna03.gennick.org)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = donna04.gennick.org)(PORT = 1521)) (LOAD_BALANCE=ON) (FAILOVER=OFF) ) (SOURCE_ROUTE = yes) (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) ) Most of the variations on addresses, address lists, descriptions, and description lists that you've seen here need to be coded by hand. Net8 Assistant, which presents a GUI interface for use in editing tnsnames.ora files, only supports the format with one description and one address list within that description. Where possible, we recommend using the format supported by Net8 Assistant. B.1.3 Connection Data The data needed to identify the instance, or the database, to which you want to connect represents the other half of the net service name equation. This data is always contained within a CONNECT_DATA parameter. Over the years , Oracle has developed several different ways to identify a database on a server. The currently recommended method is to use a service name, as shown in the following example: (CONNECT_DATA = (SERVICE_NAME = donna.gennick.org) ) The service name must match one of the service names listed after the SERVICE_NAMES parameter in the database instance's parameter file. In an Oracle8 i environment, these service names are automatically registered with the Net8 listener whenever an instance is started. That way, when a client requests to be connected to a particular service, the Net8 listener knows which instances support that service and can connect the client accordingly . Prior to the release of Oracle8 i , database instances were identified by their system identifier, or SID as it is more commonly called. Thus, on older systems, you will often see CONNECT_DATA entries that look like this: (CONNECT_DATA = (SID = donna) ) Net8 still supports this format for purposes of backward compatibility, and it's also useful if you're trying to connect remotely as SYSDBA or SYSOPER using SQL*Plus, Server Manager, or Enterprise Manager. If you want to shut down or start up an instance remotely, you need to connect to the specific instance, and to do that you need to specify the SID. |