Description of Oracle dedicated server and shared server (private mode and sharing mode)

Source: Internet
Author: User
Tags connection pooling sessions dedicated server sqlplus

I. Official website description

When we built the DBCA, we were prompted to choose the connection type, there are two types: Dedicated server mode and shared server mode. Private mode is used by default. Such as:

The Oracle official documentation describes the two documents as follows:

About dedicated andshared Server Processes

Http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/manproc001.htm

Oracledatabase creates server processes to handle the requests of user processesconnected to an instance. A server process can be either of the following:

(1) A dedicated server process, which services only one userprocess

(2) A shared server process, which can service multiple userprocesses

Oracle creates a server process to handle requests from the user processes connection instance. The server process is divided into two types: Dedicated server process and sharedserver process.

Yourdatabase is always enabled for allow dedicated server processes, but you mustspecifically configure and enable shared S Erver by setting one Ormore initialization parameters.

1.1 Dedicated Server Processes

Figure4-1, "Oracle Database dedicated Server Processes" Illustrateshow dedicated Server Processes work. In this diagram, the user processes areconnected to the database through dedicated server processes.

Ingeneral, it is better to being connected through a dispatcher and use ashared server process. This is illustrated in Figure4-2, "Oracle Database Shared Server Processes". A shared serverprocess can be more efficient because it keeps the number of processes requiredfor the running instance low .

Inthe following situations, however, users and administrators should explicitlyconnect to an instance using a dedicated SE RVer Process:

In both cases, you need to display the use of dedicated server process to connect to the instance:

(1) To submit a batch job (if example, when a job can allow little orno idle time for the server process)

(2) to the use of Recovery Manager (RMAN) to the back up, restore, or recover a database

Torequest a dedicated server connection when Oracle Database is configured forshared server, users must connect using a NE The T service name is CONFIGUREDTO use a dedicated server. Specifically, the Net service name value shouldinclude the server=dedicated clause in the Connect descriptor.

If the database is configured with shared server and you want to use dedicated server to connect to the instance, you must configure server=dedicated in the Net Service name (Tnsnames.ora).

Figure 4-1 Oracledatabase dedicated Server Processes



1.2 Shared Server Processes

Consideran Order Entry system with dedicated server processes. A Customer Phones Theorder desk and places an order, and the clerk taking the "call" enters the database. For most of the transaction, the clerk are on the telephonetalking to the customer. A server process is not needed during this time, Sothe server process dedicated to the clerk ' s user process remains idle. Thesystem is slower for and clerks entering orders, because the idle serverprocess is holding system resources.

Sharedserver architecture eliminates the need for a dedicated server process for eachconnection (see FIGURE4-2).

Figure 4-2 Oracledatabase Shared Server Processes



Ina Shared server configuration, client user processes connect to a dispatcher. The dispatcher can support multiple client connections concurrently. Eachclient connection is bound to a virtual circuit, which are a piece ofshared memory used by the dispatcher for client da Tabase connection Requestsand replies. The dispatcher places a virtual circuit on a common queue when Arequest arrives.

Anidle shared server process picks up the virtual circuit from the common queue,services the request, and relinquishes the Virtual circuit before attempting toretrieve another virtual circuit from the common queue. This approach enables a small pool of servers processes to serve a largenumber of clients. A significant advantage of shared server Architectureover the dedicated server model is the reduction of system resources, Enablingthe support of a increased number of users.

Foreven Better resource management, GKFX Server can be configuredfor connection. Connection pooling lets a dispatcher support moreusers by enabling the database server to time-out protocol connections an D touse Those connections to service an active session. Further, shared server canbe configured for session multiplexing, which combines multiple sessionsfor transmission over a Single network connection on order to conserve the operatingsystem ' s resources.

Sharedserver architecture requires Oracle Net Services. User processes targeting theshared server must connect through Oracle Net Services, even if they is on thesame machine as The Oracle Database instance.

Two. Description 2.1 Dedicated Server description

For a dedicated server configuration, Oracle always creates a new process at logon, which is dedicated to this connection service during the lifetime of the session. For each session, a new dedicated server will appear, with a one-to-one mapping between the session and the dedicated server. By definition, this dedicated server is not part of an instance. The client process (that is, the program that wants to connect to the database) communicates directly with the dedicated server through some kind of network channel (such as TCP/IP Sockets) and receives and executes my SQL from this server process. If necessary, it reads the data file and finds the data I want in the cache of the database. Maybe it will complete my UPDATE statement, or it might run my PL/SQL code. The primary goal of this server process is to respond to the SQL calls I submit.

2.2 Shared Server Description 2.2.1 Description

Shared server, which is formally said to be a multithreaded server (multi-threaded server) or MTS. In this way, no additional threads or new UNIX processes are created for each user connection.

On a shared server, Oracle uses a "shared process" pool to serve a large number of users. A shared server is actually a connection pooling mechanism. With a shared server, we don't have to create 10,000 dedicated servers for 10,000 database sessions (so there are too many processes or threads), and only a few of the processes/threads are created, as the name implies, which will be shared by all sessions. This allows Oracle to connect more users to the database, or it can be difficult to connect more users. If I let my machine manage 10,000 processes, this load will certainly crush it, but it is still possible to manage 100 or 1,000 processes. With Shared server mode, shared processes are typically started with the database, and the process is visible using the PS command.

There is a significant difference between a shared server connection and a dedicated server connection, and the client process that is connected to the database does not communicate directly with the shared server, but the private server does not, and the client process communicates directly with the dedicated server. The reason why you cannot talk directly to a shared server is because the server process is shared. In order to share these processes, another mechanism is needed to "talk" to the server process. To do this, Oracle uses one or a set of processes called schedulers (dispatcher, also known as dispatchers).

The client process communicates with a scheduler process over the network. This scheduler process puts the client's request into the request queue in the SGA (which is also one of the uses of the SGA). The first idle shared server gets the request and processes it (for example, the request may be update T SETX = x+5 WHERE Y = 2). When this command is completed, the shared server places the response in the response queue of the original scheduler, which is the scheduler that receives the request. The scheduler process has been listening to this queue, and after finding the results, it will pass the results to the customer. Conceptually, the shared server request is shown in process 2-3.

As shown in 2-3, the client connection sends a request to the scheduler. The scheduler first places this request in the request queue in the SGA ①. The first available shared server ② and processes the request from the request queue. After the processing of the shared server is finished, the response (return code, data, etc.) is placed in the response queue ③, then the dispatcher gets the response ④ and returns it to the client.

2.2.2 Shared server has some of the following drawbacks

In general, we use the Oracle default dedicated server approach, there is no need for shared server mode. One is that we use middleware (such as: WebLogic) to the Oracle, the middleware itself has a connection pooling mechanism, the other is the oracle of this shared server is not good enough, there are many shortcomings.

1) The code path of the shared server is longer than the dedicated server, so it is inherently slower than a dedicated server.
2) There is the possibility of an artificial deadlock, because it is serial, and as long as a connection is blocked, all users on that server process are blocked and are highly likely to deadlock.
3) There is the possibility of an exclusive transaction, because if a session has a transaction that takes too long to run, it exclusively shares the resource, and the other user can only wait, while the dedicated server, each client is a session.
4) Shared server mode restricts certain database features, such as: You cannot start and shut down instances individually, you cannot perform media recovery, you cannot use log Miner, and the sql_trace is meaningless (because it is a share instead of the current session).

MTS reduced memory is actually the memory required for each user to connect to the operating system process in dedicated server mode, but it uses the large_pool of the SGA to allocate UGA, pay Paul, and the reduced memory is minimal. If the connection and disconnection of a user session is frequent, the cost of creating and deleting the database process is very high, preferably in a shared server mode (otherwise, connection pooling technology should be used). Using Shared server mode is of little significance if the client is used for a lifetime (during the session life cycle) for a single connection. Because most of the time, a session is connected to a server process and the server process cannot be shared.

2.2.3 Some descriptions of the shared service initialization parameters

Shared_servers: Specifies the number of shared server process starts when instance is started, do not set this parameter too large, no one will take more time to start the database instance, After Oracle starts, the Shared_servers is dynamically adjusted based on the load. If 0, indicates that the database does not start the shared services mode. This parameter is required for the configuration of shared server, and only this parameter is required.

Modify parameters: Alter system set Shared_servers=1;

Max_shared_servers:oracle the largest shared server process that can be used at the same time. Do not set this parameter to less than shared_servers if the dynamic modification shared_servers is greater than max_ Shared_servers,oracle will overwrite the value of max_shared_servers, you need to modify max_shared_servers at this time. Also cannot be greater than processes. This parameter is intended for use in large resource operations (batch processing), in order to reserve some process for the DBA task (Rman Backup),

Shared_server_sesions: Specifies the number of shared server sessions that are allowed in total. If this parameter is set, then do not exceed the value of sessions, if not set this value, then as long as there is idle session, it can be used. Setting this value is reserved for the private connection user sessions.

Dispatchers: Configure dispatcher process. If you do not set this parameter, Oracle automatically sets a TCP protocol-based dispatcher as long as the shared_servers is set. Also need to see how many connections the operating system supports a dispatcher can handle

Sql> select * from V$dispatcher;

Max_dispatchers: Sets the number of dispatchers that can run concurrently at the same time, which must be greater than or equal to dispatchers, less than processes. This parameter will also be overwritten by dispatchers.

Circuits: Specifies the total number of virtual circuits.

2.2.4 Turn off sharing mode

With the Shared_servers parameter set to 0, all shared connections to the database cannot succeed, but the shared connection that is not freed continues to remain connected until it is disconnected. If both Shared_servers and Max_shared_servers are set to 0, then the shared connection will be terminated. If all the shared connections are disconnected, you can use the ALTER system set dispatcher= '; Clears the dispatcher to prevent the next time the database is started and the shared connection mode is turned on.

2.3 Fundamentals of TCP/IP connectivity

This will analyze one of the most common scenarios on the network: establish a network-based connection request on a TCP/IP connection. In this case, the customer is on one machine, and the server resides on another machine, and the two machines are connected through a TCP/IP network. The customer took the lead in creating a request using Oracle client software (a set of application interfaces, or APIs provided by Oracle) to connect to the database.

For example, a customer can issue the following command:

C:\users\administrator.daviddai>sqlplus Sys/[email protected]_202as sysdba;

Sql*plus:release 11.2.0.1.0 Production Onsun 21 14:36:47 2011

Copyright (c) 1982, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise editionrelease 10.2.0.1.0-production

With the partitioning, OLAP and Data miningoptions

Sql>

Here, the customer is the program sql*plus,dave2_202 is a TNS service name. TNS represents the transparent network bottom layer (Transparent networks substrate), which is the "base" software for the Oracle customer to handle remote connections, which makes it possible to establish peer-to-peer communication. The TNS connection string tells the Oracle software how to connect to the remote database.

Generally, the client software running on the machine reads a Tnsnames.ora file. This is a plain text configuration file, usually placed in the [Oracle_home]\network\admin directory. The configuration is as follows:

dave2_202 =

(DESCRIPTION =

(Address_list =

(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.3.202) (PORT = 1521))

)

(Connect_data =

(SERVER = dedicated)

(service_name = dave2)

)

)

Based on this configuration information, the Oracle client software can map the TNS connection string dave2_202 we use to some useful information, that is, the hostname, the port on which the listener process is accepted (listening), the name of the service on the database connected to the host, and so on.

The service name represents an application group with public properties, service-level thresholds, and priorities.  The number of instances that provide the service is transparent to the application, and each DB instance can register with the listener to indicate that it is providing multiple services. Therefore, the service maps to a physical DB instance and allows the DBA to correlate thresholds and priorities. This string (dave2_202) can also be parsed in other ways. For example, you can use the Oracle Internet directory (Oracle Internet directory,oid), which is a distributed Lightweight Directory Access Protocol (Lightweight directory, Access Protocol, LDAP) server, which acts as a DNS for resolving hostnames. However, Tnsnames.ora files usually only apply to most small to medium installations, in which case a copy of this configuration file is not too much to manage.

Now that the client software knows where to connect, it opens a TCP/IP socket connection to port 1521 on the server with the host name 192.168.3.202. If the server DBA installs and configures Oracle Net, and a listener listens for connection requests on port 1521, the connection is received. In a networked environment, we run a process called the TNS listener on the server. It is this listener process that allows us to physically connect to the database. When it receives an inbound connection request, it checks the request with its own profile and may reject the request (for example, because there is no such database, or if our IP address is restricted, it is not allowed to connect to the host), the request may be accepted, and the connection is actually established.

If a dedicated server connection is established, the listener process creates a dedicated server for us.      On Unix, this is done through the fork () and exec () system calls (in Unix, the only way to create a new process after initialization is through fork ()). This new dedicated server process inherits the connections established by the listener and is now physically attached to the database.

On Windows, the listener process requests that the database process create a new thread for the connection. Once this thread is created, the customer "redirects" to the thread and can establish a physical connection accordingly. Figure 2-4 shows the listener process and the dedicated server connection on UNIX.

On the other hand, if we make a shared server connection request, the listener behaves differently. The listener process knows which schedulers are running in the instance. When a connection request is received, the listener selects a scheduler process from the available scheduler pool. The listener returns the connection information to the client, which explains how the client connects to the scheduler process, and, if possible, "forwards" the connection to the scheduler process (which relies on different operating systems and database versions, but the actual effect is the same).

When the listener sends back the connection information, its work ends because the listener is running on a specific port on a particular host (the hostname and port number are known to everyone), and the scheduler accepts the connection on the arbitrarily assigned port on the server. Listener to know these random port numbers specified by the Scheduler, and to select

Select a scheduler. The customer then disconnects from the listener and connects directly to the scheduler. Now you have a physical connection to the database. This procedure is shown in 2-5.

Three. Determine whether Oracle is a shared or private mode method 3.1. Showparameter Shared_server;

(Note: 8i should be: Showparameter mts_servers;)
Sql> Show parameter shared_server;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
Max_shared_servers Integer 20
Shared_server_sessions Integer 330
Shared_servers Integer 1

3.2 View v$session views

sql> Select Username,server,program fromv$session where username is not null;

USERNAME SERVER Program

------------------------------ ------------------------------------------------

SYS dedicated Rman.exe

RMAN dedicated Rman.exe

SYS dedicated Rman.exe

SYS dedicated Sqlplus.exe

SYS dedicated Rman.exe

DAVE dedicated Toad.exe

SYS dedicated Toad.exe

3.3 Viewing monitoring: Lsnrctl Service

C:\users\administrator.daviddai>lsnrctlservice

Lsnrctl for 32-bit windows:version11.2.0.1.0-production on 2 June-June -2010 11:7:40 Copyright (c) 1991,, Oracle. All rights reserved.

Connecting to (Description= (address= (PROTOCOL=IPC) (key=extproc1521))

Service Summary:

The service "ORCL" consists of 1 instances.

Instance "ORCL", state ready, contains 1 handlers for this service ...

Handlers:

"Dedicated" has been established: 34 rejected: 0 Status: Ready

LOCAL SERVER

The service "Orclxdb" consists of 1 instances.

Instance "ORCL", state ready, contains 1 handlers for this service ...

Handlers:

"D000" established: 0 has been rejected: 0 Current: 0 Max: 1022 Status: Ready

DISPATCHER <machine:daviddai, pid:10884>

(Address= (PROTOCOL=TCP) (Host=daviddai) (port=58400))

Command execution succeeded

3.4. View the Tnsnames.ora file. Such as:

ORCL =

(DESCRIPTION =

(Address_list =

(ADDRESS = (PROTOCOL = TCP) (HOST = Daviddai) (PORT = 1521))

)

(Connect_data =

(SERVER = dedicated)

(service_name = ORCL)

)

)

This is a ORCL instance that is connected in dedicated private mode. Write on (server = shared) is using the shared server mode, but then shared_server_process needs to be open, or it will fail to connect to Oracle. If this paragraph is not written, then the system will automatically adjust according to the server mode, but according to the measured results, even if the server is defined as a shared server mode, shared_server_process is not open, the connection found in v$session is still server = Dedicated.

So basically we have this paragraph we can be empty to write, but sometimes to connect our shared server model of the database, empty there may be the system think to use a shared server way to connect, then declare the server = Dedicated use a dedicated server way to connect.

When the database is started, if Shared_servers is not specified, but dispatchers is set, then Oracle considers the shared server to be started and the shared_servers is set to 1. When the database is started, shared_servers is not set, dispatchers is not set, even if dispatchers is modified later and shared server cannot be started, the database must be restarted.


In addition, Background process, as well as through local connections, can only be dedicated. For example Sqlplus user/pass form. If the database does not have a shared server configured, the client can only connect to the database in dedicated mode.

http://blog.csdn.net/tianlesoftware/article/details/5695784

Description of Oracle dedicated server and shared server (private mode and sharing mode) (RPM)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.