配置oracle shared server

1、 独占服务器(dedicated server)
每一个session单独分配一个server process,直到用户断开连接,才释放该进程所占用的资源。而大多数时候session都是idle的,所以存在占用资源的情况。
在有些情况下,必须使用独占服务器模式:(本地连接)

SQL> select username,SERVER,PROGRAM,OSUSER,MACHINE from v$session where username is not null;

USERNAME                       SERVER    PROGRAM                                          OSUSER                         MACHINE
------------------------------ --------- ------------------------------------------------ ------------------------------ ------------------------------
SYS                            DEDICATED sqlplus@ora11g (TNS V1-V3)                       oracle                         ora11g

2、shared server特点
共享服务器响应用户请求的步骤如下:
1) 客户传送一个请求到调度程序。
2) 调度程序将请求放在SGA中的请求队列中(share pool 或 large pool)。
3) 其中的一个共享服务器进程响应并处理这个请求。
4) 共享服务器进程把处理完的请求回复放到SGA中的响应队列中。
5) 调度器从响应队列中取出已经完成的请求。
6) 调度器把完成的请求回复给客户

关于SGA的请求和相应队列以及Dispatcher,具有如下的一些特点:
1)在SGA中只有一个请求队列。
2)共享服务器监控请求队列的使用情况。
3)请求队列遵循先进先出(FIFO)的原则。
4)共享服务器将已经完成的请求放在提交该请求的dispatcher所对应的response队列中。
5)每一个dispatcher在SGA中都由一个对应的response队列。
6)Dispatcher需要负责将完成的请求回复给相应的用户进程。
7)在同一个session中,用户进程始终连接的是同一个Dspatcher。

3、配置shared server
1)、配置dispatchs


SQL> alter system set dispatchers="(PROTOCOL=tcp)(DISPATCHERS=5)";

System altered.

SQL> show parameters dispa

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dispatchers                          string      (PROTOCOL=tcp)(DISPATCHERS=5)
max_dispatchers                      integer

oracle   21441     1  0 15:22 ?        00:00:00 ora_pmon_prod
oracle   21443     1  0 15:22 ?        00:00:00 ora_psp0_prod
oracle   21445     1  1 15:22 ?        00:00:14 ora_vktm_prod
oracle   21449     1  0 15:22 ?        00:00:00 ora_gen0_prod
oracle   21451     1  0 15:22 ?        00:00:00 ora_diag_prod
oracle   21453     1  0 15:22 ?        00:00:00 ora_dbrm_prod
oracle   21455     1  0 15:22 ?        00:00:00 ora_dia0_prod
oracle   21457     1  0 15:22 ?        00:00:00 ora_mman_prod
oracle   21459     1  0 15:22 ?        00:00:00 ora_dbw0_prod
oracle   21461     1  0 15:22 ?        00:00:00 ora_dbw1_prod
oracle   21463     1  0 15:22 ?        00:00:00 ora_lgwr_prod
oracle   21465     1  0 15:22 ?        00:00:00 ora_ckpt_prod
oracle   21467     1  0 15:22 ?        00:00:00 ora_smon_prod
oracle   21469     1  0 15:22 ?        00:00:00 ora_reco_prod
oracle   21471     1  0 15:22 ?        00:00:01 ora_mmon_prod
oracle   21473     1  0 15:22 ?        00:00:00 ora_mmnl_prod
oracle   21475     1  0 15:22 ?        00:00:00 ora_d000_prod
oracle   21477     1  0 15:22 ?        00:00:00 ora_s000_prod
oracle   21485     1  0 15:23 ?        00:00:00 ora_qmnc_prod
oracle   21514     1  0 15:23 ?        00:00:00 ora_q000_prod
oracle   21516     1  0 15:23 ?        00:00:00 ora_q001_prod
oracle   21862     1  0 15:33 ?        00:00:00 ora_smco_prod
oracle   21881     1  0 15:33 ?        00:00:00 ora_w000_prod
oracle   21972     1  0 15:35 ?        00:00:00 ora_d001_prod  --调度进程启用
oracle   21974     1  0 15:35 ?        00:00:00 ora_d002_prod
oracle   21976     1  0 15:35 ?        00:00:00 ora_d003_prod
oracle   21978     1  0 15:35 ?        00:00:00 ora_d004_prod

2)、配置shared server
SQL> alter system set shared_servers=10;

System altered.

oracle   21441     1  0 15:22 ?        00:00:00 ora_pmon_prod
oracle   21443     1  0 15:22 ?        00:00:00 ora_psp0_prod
oracle   21445     1  1 15:22 ?        00:00:16 ora_vktm_prod
oracle   21449     1  0 15:22 ?        00:00:00 ora_gen0_prod
oracle   21451     1  0 15:22 ?        00:00:00 ora_diag_prod
oracle   21453     1  0 15:22 ?        00:00:00 ora_dbrm_prod
oracle   21455     1  0 15:22 ?        00:00:00 ora_dia0_prod
oracle   21457     1  0 15:22 ?        00:00:00 ora_mman_prod
oracle   21459     1  0 15:22 ?        00:00:00 ora_dbw0_prod
oracle   21461     1  0 15:22 ?        00:00:00 ora_dbw1_prod
oracle   21463     1  0 15:22 ?        00:00:00 ora_lgwr_prod
oracle   21465     1  0 15:22 ?        00:00:00 ora_ckpt_prod
oracle   21467     1  0 15:22 ?        00:00:00 ora_smon_prod
oracle   21469     1  0 15:22 ?        00:00:00 ora_reco_prod
oracle   21471     1  0 15:22 ?        00:00:01 ora_mmon_prod
oracle   21473     1  0 15:22 ?        00:00:00 ora_mmnl_prod
oracle   21475     1  0 15:22 ?        00:00:00 ora_d000_prod
oracle   21477     1  0 15:22 ?        00:00:00 ora_s000_prod
oracle   21485     1  0 15:23 ?        00:00:00 ora_qmnc_prod
oracle   21514     1  0 15:23 ?        00:00:00 ora_q000_prod
oracle   21516     1  0 15:23 ?        00:00:00 ora_q001_prod
oracle   21862     1  0 15:33 ?        00:00:00 ora_smco_prod
oracle   21881     1  0 15:33 ?        00:00:00 ora_w000_prod
oracle   21972     1  0 15:35 ?        00:00:00 ora_d001_prod
oracle   21974     1  0 15:35 ?        00:00:00 ora_d002_prod
oracle   21976     1  0 15:35 ?        00:00:00 ora_d003_prod
oracle   21978     1  0 15:35 ?        00:00:00 ora_d004_prod
oracle   22098     1  0 15:38 ?        00:00:00 ora_s001_prod
oracle   22100     1  0 15:38 ?        00:00:00 ora_s002_prod
oracle   22102     1  0 15:38 ?        00:00:00 ora_s003_prod
oracle   22104     1  0 15:38 ?        00:00:00 ora_s004_prod
oracle   22106     1  0 15:38 ?        00:00:00 ora_s005_prod
oracle   22108     1  0 15:38 ?        00:00:00 ora_s006_prod  --server进程启动
oracle   22110     1  0 15:38 ?        00:00:00 ora_s007_prod
oracle   22112     1  0 15:38 ?        00:00:00 ora_s008_prod
oracle   22114     1  0 15:38 ?        00:00:00 ora_s009_prod

3)客户端配置

TEST =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST=ora11g)(PORT = 1521))
  (CONNECT_DATA =
    (SEVER = SHARED)
    (SERVICE_NAME = prod)
  )
 )

[oracle@ora11g admin]$ tnsping test

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 04-NOV-2015 15:42:39

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=ora11g)(PORT = 1521)) (CONNECT_DATA = (SEVER = SHARED) (SERVICE_NAME = prod)))
OK (10 msec)

测试:

[oracle@ora11g admin]$ sqlplus system/oracle@test

SQL*Plus: Release 11.2.0.4.0 Production on Wed Nov 4 15:42:49 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

SQL> select username,sid,server from v$session where username is not null;

USERNAME                              SID SERVER
------------------------------ ---------- ---------
SYS                                     9 DEDICATED
SYSTEM                                 12 NONE



SQL> select username,SERVER,PROGRAM,OSUSER,MACHINE from v$session where username is not null;

USERNAME                       SERVER    PROGRAM                                          OSUSER                         MACHINE
------------------------------ --------- ------------------------------------------------ ------------------------------ ------------------------------
SYS                            DEDICATED sqlplus@ora11g (TNS V1-V3)                       oracle                         ora11g
SYSTEM                         NONE      sqlplus@ora11g (TNS V1-V3)                       oracle                         ora11g

4、监控共享server

SQL> col network for a50
SQL> select name ,NETWORK,PADDR ,STATUS,ACCEPT ,idle,busy from v$dispatcher;

NAME NETWORK                                            PADDR            STATUS           ACC       IDLE       BUSY
---- -------------------------------------------------- ---------------- ---------------- --- ---------- ----------
D000 (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=33225))  00000000720BA7A0 WAIT             YES     132806          0
D001 (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=49380))  00000000720C2D60 WAIT             YES      56575          0
D002 (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=21687))  00000000720C3E18 WAIT             YES      56572          0
D003 (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=53218))  00000000720C4ED0 WAIT             YES      56569          0
D004 (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=51052))  00000000720C5F88 WAIT             YES      56563          2

1) 在sga 中配置large pool
—监控dispatch的使用情况,如果使用率超过50%,需要增加dispatch

SQL> select name,(busy/(busy+idle))*100  "busy rate"  from  v$dispatcher;

NAME  busy rate
---- ----------
D000          0
D001          0
D002          0
D003          0
D004 .003085705

关注客户请求在请求队列中等待了多长时间,请求队列中等待的时间越长,则说明客户等待的时间也越长。

SQL> select decode(totalq,0,'No requests') "wait time",
  2   wait/totalq||'hundredths of seconds' "Average wait time per request" 
  3   from v$queue
  4   where type='COMMON';

wait time   Average wait time per request
----------- -------------------------------------------------------------
            0hundredths of seconds
            0hundredths of seconds
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值