ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle实验记录 (SHARED server MODE)

oracle实验记录 (SHARED server MODE)

原创 Linux操作系统 作者:fufuh2o 时间:2009-08-14 15:50:06 0 删除 编辑

shared理论很简单:client 向LISTENER 发请求,LISTENER  接到后判断请求是DEDICATE OR SHARED

SERVER  如果是DEDICATE 连接 则 LISTENER 衍生一个SERVER HANDLER(DEDICATE PROCESS),如果是

SHARED  LISTENER按算发 找一个注册(PMON注册) 在LINSTER中负载最小的DISPATCHER 进程(注意不是衍

生的 是事先配置好的) 找到后LISTENER 将 此DISPATCHER进程的PORT 给CILENT ,这样LISTENER 与

dispatcher process 连接

shared 工作原理 CILENT 将请求给DISPATCHER PRIOCESS(整个 会话期间用户始终同一个dispatcher连

接) ,DISPATCHER放入SGA中 请求队列(只有一个)
SHARED server process 从 请求队列拿走并处理 放入响应队列(每个DISPATCHER都对应一个专用的响应

队列),dispatcher返回给USER PROCESS(client)


user session data和cursor state需要放入SGA(SHARED POOL 如果配了LARGE POOL 放入LARGE POOL)
,每个SHARED SERVER PROCESS 都需要可以访问(因为它不是始终为一个SESSION 服务的),可以用PROFILE

的PRIVATE_SGA限制用户使用SGA空间

 

实现也很简单
SQL> show parameter dispatcher

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
dispatchers                          string      (protocol=tcp)(dispatchers=0)
max_dispatchers                      integer

SQL> show parameter shared_servers

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
max_shared_servers                   integer
shared_servers                       integer     0~~~~~~


SQL> show parameter cir

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
circuits                             integer

每个请求包 和每个处理结果包(放入 请求队列,响应队列  在SGA中) 每个CLIENT 请求包 叫一个

VIRTUAL CIRCUITS ,所以 这个参数就是定义了 进和入的 VIRTUAL CIRCUITS 的总数,因为存SGA中所以

对SGA 大小有影响


shared_servers 这个是动态的 比如开始设置1 有一个SNNN 随着运行 自己 增加,直到

max_shared_servers (dispatchers 是静态的) 随着SYSTEM 负载 也会自己减少

shared_server_sessions               integer:SESSIONS 参数控制可以处理会话总个数(用户会话和

系统会话)  shared_server_sessions是允许MTS 连接的 会话数,它设少一点,那么DEDICATE连接的用户

就可以多一点 (sessions- shared_server_sessions)

配置就非常简单了:
设置 shared_servers  dispatchers

SQL> alter system set dispatchers="(protocol=tcp)(dispatchers=3)";

 SQL> select program from v$process
  2  ;

PROGRAM
----------------------------------------------------------------
........................
ORACLE.EXE (MMNL)
ORACLE.EXE (q000)
ORACLE.EXE (D000)~~~~~~~~~~~~~
ORACLE.EXE (D001)~~~~~~~~~~~~~~ 3个DISPATCHER process

PROGRAM
----------------------------------------------------------------
ORACLE.EXE (D002)~~~~~~~~~~~~~~

23 rows selected.


SQL> alter system set shared_servers=1;

System altered.
PROGRAM
----------------------------------------------------------------
ORACLE.EXE (D002)
ORACLE.EXE (S000)~~~~~~~~~~~~~~~~新多的SHARED SERVER PROCESS


24 rows selected.
SQL> select name,paddr,status from v$shared_server;

NAME PADDR    STATUS
---- -------- ----------------
S000 6C8F3444 WAIT(COMMON)

SQL> col network format a40
SQL> select name,network,status from v$dispatcher;

NAME NETWORK                                  STATUS
---- ---------------------------------------- ----------------
D000 (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(P WAIT
     RT=3069))

D001 (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(P WAIT
     RT=3068))

D002 (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(P WAIT
     RT=3070))
SQL> desc v$circuit;
 Name                                      Null?    Type
 ----------------------------------------- -------- --------------------------

 CIRCUIT                                            RAW(4)
 DISPATCHER                                         RAW(4)
 SERVER                                             RAW(4)
 WAITER                                             RAW(4)
 SADDR                                              RAW(4)
 STATUS                                             VARCHAR2(16)
 QUEUE                                              VARCHAR2(16)
 MESSAGE0                                           NUMBER
 MESSAGE1                                           NUMBER
 MESSAGE2                                           NUMBER
 MESSAGE3                                           NUMBER
 MESSAGES                                           NUMBER
 BYTES                                              NUMBER
 BREAKS                                             NUMBER
 PRESENTATION                                       VARCHAR2(257)
 PCIRCUIT                                           RAW(4)

SQL> select circuit,saddr,dispatcher,server,status,waiter from v$circuit;

no rows selected来一个CILENT 就会有一条记录,里面有很多有用的信息

C:\>lsnrctl
 OK SERVER 端搞好了
LSNRCTL> services
 "DEDICATED" established:35 refused:0 state:ready
    LOCAL SERVER
 "D002" established:40 refused:0 current:40 max:1002 state:ready
    DISPATCHER
    (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(PORT=3070))
 "D001" established:40 refused:0 current:40 max:1002 state:ready
    DISPATCHER
    (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(PORT=3068))
 "D000" established:39 refused:0 current:39 max:1002 state:ready
    DISPATCHER
    (ADDRESS=(PROTOCOL=tcp)(HOST=6688-621)(PORT=3069))
 可以看出来已经注册好了到LISTENER

配置一下CLIENT的TNSNAMES.ORA吧
xh =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 6688-621)(PORT = 1521))
    (CONNECT_DATA =
      (oracle_sid  = orcl)~~~~~~~~~~没写
    )
  )
AA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 6688-621)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = SHARED)
      (oracle_sid = orcl)~~~~~~~~~~~~~~SHARED
    )
  )
BB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 6688-621)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (oracle_sid = orcl)~~~~~~~~~~~~~~专用
    )
  )
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )


SQL> conn zz/a123@bb(SID 142)~~~~~~DEDICATE
Connected.
SQL>

SQL> conn xh/a831115@aa(SID 143)~~~~~~~~~SHARED
Connected.
SQL>

SQL> conn xh/a831115@xh (SID 144)~~~~~~~DEFAULT
Connected.
SQL>
SQL> select circuit,saddr,dispatcher,server,status,waiter from v$circuit;

CIRCUIT  SADDR    DISPATCH SERVER   STATUS           WAITER
-------- -------- -------- -------- ---------------- --------
6B66892C 6C9BBBDC 6C8F2B44 00       NORMAL           00~~~~~~~~~~~~2条
6B668F8C 6C9BCDCC 6C8F2B44 00       NORMAL           00

SQL> select sid,program from v$session where saddr='6C9BBBDC' or saddr='6C9BCDCC
'
  2  ;

       SID PROGRAM
---------- ----------------------------------------------------------------
       143 sqlplus.exe
       144 sqlplus.exe~~~~~~~~DEFUALT 用SHARED


SQL> select name,paddr,status from v$shared_server;

NAME PADDR    STATUS
---- -------- ----------------
S000 6C8F3444 EXEC~~~~~~~~~当有SESSION 执行时候 状态为EXEC

SQL> select program from v$process where addr='6C8F3444';

PROGRAM
----------------------------------------------------------------
ORACLE.EXE (S000)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12020513/viewspace-612355/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-26

  • 博文量
    182
  • 访问量
    426830