[Guide]Managing Oracle Processes
Server Processes
Dedicated Server Processes
In the following situations, users and administrators should explicitly connect to an instance using a dedicated server process:
1.To submit a batch job (for example, when a job can allow little or no idle time for the server process)
2.To use Recovery Manager to back up, restore, or recover a database
To request a dedicated server connection when Oracle is configured for shared server, users must connect using a net service name that is configured to use a dedicated server. Specifically, the net service name value should include the SERVER=DEDICATED clause in the connect descriptor.
Shared Server Processes
Configuring Oracle for the Shared Server
Initialization Parameters for Shared Server
Parameter Description
The following parameter is required by shared server:
DISPATCHERS 配置 dispatcher 进程
The following parameters are optional (if not specified, Oracle selects defaults):
MAX_DISPATCHERS 同时运行的最大 dispatcher 进程数量
SHARED_SERVERS 实例启动时,共享服务器进程的数量
MAX_SHARED_SERVERS 同时运行的最大共享服务器进程的数量
CIRCUITS Specifies the total number of virtual circuits that are available for inbound and outbound network sessions.
SHARED_SERVER_SESSIONS Specifies the total number of shared server user sessions to allow. Setting this parameter enables you to reserve user sessions for dedicated servers.
Other parameters affected by shared server that may require adjustment:
LARGE_POOL_SIZE Specifies the size in bytes of the large pool allocation heap. Shared server may force the default value to be set too high, causing performance problems or problems starting the database.
SESSIONS Specifies the maximum number of sessions that can be created in the system. May need to be adjusted for shared server.
Setting the Initial Number of Dispatchers (DISPATCHERS)
如果1个dispatcher可以供1000个连接同时使用,那么当高峰时期有1500个连接的环境中,应该将dispatcher设为2个。太多的dispatcher会降低系统性能。
Setting the Initial Number of Shared Servers (SHARED_SERVERS)
Oracle 会根据请求队列的长度动态调整共享服务器进程的数量,范围在SHARED_SERVERS和MAX_SHARED_SERVERS之间。
Typical systems seem to stabilize at a ratio of one shared server for every ten connections.
Adding and Removing Dispatcher Processes
查看 V$QUEUE, V$DISPATCHER and V$DISPATCHER_RATE 视图,如果 dispatcher processes 负担一直很高,则增加进程(最多增加到 MAX_DISPATCHERS),反之减少他们。
当减少进程时,Dispatcher Processes 不会立即移除,而是等到用户断开连接才会终止。
语法:
ALTER SYSTEM
SET DISPATCHERS =
'(PROTOCOL=TCP)(DISPATCHERS=5) (INDEX=0)',
'(PROTOCOL=TCPS)(DISPATCHERS=2) (INDEX=1)';
The INDEX keyword can be used to identify which DISPATCHERS parameter to modify. To identify the index number assigned to an DISPATCHERS parameter, query the CONF_INDX value in the V$DISPATCHER view.
Shutting Down Specific Dispatcher Processes
Each dispatcher is uniquely identified by a name of the form Dnnn.可以通过 V$DISPATCHER 查询。
To shut down dispatcher D002, issue the following statement:
ALTER SYSTEM SHUTDOWN IMMEDIATE 'D002';
The IMMEDIATE keyword stops the dispatcher from accepting new connections and Oracle immediately terminates all existing connections through that dispatcher. After all sessions are cleaned up, the dispatcher process shuts down. If IMMEDIATE were not specified, the dispatcher would wait until all of its users disconnected and all of its connections terminated before shutting down.
Changing the Minimum Number of Shared Server Processes
当实例启动,可以动态调整共享服务器进程数量。Oracle will eventually terminate servers that are idle when there are more shared servers than the minimum limit you specify.
If you set SHARED_SERVERS to 0, Oracle terminates all current servers when they become idle and does not start any new servers until you increase SHARED_SERVERS. Thus, setting SHARED_SERVERS to 0 may be used to effectively disable shared server.
语法:
ALTER SYSTEM SET SHARED_SERVERS = 2;
Monitoring Shared Server
V$DISPATCHER
Provides information on the dispatcher processes, including name, network address, status, various usage statistics, and index number.
V$DISPATCHER_RATE
Provides rate statistics for the dispatcher processes.
V$QUEUE
Contains information on the shared server message queues.
V$SHARED_SERVER
Contains information on the shared server processes.
V$CIRCUIT
Contains information about virtual circuits, which are user connections to the database through dispatchers and servers.
V$SHARED_SERVER_MONITOR
Contains information for tuning shared server.
V$SGA
Contains size information about various system global area (SGA) groups. May be useful when tuning shared server.
V$SGASTAT
Detailed statistical information about the SGA, useful for tuning.
V$SHARED_POOL_RESERVED
Lists statistics to help tune the reserved pool and space within the shared pool.
About Oracle Background Processes
Monitoring the Processes of an Oracle Instance
Process and Session Views
V$PROCESS
Contains information about the currently active processes
V$SESSION
Lists session information for each current session
V$SESS_IO
Contains I/O statistics for each user session
V$SESSION_LONGOPS
This view displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution. More operations are added for every Oracle release.
V$SESSION_WAIT
Lists the resources or events for which active sessions are waiting
V$SYSSTAT
Contains session statistics
V$RESOURCE_LIMIT
Provides information about current and maximum global resource utilization for some system resources
V$SQLAREA
Contains statistics about shared SQL area and contains one row for each SQL string. Also provides statistics about SQL statements that are in memory, parsed, and ready for execution
V$LATCH
Contains statistics for non-parent latches and summary statistics for parent latches
Monitoring Locks
V$LOCK
Lists the locks currently held by the Oracle server and outstanding requests for a lock or latch
Trace Files and the Alert File
The alert file of a database is a chronological log of messages and errors, which includes the following:
1.All internal errors (ORA-600), block corruption errors (ORA-1578), and deadlock errors (ORA-60) that occur
2.Administrative operations, such as CREATE, ALTER, and DROP statements and STARTUP, SHUTDOWN, and ARCHIVELOG statements
3.Several messages and errors relating to the functions of shared server and dispatcher processes
4.Errors occurring during the automatic refresh of a materialized view
5.The values of all initialization parameters at the time the database and instance start
If an operation is successful, a "completed" message is written in the alert file, along with a timestamp.
Controlling the Size of Trace Files
You can control the maximum size of all trace files (excluding the alert file) using the initialization parameter MAX_DUMP_FILE_SIZE. This limit is set as a number of operating system blocks. To control the size of an alert file, you must manually delete the file when you no longer need it; otherwise Oracle continues to append to the file. You can safely delete the alert file while the instance is running, although you might want to make an archived copy of it first.
Managing Processes for Parallel Execution
The degree of parallelism is the number of parallel execution servers that can be associated with a single operation. The degree of parallelism is determined by any of the following:
1.A PARALLEL clause in a statement
2.For objects referred to in a query, the PARALLEL clause that was used when the object was created or altered
3.A parallel hint inserted into the statement
4.A default determined by Oracle
Managing the Parallel Execution Servers
Parallel execution can be tuned for you automatically by setting the initialization parameter PARALLEL_AUTOMATIC_TUNING = TRUE. With this setting, Oracle determines the default values for other initialization parameters that affect the performance of parallel execution.
Altering Parallel Execution for a Session
Disabling Parallel Execution
All subsequent DML (INSERT, UPDATE, DELETE), DDL (CREATE, ALTER), or query (SELECT) statements will not be parallelized after an ALTER SESSION DISABLE PARALLEL DML|DDL|QUERY statement is issued. They will be executed serially, regardless of any PARALLEL clause or parallel hints associated with the statement.
Enabling Parallel Execution
Where a PARALLEL clause or parallel hint is associated with a statement, those DML, DDL, or query statements will execute in parallel after an ALTER SESSION ENABLE PARALLEL DML|DDL|QUERY statement is issued. This is the default for DDL and query statements.
A DML statement can be parallelized only if you specifically issue this statement. The following statement enables parallel processing of DML statements:
ALTER SESSION ENABLE PARALLEL DML;
Note:
Parallel DML is available only if you have installed Oracle's Partitioning Option.
Forcing Parallel Execution
You can force parallel execution of all subsequent DML, DDL, or query statements for which parallelization is possible with the ALTER SESSION FORCE PARALLEL DML|DDL|QUERY statement. Additionally you can force a specific degree of parallelism to be in effect, overriding any PARALLEL clause associated with subsequent statements. If you do not specify a degree of parallelism in this statement, the default degree of parallelism is used. However, a degree of parallelism specified in a statement through a hint will override the degree being forced.
The following statement forces parallel execution of subsequent statements and sets the overriding degree of parallelism to 5:
ALTER SESSION FORCE PARALLEL DDL PARALLEL 5;
To force the parallelization of DML, it must also be enabled as shown in "Enabling Parallel Execution".
Managing Processes for External Procedures
External procedures, are procedures that are called from another program, but are written in a different language.
To control access to DLLs, the database administrator grants execute privileges for the appropriate DLLs to application developers. The application developers write the external procedures and grant execute privilege on specific external procedures to other users.
Terminating Sessions
When a session is terminated, the session's transaction is rolled back and resources (such as locks and memory areas) held by the session are immediately released and available to other sessions.
Identifying Which Session to Terminate
To identify the system identifier (sid) and serial number of a session, query the V$SESSION dynamic performance view.
当该用户在执行 SQL 时 STATUS 栏为 ACTIVE,否则为 INACTIVE。
Terminating an Active Session
If a user session is processing a transaction (ACTIVE status) when it is terminated, the transaction is rolled back and the user immediately receives the following message:
ORA-00028: your session has been killed
If, after receiving the ORA-00028 message, a user submits additional statements before reconnecting to the database, Oracle returns the following message:
ORA-01012: not logged on
If an active session cannot be interrupted (it is performing network I/O or rolling back a transaction), the session cannot be terminated until the operation completes. Additionally, the session that issues the ALTER SYSTEM statement to terminate a session waits up to 60 seconds for the session to be terminated. If the operation that cannot be interrupted continues past one minute, the issuer of the ALTER SYSTEM statement receives a message indicating that the session has been "marked" to be terminated. A session marked to be terminated is indicated in V$SESSION with a STATUS of KILLED and a SERVER that is something other than PSEUDO.
Terminating an Inactive Session
If the session is INACTIVE when it is terminated, the ORA-00028 message is not returned immediately. The message is not returned until the user subsequently attempts to use the terminated session.
When an inactive session has been terminated, STATUS in the V$SESSION view is KILLED. The row for the terminated session is removed from V$SESSION after the user attempts to use the session again and receives the ORA-00028 message.
Posted by Sky at 11:41 PM | Permalink | comments(0) | Edit | Database