为什么使用共享服务器?
对于共享服务器(MTS),其最大的优点就在于不需要给每个连接都创建相应的专用服务器进程,因而共享服务器体系结构保持了运行实例所需的最少数目的进程。
在共享服务器(MTS)中,我们也可以使用配置为专用服务器的网络服务名称(即,网络服务名称的值应该在连接描述符中包括SERVER=DEDICATED 子句)实现专用服务器连接的方式。
当然,对于以下两种情况,要求必须使用专用服务器连接到实例中:
1. 使用RMAN时,必须使用专用服务器方式连接数据库
2. 批处理作业时
影响共享服务器配置的初始化参数
DISPATCHERS
这是配置共享服务器所必须的参数,该参数指示了系统启动时开始运行的调度进程的描述,。如果要使用多个调度进程,需要连续设置多个DISPATCHERS,例如:
SQL> select name , network from v$dispatcher;
NAME NETWORK --------------------------------------------------------------------------------
SQL> ALTER SYSTEM SET DISPATCHERS="(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1))(DISPATCHERS=3)";
System altered
SQL> select name , network from v$dispatcher;
NAME NETWORK -------------------------------------------------------------------------------- D000 (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1094)) D001 (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1095)) D002 (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1096))
SQL> |
使用这个参数设置将启动三个调度进程,这两个调度程序将在IP地址为本机进行监听。注意HOST选项中指定的IP必须是实际存在的有效IP。
这个参数可以使用ALTER SYSTEM SET DISPATCHERS命令动态的修改,可以添加的最多的DISPATCHERS数目由参数MAX_DISPATCHERS决定。例如:
ALTER SYSTEM SET DISPATCHERS = ‘(PROTOCOL=TCP)(DISPATCHERS=5)(INDEX=1)’;
|
这个例子中第一个设置告诉数据库修改参数文件中的第2个DISPATCHERS的设置,使之为TCP/IP协议使用5个DISPATCHERS,如果当前的调度进程少于5个,那么系统会增加调度进程到5个,如果当前哦调度进程大于5个,那么系统不能立即删除多余的调动进程,Oracle只能在用户断开连接后,才将DISPATCHERS的数目减少到5个。
DISPATCHERS数目设置的太高或者太低都不利于系统的性能,通过查询V$QUEUE、V$DISPATCHERS和V$DISPATCHER_RATE,我们就可以确定是否需要增加调度进程,或者需要减少调度进程。通常如果调度进程的装载量很高,那么增加新的调度进程可能会提高性能;如果装载量很低,那么减少调度进程会提高性能。对于大多数应用,每1000个连接分配一个DISPATCHERS就可以了。
MAX_DISPATCHERS
指定系统中同时运行的调度进程的最大数目,这个参数是静态参数,缺省值是5。
SHARED_SERVERS 数目
指定启动实例时需要创建的共享服务器进程的数目,Oracle 将根据请求队列的长度动态调整共享服务器进程的数目,最多可创建的共享服务器的数目由参数MAX_SHARED_SERVERS决定。
SHARED_SERVERS缺省值是1,如果不希望使用共享服务器结构,那么可以将这个参数值设置为0。该参数是个动态参数,可以ALTER SYSTEM命令动态的调整。一般来说,每10 个连接分配一个共享服务器就可以了。
这个参数可以使用ALTER SYSTEM SET SHARED_SERVERS命令动态的修改,例如:
ALTER SYSTEM SET SHARED_SERVERS=0; |
上述命令将终止所有的空闲的共享服务器进程。
MAX_ SHARED_SERVERS
指定系统中可以同时运行的共享服务器进程的最大数目,这个参数是静态参数
CIRCUITS
这是一个静态参数,如果使用共享服务器结构,用那么这个参数指定进出网络会话时可以利用的虚拟回路的总数;如果不使用共享服务器结构,那么这个参数为0。
SHARED_SERVER_SESSIONS
指定共享服务器结构中允许的用户会话的总数,设置这个参数可以为专用服务器保留用户会话。这是一个静态参数,其取值范围在0到SESSIONS-5之间。
LARGE_POOL_SIZE
由于在MTS中,UGA需要从LARGE_POOL_SIZE中分配,因此需要将这个参数的值指定为一个较大的值,以满足应用的需求。将该值设置的太低或太高都会影响系统的性能。
SESSIONS
指定系统可以创建的session的最大数目。该参数的缺省值是PROCESS*1.1+5,例如,PROCESS为150(缺省值),那么SESSIONS的值为150*1.1+5 = 170。
监视共享服务器
经常用开监视共享服务器的试图有9个:
V$DISPATCHER
包含有关调度进程的信息,包括DISPATCHERS的名称,DISPATCHERS的网址,进程地址,状态等各种信息。
V$DISPATCHER_RATE
包含调度进程的速率统计表。
V$QUEUE
包含有关共享服务器消息队列的信息。
|
V$SHARED_SERVER
包含有关共享服务器进程的信息。
数据类型 | 描述 | |
WAIT (ENQ) - Waiting for a lock WAIT (SEND) - Waiting to send data to user WAIT (COMMON) - Idle; waiting for a user request WAIT (RESET) - Waiting for a circuit to reset after a break QUIT - Terminating | ||
Total number of requests taken from the common queue in this server's lifetime |
V$CIRCUIT
包含有关虚拟回路的信息,这些虚拟回路是一些通过调度程序和服务器连接到数据库的用户连接。
Address of server process that is waiting for the (currently busy) circuit to become available | ||
Total number of messages that have gone through this circuit | ||
V$SHARED_SERVER_MONITOR
包含用来调整共享服务器进程的信息。
类型 | ||
Highest number of virtual circuits in use at one time since the instance started. If this value reaches the value set for the | ||
Highest number of shared server sessions in use at one time since the instance started. If this reaches the value set for the | ||
Total number of shared servers started since the instance started (but not including those started during startup) | ||
Total number of shared servers stopped by Oracle since the instance started | ||
Highest number of servers running at one time since the instance started. If this value reaches the value set for the |
V$SGA
包含SGA 中各种内存结构的统计信息。
V$SGASTAT
包含SGA 中各种内存结构的详细信息。
V$SHARED_POOL_RESERVED
这个视图使用来调整共享池中的保留池(RESERVED POOL)和存储空间的。只有当初始化参数设置了SHARED_POOL_RESERVED_SIZE
参数后,这个试图的信息才可用。
类型 | ||
Size of the largest free piece of memory on the reserved list | ||
Size of the largest used piece of memory on the reserved list | ||
Number of times that the reserved list was searched for a free piece of memory | ||
Number of times the reserved list did not have a free piece of memory to satisfy the request, and started flushing objects from the LRU list | ||
Request size of the last request miss, when the reserved list did not have a free piece of memory to satisfy the request and started flushing objects from the LRU list | ||
Request size of the largest request miss, when the reserved list did not have a free piece of memory to satisfy the request and started flushing objects from the LRU list | ||
The following columns of | ||
Number of times that no memory was found to satisfy a request (that is, the number of times the error | ||
Request size of the last failed request (that is, the request size for the last | ||
Minimum size of a request which signals an | ||
Number of requests that signalled an | ||
Last size of the request that returned an |
关闭调度进程
如果关闭某个指定的调度进程,首先需要从V$DISPATCHER试图找到需要关闭的调度进程:
SQL> select name , network from v$dispatcher;
NAME NETWORK -------------------------------------------------------------------------------- D000 (ADDRESS=(PROTOCOL=tcp)(HOST=lunar)(PORT=1040))
SQL>
|
然后使用ALTER SYSTEM 命令关闭该调度进程:
SQL> ALTER SYSTEM SHUTDOWN IMMEDIATE 'D000';
System altered
SQL> select name , network from v$dispatcher;
NAME NETWORK --------------------------------------------------------------------------------
SQL>
|