Oracle MTS的相关问题

上一篇 / 下一篇  2009-03-01 16:45:22 / 个人分类:Oracle

  • 文件版本: V1.0
  • 开发商: 本站原创
  • 文件来源: 本地
  • 界面语言: 简体中文
  • 授权方式: 免费
  • 运行平台: Win9X/Win2000/WinXP

一、什么是MTS

MTS = Multi-Threaded Server
MTS是ORACLE SERVER的一个可选的配置选择,是相对DEDICATE方式而言,它最大的优点是在以不用增加物理资源(内存)的前提下支持更多的并发的连接。
Joseph C.Johnson以餐馆给出一个MTS的形象的比喻  
Na4y} E8{X6fG0  假设ORACLE是一家餐馆,当你走进一家餐馆时你感觉最舒服的服务方式就是有一个专门的waiter来为你服务,而不管餐馆中来了多少人,她只对你请求应答,这是DEDICTE的处理方式,也就是说每一个ORACLE客户端的连接都有一个专门的服务进程来为它服务。而大部的餐馆的服方式都不是一对一的,当你走进的时侯,你就被指定了一个waiter,她也可能为其它桌服着务,这对于餐馆来说是最有利的,因为他们可以服务更多的客人而不需要增加他们的员工。这样对你来说也可能是不错的,如果餐馆不是太忙,她服务的客人的请求都很简短且容易完成,你的感觉也好像自己拥有一个专门的waiter,waiter把你的ORDER转给厨师,然后把做好的菜拿给你,这就是MTS的处理方式,这些共享的waiters我们叫她们为Dispatchers,厨师我们则叫他们为Shared Server Processes。
 

二、MTS架构

[metalink-Note:29038.1]
1.  Oracle Multi-Threaded Server Architecture.51Testing软件测试网`s F J}7r U4U ]$A
----------------------------------------------
/s2~+v? pT'w[051Testing软件测试网kn!Y/[5CH4BdK$q^p
                            +-----------+   user
G/O Bmd4X"c5N%EM_e0                           +-----------+|   processes
&ve W E[Q0                           |           ||
;R\c:];Rf K0                           |APPLICATION||51Testing软件测试网H5w aK:A3D
                           |   CODE    ||
]4yW `/zF J0                           |           |+51Testing软件测试网l"NnY|0x4x!`-C)F
                           +-----------+51Testing软件测试网"W)CaD!P B"z
                                /|\
!O5f!|9Z'\D CVK4m0                                 |                     CLIENT51Testing软件测试网kF,E$G)p N
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+y4L)O.|6b0                                 |                     SERVER
.^%AcL&yx$H-nI9d8]0                                \|/
O,L6r7Q,KF0                       +----------------------------------+
'E&Vnd7gl3A0                      +----------------------------------+|
(dx+t \ B0                      |                                  ||
Ef`~:?h E0                      |       DISPATCHER PROCESSES       || 
-Q:TVH*R0                      |                                  |+  51Testing软件测试网vC:|,[ OB
                      +----------------------------------+    
e9N+JANt0                        |                             /|\51Testing软件测试网S'KO6S M
                        |                              |51Testing软件测试网.S4Mn\_9eyu&O
                        |     +-----------+            |51Testing软件测试网P]0F S:q0t
                        |    +-----------+| shared     |51Testing软件测试网:} E$yA#Q+z!yJ
                        |   +-----------+|| server     |51Testing软件测试网N!wi {*CN
                        |   |  ORACLE   ||+ processes  |
:D-rDEy%O*C#Ho%Wj0                        |   |SERVER CODE|+             |51Testing软件测试网g`%Xw!qoy{$VT{
                        |   +-----------+              |
u'^ v)JX9a*bVv0                        |    /|\ /|\  |                |51Testing软件测试网 i1j w$G n h#z
                        |     |   |   |                |51Testing软件测试网n"q!U;`osI*L
                        |     |   |   |                |51Testing软件测试网.zGFDmV$K
                        |     |  \|/  |                |51Testing软件测试网iI$lI'H
        +---------------|-----|-------|----------------|-------+51Testing软件测试网(v%B4r(Rk9z
        |              \|/    |      \|/               |       |
g9?Akj;e1_G7x0        |   +-------------------+   +----------------------+   |51Testing软件测试网 ^0`AWpT
        |   |     REQUEST       |   |   RESPONSE QUEUES    |   |
dZA oRd ?Q0        |   |     QUEUES        |   +----------------------+   |51Testing软件测试网?k%\2z:\&R&[
        |   +-------------------+                              |51Testing软件测试网w ]MoP W4z6{
        |                  SYSTEM GLOBAL AREA                  |
7U-},z[3XPX0K0        |                                                      |51Testing软件测试网9Y\"`2Hr0i{7N
        +------------------------------------------------------+
u't*I m9p0
51Testing软件测试网E/yf!HH y
Client Connections to MTS
Der3x'ju\0    ~~~~~~~~~~~~~~~~~~~~~~~~~
?S)JR&t4X0 A client process wanting to connect to an Oracle instance using MTS
[XA/tYzs0 should go through the following steps:
  a) Call the listener
kNE&A2f7aaY0  b) The listener tells it to call back on the address where51Testing软件测试网$_?#N f6`6O!_'J
     the dispatcher is listening (a REDIRECT)51Testing软件测试网5G1vl&TuF
  c) The client calls the dispatcher and establishes a connection.51Testing软件测试网 ibPd%EcNZ)k
  d) The dispatcher now has a CLIENT connection ESTABLISHED and51Testing软件测试网W0]3k vN[ h$H
     will also continue to listen for any new connections.
c;zh6?H0  e) The client sends a SQL message to the dispatcher.51Testing软件测试网Nk2Oo0x)Y
  f) The dispatcher unwraps this message packet and places the51Testing软件测试网NhA4v`
     request onto a queue in the SGA (System Global Area).51Testing软件测试网:zb7l9Rzs-O$e3}
     This queue has NOTHING to do with SQL*Net. The SQL*Net
Dip0A9d0     layer ends in the dispatcher.51Testing软件测试网vA}9I o*D4Z ISn
  g) A shared server will pick up the request from the SGA queue
-|*l'yr]e0     and process it. When there is any result this is placed
V$rD:x-hm2W0     on a separate queue in the SGA ready for the dispatcher.51Testing软件测试网c0Z.H(vJX.D
  h) The dispatcher picks up the response message from the SGA
] j9}~(Fk2r0     and wraps this into a SQL*Net message. This is passed51Testing软件测试网B@(m$m&a]
     back to the client.
 

三、确定你的DB是否在使用MTS

[metalink-Note:1071305.6]
Solution Description:
\ O.G d*G3J"Nw0=====================
6Sw-ou1A/{#p,I(E0 
%Ph8m2['[LC0Look at the "init.ora" parameter MTS_DISPATCHERS.
rbK$d6o4h4GM Z nv0 
%G4aN L(Pk y0MTS_DISPATCHERS defines the number of dispatchers created when the instance51Testing软件测试网m^[7S\
starts up. If this is set to zero, or is null (default value), then you are NOT
(S Ju;v2yx0using MTS.
If MTS_DISPATCHERS is greater than zero, then check these other "init.ora"
a2v/a1DW`%`0parameters for valid values:
   MTS_MAX_DISPATCHERS  Maximum number of dispatchers51Testing软件测试网~,B7["n}'c+N\
   MTS_SERVERS  Number of server processes created at startup
E@)Y4T"A1w3Q0   MTS_MAX_SERVERS  Maximum number of shared server processes51Testing软件测试网D9r*WB:K!i GY D@
   MTS_SERVICE  SID51Testing软件测试网[c!A}J$m$[
   MTS_LISTENER_ADDRESS  Configuration of the listener
/nV vW:n3Cw+ik0 
Solution Explanation:
A'CQ [6m r} I%m0A0=====================
+s"O/RTn+\0 51Testing软件测试网xK.[%`-` F&Ubx
These other "init.ora" parameters may have valid values, but if MTS_DISPATCHERS51Testing软件测试网H"y^-RT%DV-z8K.eC
is zero or null, MTS is not being used.

四、MTS相关参数的含义

[metalink-Note:29038.1]
The main parameters required to start MTS are:
  o MTS_SERVICE - This parameter establishes the name of the MTS service
.^.jAM P!Fy9Vh0    that clients connect to, in order for the dispatchers to handle requests.51Testing软件测试网-KS4iIh*T%E:RB
   
O6f/[LBew(|\0  o MTS_DISPATCHERS - Dispatchers are detached processes that handle client51Testing软件测试网!V Po;D!TD
    process requests and communicate them to server processes for execution.
    This parameter defines the number of dispatchers to startup for51Testing软件测试网 S:v+?3ca]#H3b r
    each protocol that is configured for MTS.  For example,
.nO]#T$bFEy1L0 51Testing软件测试网"G^*X"L&f ^_(VE
         mts_dispatchers = "ipc, 2"
  o MTS_SERVERS - This is the number of shared server processes that51Testing软件测试网dwG7o)\
    start at instance startup time.  Shared servers service the51Testing软件测试网4V;S:y#J!@+p nU%cA
    client requests passed on to them by the dispatchers.
  o MTS_LISTENER_ADDRESS - This is the full address for dispatchers to listen
*v3rv$NOg.d0    on, and is the same as the address configured in the TNS listener.  The
x#?h0\M)}I0    address specification is protocol-specific.  For example:
         mts_listener_address = "(address=(protocol=ipc)(key=sw))"

五、使用MTS连接DB

先在主机命令行$ lsnrctl services;
"D000" established:0 refused:0 current:1 max:972 state:ready51Testing软件测试网7X4?+j4D:Wi;Xd
         DISPATCHER <machine: db1, pid: 3950>
qTXd6Xip0         (ADDRESS=(PROTOCOL=tcp)(HOST=eagle1)(PORT=33166));
查看dispather的监听端口号——33166。(dispather进程名称一般是 ora_dNNN_SID,NNN in (000-999))
在client端的tnsname.ora中,注意:
TODB_MTS =
p_C r.{o3R0  (DESCRIPTION =
~,Ve0X~'oZ0    (ADDRESS_LIST =51Testing软件测试网tS j)g$X A}
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 33166))
EjKh|? h^[0    )51Testing软件测试网:kfU _V G j$Y
    (CONNECT_DATA =
zP"RC L0     (SERVER = SHARED)
.E,W,F4a a0      (SERVICE_NAME = dbname)
F"t#A'm4O)C"p9Yo0    )51Testing软件测试网QFS0Q1N F
  )
这样可以解决ora-12520问题(当然这只是解决方法之一)

六、一问一答

Q:MTS一定比Delicated模式好吗?
A:不是。如果硬件好点,建议使用Delicated模式。biti语录:“我是能不用MTS就不用”
Q:MTS与Delicated模式可以相互转换吗?
A:可以。
MTS => Delicated
Reset the MTS Parameters in init.ora and reopen your DB.
Delicated => MTS
Added the MTS Parameters in init.ora and reopen your DB.
Q:MTS模式下可以用Delicated连进来吗?
A:可以。(SERVER = Delicated)即可。反之则不行。
Q:RAC环境一定得是MTS吗?
A:不是。
Q:JDBC thin 支持MTS吗?
A:目前不支持。

TAG:

 

评分:0

我来说两句

Open Toolbar