Dedicated Server Process
客户端连接只需建立一次tcp:
但根据在实际实验时看到的现象,dedicated server process并不是listener的子进程,如下所示:
$ ps -ef | grep oracle
oracle 3242 3201 0 03:52 pts/0 00:00:00 sqlplus (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 3956 1 0 04:07 pts/0 00:00:00 /u01/oracle/bin/tnslsnr LISTENER -inherit
oracle 5563 1 4 12:46 pts/0 00:00:00 oraclelty (LOCAL=NO)
oracle 5564 3871 0 12:46 pts/0 00:00:00 ps -ef
oracle 5565 3871 0 12:46 pts/0 00:00:00 grep oracle
Shared Server
客户端连接须建立两次tcp:
推荐将队列缓存区置于larg pool里,须设置large_pool_size 参数值。
一个dispatcher最多可以支持的连接数与操作系统平台有关。
Configuring Oracle Shared Server
• Required initialization parameters
– DISPATCHERS
– SHARED_SERVERS
• Optional initialization parameters
– MAX_DISPATCHERS
– MAX_SHARED_SERVERS
– CIRCUITS
– SHARED_SERVER_SESSIONS
dispatcher启动个数是静态的,初始化启动个数由DISPATCHERS决定。通过alter system命令改变启动个数。而shared servers的个数可以动态增加,初始启动个数由SHARED_SERVERS决定。
Tips:
在调试时如有需要,可以将MAX_SHARED_SERVERS值设为0(不能再内存中修改),关闭shared server模式。即使将shared_servers值设为0,当有客户端链接进来时oracle会自动产生share server进程。
dispatcher与shared server的通信链路称为一条virtual circuit,分inbound和outbound。即dispatcher—--request queue----shared server是inbound虚链路,shared server----response queue----dispatcher为outbound虚链路。
CIRCUITS参数值决定了虚链路(包括inbound和outbound)总数。这个值也影响了整个SGA的大小。
SHARED_SERVER_SESSIONS值决定了所有shared server所能同时处理的session数。这里是对整个oracle而言的,不是对单个shared server。
初始化参数中有个参数sessions,这个值决定了oracle能同时处理的session数,所以这个参数值与SHARED_SERVER_SESSIONS的值也就决定了留给dedicated servers能同时处理的session数。
注意:如果listener监听端口不是默认值1521时,必须配置local_listener参数或者在dispatchers参数值中指定tnsname。
配置举例:
SQL> show parameter dispat
NAME TYPE VALUE
------------------------- ----------- -------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=ltyXDB)
max_dispatchers integer 5
SQL> alter system set dispatchers='(protocol=tcp)(dispatchers=1)';
System altered.
SQL> show parameter disp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (protocol=tcp)(dispatchers=1)
max_dispatchers integer 5
mts_dispatchers string (protocol=tcp)(dispatchers=1)
#注意:如果原来spfile中没有配置dispatchers这个参数,则有可能在oracle启动后修改dispatchers值。这个一旦定义就不能在spfile中被修改,如:
SQL> alter system set dispatchers='(protocol=tcp)(dispatchers=2)' scope=spfile;
alter system set dispatchers='(protocol=tcp)(dispatchers=2)' scope=spfile
*
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM
解决方法是,先由spfile创建pfile。在pfile中更改后再由pfile创建spfile。
另外,在修改这些值前最好先启动listener。否则可能出现修改这些值后无法同步在listener中注册的情况。
SQL> !
[oracle@localhost ~]$ ps -ef | grep oracle
……
oracle 3360 1 0 04:01 ? 00:00:00 ora_s000_lty #shared server进程。
oracle 3362 1 0 04:01 ? 00:00:00 ora_d000_lty #dispatcher进程。
……
SQL> show parameter disp
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (protocol=tcp)(dispatchers=1)
max_dispatchers integer 5
mts_dispatchers string (protocol=tcp)(dispatchers=1)
mts_max_dispatchers integer 5
SQL> alter system set dispatchers='(protocol=tcp)(dispatchers=4)';
System altered.
SQL> show parameter shared_ser
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers integer 20
shared_server_sessions integer 165
shared_servers integer 1
SQL> alter system set shared_servers=3;
System altered.
SQL> !
[oracle@localhost ~]$ ps -ef | grep oracle
……
oracle 3360 1 0 04:01 ? 00:00:00 ora_s000_lty
oracle 3362 1 0 04:01 ? 00:00:00 ora_d000_lty
oracle 3364 1 0 04:01 ? 00:00:00 ora_arc0_lty
oracle 3366 1 0 04:01 ? 00:00:00 ora_arc1_lty
oracle 7109 1 0 17:04 ? 00:00:00 ora_d001_lty
oracle 7111 1 0 17:04 ? 00:00:00 ora_d002_lty
oracle 7113 1 0 17:04 ? 00:00:00 ora_d003_lty
……
[oracle@localhost admin]$ lsnrctl service
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
Services Summary...
Service "lty.suny.com" has 1 instance(s).
Instance "lty", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "ltyXDB.suny.com" has 1 instance(s).
Instance "lty", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1002 state:ready
DISPATCHER <machine: localhost.localdomain, pid: 7243>
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1468))
The command completed successfully
验证:
使用客户端链接后,
SQL> select circuit,dispatcher,status from v$circuit;
CIRCUIT DISPATCH STATUS
-------- -------- ----------------
5AEFBAF8 5A290E48 NORMAL
或者:
$ netstat -anp | more
……
tcp 0 0 192.168.1.10:1521 192.168.1.200:51013 ESTABLISHED 5151/ora_d001_lty
同时使用专用服务器和Oracle Shared Server
客户端tnsnames.ora配置
ORACLE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = lty.suny.com)
)
)
#在常规配置模式下,如上。Oracle优先使用shared server。
ORACLE_SHARED =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = lty.suny.com)
(SERVER = shared)
)
)
#在此模式下使用shared模式,在dispatchers不可用时链接将被拒绝。
ORACLE_DEDI =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = lty.suny.com)
(SERVER = dedicated)
)
)
#在此模式下将使用dedicated模式链接。
验证:
[oracle@localhost admin]$ netstat -anp | more
……
tcp 0 0 127.0.0.1:1521 127.0.0.1:46663 ESTABLISHED 6249/tnslsnr
tcp 0 0 127.0.0.1:46663 127.0.0.1:1521 ESTABLISHED 6096/ora_pmon_lty
tcp 0 0 192.168.1.10:1521 192.168.1.200:51468 ESTABLISHED 6114/ora_d000_lty
tcp 0 0 192.168.1.10:1521 192.168.1.200:51467 ESTABLISHED 6114/ora_d000_lty
tcp 0 0 192.168.1.10:1521 192.168.1.200:51474 ESTABLISHED 6325/oraclelty
何时使用专用服务器
•提交批作业(预计很少有或没有空闲时间)
•以sysdba 身份连接以启动、关闭或执行恢复
•在三层架构中,中间件与oracle服务器之间。
启动关闭数据库时不能以shared方式链接,否则出错:ORA-00106: cannot startup/shutdown database when connected to a dispatcher
相关视图:
• V$CIRCUIT
• V$SHARED_SERVER
• V$DISPATCHER
• V$SHARED_SERVER_MONITOR
• V$QUEUE
• V$SESSION
问题:listener.ora如下无法同时启动shared server,无法再listener中注册?
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = lty.suny.com)
(ORACLE_HOME = /u01/oracle)
(SID_NAME = lty)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
蓝色部分改成如下情况下可以使用shared server:
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
本文转自 d185740815 51CTO博客,原文链接:http://blog.51cto.com/luotaoyang/312677,如需转载请自行联系原作者