专用服务器进程(默认oracle net connect模式)
? 用户进程和服务器进程是分开的。
? 每个用户进程都有自己的服务器进程。
? 用户进程和服务器进程可在不同的机器上运行,以利用分布式处理的优势。
? 用户进程和服务器进程的比率是1 比1。
? 即使用户进程不发出数据库请求,专用服务器也存在,只是保持空闲状态。
Oracle Shared Server 的优点
? 减少针对某一例程的进程数目
? 增加可服务的用户数
? 实现负载平衡
? 减少空闲服务器进程的数目
? 减少内存占用和系统开销
配置Oracle Shared Server
? 必需的初始化参数
–DISPATCHERS:指定最初为某一给定协议启动的调度程序的数目
–SHARED_SERVERS:指定启动例程时创建的服务器进程的数目
? 可选初始化参数
–MAX_DISPATCHERS:指定可同时运行的调度程序进程的最大数目
–MAX_SHARED_SERVERS:指定可启动的共享服务器的最大数目
–CIRCUITS
–SHARED_SERVER_SESSIONS
DISPATCHERS
指定最初为某一给定协议启动的调度程序的数目
DISPATCHERS = “(PROTOCOL=TCP)(DISPATCHERS=2)\(PROTOCOL=IPC)(DISPATCHERS=1)”
=======================================================================================================================
SQL> show parameter dispa
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string ####当该值为非空时候可以直接用alter system set 修改,因为空值无法执行修改,所以可以通过pfile修改后生成新的spfile来处理
max_dispatchers integer
SQL> show parameter share
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 14M
shared_pool_size big integer 0
shared_server_sessions integer
shared_servers integer 1
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@server01 ~]$ cd /opt/oracle/product/10.2.0/db_1/dbs/
[oracle@server01 dbs]$ vi initmsp.ora
....
*.dispatchers='(protocol=tcp)(dispatchers=1)'
SQL> create spfile from pfile;
File created.
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 633343360 bytes
Database Buffers 192937984 bytes
Redo Buffers 6590464 bytes
Database mounted.
Database opened.
SQL> show parameter dispatcher
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (protocol=tcp)(dispatchers=1)
max_dispatchers integer
SQL> show parameter share
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 14470348
shared_pool_size big integer 0
shared_server_sessions integer
shared_servers integer 1
[oracle@server01 ~]$ ps -ef | grep oracle
oracle 3876 1 0 14:26 ? 00:00:00 /opt/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
root 10675 10647 0 20:03 pts/2 00:00:00 su - oracle
oracle 10676 10675 0 20:03 pts/2 00:00:00 -bash
oracle 10703 10676 0 20:03 pts/2 00:00:00 rlwrap sqlplus / as sysdba
oracle 10704 10703 0 20:03 pts/3 00:00:00 sqlplus
oracle 14200 1 0 22:48 ? 00:00:00 ora_pmon_msp
oracle 14202 1 0 22:48 ? 00:00:00 ora_psp0_msp
oracle 14204 1 0 22:48 ? 00:00:00 ora_vktm_msp
oracle 14208 1 0 22:48 ? 00:00:00 ora_gen0_msp
oracle 14210 1 0 22:48 ? 00:00:00 ora_diag_msp
oracle 14212 1 0 22:48 ? 00:00:00 ora_dbrm_msp
oracle 14214 1 0 22:48 ? 00:00:00 ora_dia0_msp
oracle 14216 1 0 22:48 ? 00:00:00 ora_mman_msp
oracle 14218 1 0 22:48 ? 00:00:00 ora_dbw0_msp
oracle 14220 1 0 22:48 ? 00:00:00 ora_lgwr_msp
oracle 14222 1 0 22:48 ? 00:00:00 ora_ckpt_msp
oracle 14224 1 0 22:48 ? 00:00:00 ora_smon_msp
oracle 14226 1 0 22:48 ? 00:00:00 ora_reco_msp
oracle 14228 1 0 22:48 ? 00:00:00 ora_mmon_msp
oracle 14230 1 0 22:48 ? 00:00:00 ora_mmnl_msp
oracle 14232 1 0 22:48 ? 00:00:00 ora_d000_msp
oracle 14234 1 0 22:48 ? 00:00:00 ora_s000_msp
oracle 14285 10704 0 22:48 ? 00:00:00 oraclemsp (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14287 1 0 22:48 ? 00:00:00 ora_arc0_msp
oracle 14289 1 0 22:48 ? 00:00:00 ora_arc1_msp
oracle 14291 1 0 22:48 ? 00:00:00 ora_arc2_msp
oracle 14293 1 0 22:48 ? 00:00:00 ora_arc3_msp
oracle 14295 1 0 22:48 ? 00:00:00 ora_qmnc_msp
oracle 14309 1 0 22:48 ? 00:00:00 ora_cjq0_msp
oracle 14311 1 0 22:48 ? 00:00:00 ora_vkrm_msp
oracle 14314 1 0 22:48 ? 00:00:00 ora_q000_msp
oracle 14316 1 0 22:48 ? 00:00:00 ora_q001_msp
oracle 14340 10704 0 22:49 pts/3 00:00:00 /bin/bash
oracle 14354 14340 1 22:49 pts/3 00:00:00 ps -ef
oracle 14355 14340 0 22:49 pts/3 00:00:00 grep oracle
[oracle@server01 ~]$ exit
SQL> alter system set max_dispatchers=5;
System altered.
SQL>
SQL>
SQL> show parameter disp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_plan_display string AUTO
dispatchers string (protocol=tcp)(dispatchers=1)
max_dispatchers integer 5
SQL> alter system set dispatchers='(protocol=tcp)(dispatchers=4)';
System altered.
SQL>
SQL>
SQL> show parameter disp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_plan_display string AUTO
dispatchers string (protocol=tcp)(dispatchers=4)
max_dispatchers integer 5
SQL> alter system set shared_servers=5;
System altered.
SQL>
SQL>
SQL> show parameter share
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 14470348
shared_pool_size big integer 0
shared_server_sessions integer
shared_servers integer 5
[oracle@server01 ~]$ ps -ef | grep ora
root 2765 2721 0 14:23 ? 00:00:01 hald-addon-storage: polling /dev/sr0 (every 2 sec)
oracle 3876 1 0 14:26 ? 00:00:00 /opt/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
root 10675 10647 0 20:03 pts/2 00:00:00 su - oracle
oracle 10676 10675 0 20:03 pts/2 00:00:00 -bash
oracle 10703 10676 0 20:03 pts/2 00:00:00 rlwrap sqlplus / as sysdba
oracle 10704 10703 0 20:03 pts/3 00:00:00 sqlplus
oracle 14200 1 0 22:48 ? 00:00:00 ora_pmon_msp
oracle 14202 1 0 22:48 ? 00:00:00 ora_psp0_msp
oracle 14204 1 0 22:48 ? 00:00:00 ora_vktm_msp
oracle 14208 1 0 22:48 ? 00:00:00 ora_gen0_msp
oracle 14210 1 0 22:48 ? 00:00:00 ora_diag_msp
oracle 14212 1 0 22:48 ? 00:00:00 ora_dbrm_msp
oracle 14214 1 0 22:48 ? 00:00:01 ora_dia0_msp
oracle 14216 1 0 22:48 ? 00:00:00 ora_mman_msp
oracle 14218 1 0 22:48 ? 00:00:00 ora_dbw0_msp
oracle 14220 1 0 22:48 ? 00:00:00 ora_lgwr_msp
oracle 14222 1 0 22:48 ? 00:00:00 ora_ckpt_msp
oracle 14224 1 0 22:48 ? 00:00:00 ora_smon_msp
oracle 14226 1 0 22:48 ? 00:00:00 ora_reco_msp
oracle 14228 1 0 22:48 ? 00:00:00 ora_mmon_msp
oracle 14230 1 0 22:48 ? 00:00:00 ora_mmnl_msp
oracle 14232 1 0 22:48 ? 00:00:00 ora_d000_msp
oracle 14234 1 0 22:48 ? 00:00:00 ora_s000_msp
oracle 14285 10704 0 22:48 ? 00:00:00 oraclemsp (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 14287 1 0 22:48 ? 00:00:00 ora_arc0_msp
oracle 14289 1 0 22:48 ? 00:00:00 ora_arc1_msp
oracle 14291 1 0 22:48 ? 00:00:00 ora_arc2_msp
oracle 14293 1 0 22:48 ? 00:00:00 ora_arc3_msp
oracle 14295 1 0 22:48 ? 00:00:00 ora_qmnc_msp
oracle 14309 1 0 22:48 ? 00:00:00 ora_cjq0_msp
oracle 14311 1 0 22:48 ? 00:00:00 ora_vkrm_msp
oracle 14314 1 0 22:48 ? 00:00:00 ora_q000_msp
oracle 14316 1 0 22:48 ? 00:00:00 ora_q001_msp
oracle 14416 1 0 22:53 ? 00:00:00 ora_d001_msp
oracle 14418 1 0 22:53 ? 00:00:00 ora_d002_msp
oracle 14420 1 0 22:53 ? 00:00:00 ora_d003_msp
oracle 14423 1 0 22:53 ? 00:00:00 ora_smco_msp
oracle 14426 1 0 22:53 ? 00:00:00 ora_w000_msp
oracle 14449 1 0 22:54 ? 00:00:00 ora_s001_msp
oracle 14451 1 0 22:54 ? 00:00:00 ora_s002_msp
oracle 14453 1 0 22:54 ? 00:00:00 ora_s003_msp
oracle 14455 1 0 22:54 ? 00:00:00 ora_s004_msp
oracle 14579 10704 0 23:00 pts/3 00:00:00 /bin/bash
oracle 14677 1 0 23:03 ? 00:00:00 ora_w001_msp
oracle 14819 14579 1 23:11 pts/3 00:00:00 ps -ef
oracle 14820 14579 0 23:11 pts/3 00:00:00 grep ora
SQL> alter system set max_shared_servers=6;
System altered.
SQL> show parameter max_shared
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers integer 6
[oracle@server01 ~]$ lsnrctl services ####检查shared server是否正常工作可用
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 17-APR-2014 23:00:09
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.220.101)(PORT=1521)))
Services Summary...
Service "msp" has 1 instance(s).
Instance "msp", status READY, has 5 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=50033))
"D002" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=44861))
"D001" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=9016))
"D003" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=54006))
The command completed successfully
=====================================================================
C:\instantclient_11_2>sqlplus u1/msp_12345@192.168.220.101:1521/msp
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 22 14:30:36 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> select circuit,dispatcher,status from v$circuit; ###可查看当前有多少连接数
CIRCUIT DISPATCHER STATUS
---------------- ---------------- ----------------
000000008B0000A8 00000000913981F0 NORMAL
SQL>
[oracle@server01 ~]$ netstat -anp | more
....
tcp 0 0 192.168.220.101:1521 192.168.220.1:59495 ESTABLISHED 15745/ora_d003_msp
[oracle@server01 ~]$ ps -ef | grep 15745
oracle 15745 1 0 09:45 ? 00:00:00 ora_d003_msp
oracle 24668 15926 0 14:34 pts/2 00:00:00 grep 15745
================================================================================
CIRCUITS
? 指定可供入站和出站网络会话使用的虚拟线路总数
动态视图
? V$CIRCUIT
? V$SHARED_SERVER
? V$DISPATCHER
? V$SHARED_SERVER_MONITOR
? V$QUEUE
? V$SESSION