Using the Easy Connect Naming Method

The Easy Connect naming method eliminates the need for service name lookup in the tnsnames.ora files for TCP/IP environments. In fact, no naming or directory system is required if you use this method.

This naming method provides out-of-the-box TCP/IP connectivity to databases. It extends the functionality of the host naming method by enabling clients to connect to a database server with an optional port and service name in addition to the host name of the database:

For URL or JDBC connections, it is required that the connect identifier is preceded by a double-slash (//). For example:

scott@//sales-server
Enter password: password

For SQL connections, it is optional that the connect identifier is preceded by a double-slash (//). For example, the following connect strings are semantically equivalent:

SQL> CONNECT scott@sales-server
Enter password: password

SQL> CONNECT scott@//sales-server
Enter password: password

host

Required. Specify the host name or IP address of the database host computer.

The host name is domain-qualified if the local operating system configuration specifies a domain.

You may use an IPv4 or IPv6 address as a value. IPv6 addresses or host names that resolve to IPv6 addresses must be enclosed in square brackets, as in [2001:0DB8:0:0::200C:417A] and [salesdb].

port

Optional. Specify the listening port.

The default is 1521.

service_name

Optional. Specify the service name of the database.

If a user specifies a service name, then the listener connects the user to that specific database. Otherwise, the listener connects to the database specified by the DEFAULT_SERVICE_listener_name parameter in the listener.ora file. If DEFAULT_SERVICE_listener_name is not configured for the listener and a service name is not explicitly specified by the user as part of the Easy Connect syntax, then the listener returns an error.

server

Optional. Specify the database server type to use.

This parameter instructs the listener to connect the client to a specific type of service handler.

The values for the server parameter are dedicated, shared, and pooled. If server is not specified in the Easy Connect syntax, then the type of server is chosen by the listener (shared server if configured, otherwise a dedicated server is used).

Note: In Oracle Call Interface documentation, server is referred to as connect_type.

instance_name

Optional. Used to identify the database instance to access.

The instance name can be obtained from the INSTANCE_NAME parameter in the initialization parameter file.

Easy Connect naming is automatically configured at installation. Before using it, you may want to ensure that EZCONNECT is specified by the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file. This parameter specifies the order of naming methods Oracle Net can use to resolve connect identifiers to connect descriptors.

Configuring Easy Connect Naming to Use a DNS Alias

You can optionally configure a DNS alias for the host name, as provided with the host naming method in Oracle Database 11g. With host naming, clients use a connect string that uses the following pattern:

CONNECT username@DNSalias
Enter password: password

To configure a DNS alias:

Ensure the database service is registered with the listener.

If the database can find the listener, then information about the database service is dynamically registered with the listener during service registration, including the service name. The listener is found if the following conditions are met:

The default listener named LISTENER on TCP/IP, port 1521 is running.

The LOCAL_LISTENER parameter is set in the initialization file.

If the database cannot find the listener, then configure the listener.ora file with the GLOBAL_DBNAME parameter, as shown in the following example

You can configure a mechanism such as DNS, NIS, or a centrally-maintained TCP/IP host file, /etc/hosts. For example, if a service name of sales-server for a database exists on a computer named sales.us.example.com, then the entry in the /etc/hosts file would look like the following:

Configuring the Local Naming Method

The local naming method adds net service names to the tnsnames.ora file. Each net service name maps to a connect descriptor.

Example 8-2 shows the net service name sales mapped to the connect descriptor contained in DESCRIPTION. The DESCRIPTION section contains the protocol address and identifies the destination database service. In this example, the protocol is TCP/IP and the port is 1521.

Administrator or run-time installation: Oracle Net Configuration Assistant prompts you to configure net service names in the tnsnames.ora file to connect to an Oracle Database service.

Custom installation: Oracle Net Configuration Assistant prompts you to select naming methods to use. If local is selected, then Oracle Net Configuration Assistant prompts you to configure net service names in the tnsnames.ora file to connect to an Oracle Database service.

Configuring the tnsnames.ora File After Installation

You can add net service names to the tnsnames.ora file at any time after installation. To configure the local naming method, perform the following tasks:

The default setting of Database Default is recommended for the connection type. If shared server is configured in the initialization parameter file, then you can select Dedicated Server to force the listener to spawn a dedicated server, bypassing shared server configuration. If shared server is configured in the initialization parameter file and you want to guarantee the connection always uses shared server, then select Shared Server.

Select a release, enter a destination service name, and optionally, select a database connection type.

Oracle recommends that you use the default setting of Database Default for the connection type. If shared server is configured in the initialization parameter file, then you can select Dedicated Server to force the listener to spawn a dedicated server, bypassing shared server configuration. If shared server is configured in the initialization parameter file and you want to guarantee the connection always uses shared server, then select Shared Server.

Click Test to verify that the net service name works, or click Finish to dismiss the Net Service Name wizard.

If you click Test, then Oracle Net connects to the database server by using the connect descriptor information you configured. Therefore, the listener and database must be running for a successful test. If they are not, then see "Starting Oracle Net Listener and the Oracle Database Server" to start components before testing. During testing, a Connection Test dialog box appears, providing status and test results. A successful test results in the following message:

The connection test was successful.

If the test was successful, then click Close to close the Connect Test dialog box, and proceed to Step 13.

If the test was not successful, then do the following:

Ensure that the database and listener are running, and then click Test.

Click Change Login to change the user name and password for the connection, and then click Test.

Follow the prompts in the wizard and online help to complete net service name creation.

Task 2 Configure Local Naming as the First Naming Method

Configure local naming as the first method specified in the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file. This parameter specifies the order of naming methods Oracle Net uses to resolve connect identifiers to connect descriptors.

To configure the local naming method as the first naming method, use one of the following methods:

After one client is configured, it is best to simply copy the tnsnames.ora and sqlnet.ora configuration files to the same location on the other clients. This ensures that the files are consistent. Alternatively, you can use Oracle Net Assistant on every client.

Task 4 Configure the Listener

Ensure that the listener located on the server is configured to listen on the same protocol address configured for the net service name. By default, the listener is configured for the TCP/IP protocol on port 1521.

Configuring the Directory Naming Method

With the directory naming method, connect identifiers are mapped to connect descriptors contained in an LDAP-compliant directory server, such as Oracle Internet Directory and Microsoft Active Directory. A directory provides central administration of database services and net service names, making it easier to add or relocate services.

A database service entry is created with Database Configuration Assistant during installation. Oracle Enterprise Manager and Oracle Net Manager are used to create and modify net service names and net service alias entries, and to modify the database service entry. Clients can use these entries to connect to the database.

To configure the directory naming method, perform the following tasks:

In addition, if the error occurs, then the following message will be added to the error log:

Configuration exception: Could not check for the Oracle Schema:
oracle.net.config.ConfigException: TNS-04409: Directory Service Error

This error usually occurs in the following situations:

No Oracle Context exists in the directory. The Oracle Internet Directory installer or other Oracle Internet Directory tool should be used to create an Oracle Context.

If the Oracle Internet Directory directory is release 11, then, by default, it will not allow anonymous binds, and may prevent Oracle Net Configuration Assistant from accessing the Oracle Context. Check the configuration of the Oracle Internet Directory server for the following parameter. If the parameter is set to 0, then change it to 1.

dn: cn=oid,cn=osdldapd,cn=subconfigsubentry
orlanonymousbindsflag: 1

Task 2 Create Net Service Names in the Directory

You can configure clients to use a net service name rather than the database service entry. To create net service names, do the following:

Notes:

Only users that are members of either the OracleNetAdmins or OracleContextAdmins group can create net service name entries in a directory. To add or remove users from the OracleNetAdmins group, see "Adding Users To the OracleNetAdmins Group".

Select a database connection type. Oracle recommends that you use the Database Default for the connection type. If shared server is configured in the initialization parameter file, then the following options are available:

When database registration with the directory naming completes, Database Configuration Assistant creates a database service entry in the directory. By default, this entry contains network route information with the location of the listener through a protocol address. You can re-create this information or modify the existing network route information.

Note:

Only users that are members of the OracleNetAdmins or OracleContextAdmins group can modify network information for a database service in a directory. To add or remove users from these groups, see "Adding Users To the OracleNetAdmins Group".

To create or modify network route information for a database service, do the following:

Select Directory Naming from the Administer list, and then select the Oracle home that contains the location of the directory server.

Click Go. You may be prompted to log in to the database server and the directory server.

The Directory Naming page appears.

Click the Database Services tab.

In the Simple Search section, select Oracle Context and search criteria to see the net service names for Oracle Context.

The database service names display in the Results section.

In the Results section, select a database service, and then click Edit.

Task 4 Create Net Services Aliases

Net service aliases in a directory server enable clients to refer to a database service or a net service name by an alternative name. For example, a net service alias of salesalias can be created for a net service name of sales. When salesalias is used to connect to a database, as in CONNECT scott@salesalias, it resolves to and use the connect descriptor information for sales.

There are two main uses of net service aliases:

Use a net service alias as a way for clients to refer to a database service or net service name by another name.

Use a net service alias in one Oracle Context for a database service or net service name in a different Oracle Context. This enables a database service or net service name to be defined once in the directory server, and referred to by clients that use other Oracle Contexts.

Only users that are members of either the OracleNetAdmins or OracleContextAdmins group can create or modify net service alias entries in a directory. To add or remove users from the OracleNetAdmins group, see "Adding Users To the OracleNetAdmins Group".

To create or access net service aliases, ensure that the Oracle home is at least release 9.2.0.4.

Net service aliases are not supported by Microsoft Active Directory.

Ensure the NLS_LANG environment variable is set for the clients when using net service aliases.

Configure directory naming as the first method to be used in the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file. This parameter specifies the order of naming methods Oracle Net uses to resolve connect identifiers to connect descriptors. To configure LDAP as the first naming method you can use one of the following methods:

From the Available Methods list, select LDAP, and then click the right-arrow button.

From the Selected Methods list, select LDAP, and then use the Promote button to move the selection to the top of the list.

Select Save Network Configuration from the File menu.

The sqlnet.ora file updates with the NAMES.DIRECTORY_PATH parameter, listing ldap first, such as the following:

NAMES.DIRECTORY_PATH=(ldap, tnsnames, hostname)

Task 6 Configure the Listener

Ensure that the listener located on the server is configured to listen on the same protocol address configured for the net service name. By default, the listener is configured to listen on the TCP/IP protocol, port 1521.

Creating Multiple Default Contexts in a Directory Naming Server

If you want clients to use discovery in directories which have more than one Oracle Context, then you can define the orclCommonContextMap attribute in the base admin context; this overrides the orclDefaultSubscriber attribute. During name lookup the discovery operation returns both values, and the client decides based on these which Oracle Context to use.

If the orclCommonContextMap attribute is not defined, then the orclDefaultSubscriber will be used as the default. If orclCommonContextMap is defined, then the client finds the default Oracle Context which is associated with its DNS domain in the orclCommonContextMap. To enable multiple default contexts, define the orclCommonContextMap with a list of associations between a domain and a DN to be used as the default oracleContext. A sample LDIF file entry is shown here:

For example, if the tnsnames.ora file supports a domain structure example.com and you want to replicate this domain in the directory, then create domain component entries of dc=com and dc=example in the directory, as shown in Figure 8-1.

You can replicate the domain structure you currently use with tnsnames.ora, or you can develop an entirely different structure. Introducing an entirely different structure can change the way clients enter the net service name in the connect string. Oracle recommends considering relative and fully-qualified naming issues before changing the structure.

Create an Oracle Context under each DIT location that you created in Task 1 using Oracle Internet Directory Configuration Assistant. Oracle Context has a relative distinguished name (RDN) of cn=OracleContext. Oracle Context stores network object entries, as well as other entries for other Oracle components. In Figure 8-2, cn=OracleContext is created under dc=example,dc=com.

If the tnsnames.ora file you want to export is not loaded in Oracle Net Manager, then select Open Network Configuration from the File menu to select the tnsnames.ora file to export to the directory.

Select Directory from the Command menu, and then select Export Net Service Names.

The Directory Server Migration wizard starts.

Click Next.

If net service names with multiple domain were detected in the tnsnames.ora file, then the Select Domain page appears. Continue to Step 5.

If the net service names are not domain qualified, then the Select Net Service Names page appears. Skip to Step 6.

Select the network domain whose net service names you want to export, and then click Next.

The Select Net Service Names page appears.

Select the net service names from the list to export, and then click Next.

The Select Destination Context page appears.

In the Select Destination Context page, perform the following:

From the Directory Naming Context list, select the directory entry that contains the Oracle Context. The directory naming context is part of a directory subtree that contains one or more Oracle Contexts.

From the Oracle Context list, select the Oracle Context to which you want to export the selected net service names.

Click Next.

The Directory Server Update page appears with the status of the export operation.

Click Finish to dismiss the Directory Server Migration wizard.

Exporting Directory Naming Entries to a tnsnames.ora File

After you create the directory naming entries, consider exporting the entries to a local tnsnames.ora file, and distributing that file to clients. Clients can use the locally saved file when a directory server is temporarily unavailable.

To export directory naming entries to a local tnsnames.ora file, do the following:

Select Directory Naming from the Administer list, and then select the Oracle home that contains the location of the directory server.

Click Go.

The Directory Naming page appears.

Click the Net Service Names tab.

In the Simple Search section, select Oracle Context and search criteria to see the net service names for a particular Oracle Context.

The net service names display in the Results section.

In the Results section, click Save to tnsnames.ora.

The Processing: Create tnsnames.ora File page appears, informing you of the creation process.

Configuring External Naming Methods

External naming refers to the method of resolving a net service name, stored in a third-party naming service, to a network address, such as network information services (NIS). Organizations and corporations using NIS as part of their systems infrastructure have the option to store net service names and addresses in NIS, using NIS external naming.

For example, when a user gives a command such as the following and payroll is a net service name:

sqlplus scott@payroll
Enter password: password

NIS external naming on the node running the client program or database server acting as a client program contacts an NIS server located on the network, and passes the net service name to the NIS server. The NIS server resolves the net service name into an Oracle Net address and returns this address to the client program or server. The client program then uses this address to connect to Oracle Database.

An NIS server runs a program called ypserv, which handles name requests. The ypserv program stores different types of data in special files called maps. For example, passwords are stored in a map called passwd.byname. Oracle Database service names are stored in a map called tnsnames.

When a user uses a connect string, NIS external naming uses an RPC call to contact the ypserv program, and passes the Oracle net service name and the name of the map. The ypserv program looks in the tnsnames map for the name, such as payroll, and its address for the net service name. The address is returned to the client, and the client program uses the address to contact the database server.

Note:

The NIS external naming method is not available on all platforms. Use the adapters command to check availability of NIS external naming on your system. If available, then it is listed under Oracle Net naming methods, as follows:

Before configuring servers to support NIS external naming, ensure that NIS is configured and running on the NIS servers that need to resolve Oracle Database net service names. Consult your NIS documentation for specifics. To complete this task, add the tnsnames map to the existing NIS maps, and then verify that the tnsnames map has been installed properly.

Keep a copy of the tnsnames.ora file, preferably in ORACLE_HOME/network/admin directory. You may need to use this file again later to load net service names into the NIS map.

Convert the contents of the tnsnames.ora file to a tnsnames map using the tns2nis program similar to the following:

tns2nis tnsnames.ora

The tns2nis program reads the tnsnames.ora file from the current directory. If tnsnames.ora file is not located in the current directory, then you can use a full path name to specify its location, such as /etc/tnsnames.ora or ORACLE_HOME/network/admin/tnsnames.ora.

The tnsnames map is then written into the current working directory.

Note:

The tns2nis program is supplied with NIS external naming.

Copy tnsnames to the NIS server.

Install the tnsnames map using makedbm, which is an NIS program.

Note:

This step should be performed by the person in charge of NIS administration.

The makedbm program converts the tnsnames map into two files that the NIS server can read. The location of these files is operating system specific.

See Also:

Oracle operating system-specific documentation for details

For example, to generate and install a tnsnames map on Linux, as the root user, enter the following at the command line:

# makedbm tnsnames /var/yp/'domainname'/tnsnames

Verify tnsnames has been installed properly using the following command:

ypmatch net_service_name tnsnames

For example, you might enter the following command:

ypmatch example.com tnsnames

This returns the length of the address in characters, followed by the address such as the following:

To configure clients, configure NIS as the first method specified in the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file. This parameter specifies the order of naming methods Oracle Net can use to resolve connect identifiers to connect descriptors.