/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

ORACLE参数max_shared_servers空值与零的区别

报文来源:潇湘隐者  的 《ORACLE参数max_shared_servers空值与零的区别



ORACLE数据库中的参数max_shared_servers,这是一个DBA很熟悉的参数,但是这个参数max_shared_servers为空值与为0有区别吗?这个细节可能很多人都没有注意过。如下所示:

  1 SQL> show parameter max_shared_servers
  2 
  3 NAME                                 TYPE        VALUE
  4 ------------------------------------ ----------- ------------------------------
  5 max_shared_servers                   integer
  6 SQL>
  7 
  8 SQL> show parameter shared
  9 
 10 NAME                                 TYPE        VALUE
 11 ------------------------------------ ----------- ------------------------------
 12 hi_shared_memory_address             integer     0
 13 max_shared_servers                   integer
 14 shared_memory_address                integer     0
 15 shared_pool_reserved_size            big integer 23488102
 16 shared_pool_size                     big integer 0
 17 shared_server_sessions               integer     100
 18 shared_servers                       integer     1
 19 SQL>


检查一下参数shared_servers, 这个参数不能为0,否则下面测试,连接数据库就会报“ORA-12520:TNS: 监听程序无法为请求的服务器类型找到可以用的处理程序”错误。如果shared_servers为0,将其设置为1(也请留意参数shared_server_sessions影响测试结果)

  1 SQL> alter system set shared_servers=1 scope=both;
  2 
  3 System altered.
  4 
  5 SQL>
此时检查shared server process的数量,你会发现只有一个shared server 进程,如下所示
  1 [oracle@DB-Server trace]$ ps -ef | grep ora_s00 | grep -v grep
  2 oracle    6824     1  0 15:35 ?        00:00:02 ora_s000_gsp
  3 [oracle@DB-Server trace]$
  1 --我们使用SQL Developer或PL/SQL Developer使用共享服务器模式连接到数据库,开启多个会话,每个会话执行一个类似下面的SQL语句,边开启新的会话,边检查shared server process的数量,如下所示,你会看到shared --server process的数量会一直增加。
  2 
  3 UPDATE TEST SET NAME='Kerry' WHERE ID= 1001;

image


我们将参数max_shared_servers设置为0,然后对比上面的测试来看看

  1 SQL> alter system set max_shared_servers=0 scope=both;
  2 
  3 System altered.
  4 
  5 SQL> !
  6 [oracle@DB-Server ~]$  ps -ef | grep ora_s00 | grep -v grep
  7 oracle    6824     1  0 15:35 ?        00:00:02 ora_s000_gsp
  8 [oracle@DB-Server ~]$
clip_image002

此时开启多个共享服务器连接模式的会话执行一些UPDATE语句,你会发现shared server process的数量不会变化。如下所示。

  1 [oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
  2 oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
  3 [oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
  4 oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
  5 [oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
  6 oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
  7 [oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
  8 oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
  9 [oracle@DB-Server ~]$

如果你每个会话都执行同一个UPDATE语句, 还会遇到下面错误,当然max_shared_servers为空值的情况是不会遇到这种情况的。

UPDATE TEST SET NAME='Kerry' WHERE ID= 1001;

clip_image003

可以使用下面SQL语句将max_shared_servers参数重置为空值。不过需要重启实例


  1 SQL> alter system reset "max_shared_servers" scope=spfile;
  2 
  3 System altered.
  4 
  5 SQL> shutdown immediate;
  6 
  7 Database closed.
  8 
  9 Database dismounted.
 10 
 11 ORACLE instance shut down.


  1 关于这个max_shared_servers参数为空值的情况,其实官方文档已经给出了详细描述:
  2 
  3 
  4 
  5 MAX_SHARED_SERVERS specifies the maximum number of shared server processes allowed to be running simultaneously. Setting this parameter enables you to reserve process slots for other processes, such as dedicated servers.
  6 
  7 When you want to reduce the range of shared servers, you can reduce MAX_SHARED_SERVERS before reducing SHARED_SERVERS. If MAX_SHARED_SERVERS is lower than SHARED_SERVERS, then the number of shared servers will not vary but will remain at the constant level specified by SHARED_SERVERS. If MAX_SHARED_SERVERS is not specified, then a shared server process may be spawned as long as the number of free process slots is greater than 1 / 8 the maximum number of processes, or 2 if PROCESSES is less than 24.
  8 
  9 
 10 
 11 另外其它相关参数的描述如下所示,仅供参考。
 12 
 13 SHARED_SERVERS: Specifies the initial number of shared servers to start and the minimum number of shared servers to keep. This is the only required parameter for using shared servers.
 14 
 15 
 16 MAX_SHARED_SERVERS: Specifies the maximum number of shared servers that can run simultaneously.
 17 
 18 
 19 SHARED_SERVER_SESSIONS: Specifies the total number of shared server user sessions that can run simultaneously. Setting this parameter enables you to reserve user sessions for dedicated servers.
 20 
 21 
 22 DISPATCHERS: Configures dispatcher processes in the shared server architecture.
 23 
 24 
 25 MAX_DISPATCHERS: Specifies the maximum number of dispatcher processes that can run simultaneously. This parameter can be ignored for now. It will only be useful in a future release when the number of dispatchers is auto-tuned according to the number of concurrent connections.
 26 
 27 
 28 CIRCUITS: Specifies the total number of virtual circuits that are available for inbound and outbound network sessions.
posted @ 2017-10-21 16:25  一品堂.技术学习笔记  阅读(1240)  评论(0编辑  收藏  举报