Wednesday, August 13, 2008

Oracle Net - Dedicated and shared connections

When you configure your database to use Shared Server (previously called Multi-threaded server or MTS), all client requests are handed off to one of the shared server processes by the listener, via a dispatcher. If you want certain clients to use a dedicated server process, you need to set the dedicated server option in your database connect string: ie

sqlplus scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=\
(PROTOCOL=TCP)(PORT=1521)(NODE=shep.alcyontech.com)))\
(CONNECT_DATA=(SERVICE_NAME=macie.alcyontech.com)\
(SERVER=DEDICATED)))

(normally you will type this all on one line but the "\" allows you to escape the CRLF on many systems.

Note that although Oracle 11g docs give an example of a connect_option "SERVER_NAME": there is no such option; the only options are SERVICE_NAME, and SERVER, and they are a pair, you can not use SERVER=DEDICATED without indicating the service.

As the above is kinda a drag when you want to log in, you may choose to add an entry to your tnsnames.ora file that will give you an alias that uses a lot less typing:

MACED =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = shep.alcyontech.com)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVICE_NAME = macie.alcyontech.com)
(SERVER=dedicated)
)
)

Note that MACED is a net_service_name or alias for that connection descriptor, and like your instance name is just a label that you select; it need not be the database name or the instance name. The significance of this is that you can change the net_service_name to any alias you like at any time, so if you first use this connector for development, you can call it "devd" and later "testd" and then "prodd" (if you are using two connection descriptors, one dedicated and one shared, you may want to change both aliases at the same time).

Other notes:

For RAC installations, Oracle recommends that you do not set the service_name in the initsid.ora file, just use SQL>> show parameter name to find out what it currently is, and use that.

You can also set the connection method in sqlnet.ora, but that will set all connections to a single mode; this discussion is about how you set up to use either. Also note that if you do use sqlnet.ora to set shared or dedicated connections that will OVERRIDE any selection indicated in the connect section of the descriptor.

No comments: