ORACLE参数max_shared_servers空值与零的区别

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

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

 

 
SQL> show parameter max_shared_servers
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers                   integer
SQL> 
 
SQL> show parameter shared  
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address             integer     0
max_shared_servers                   integer
shared_memory_address                integer     0
shared_pool_reserved_size            big integer 23488102
shared_pool_size                     big integer 0
shared_server_sessions               integer     100
shared_servers                       integer     1
SQL> 

 

 

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

SQL> alter system set shared_servers=1 scope=both;
 
System altered.
 
SQL> 

 

 

此时检查shared server process的数量,你会发现只有一个shared server 进程,如下所示

 

[oracle@DB-Server trace]$ ps -ef | grep ora_s00 | grep -v grep
oracle    6824     1  0 15:35 ?        00:00:02 ora_s000_gsp
[oracle@DB-Server trace]$ 

 

我们使用SQL Developer或PL/SQL Developer使用共享服务器模式连接到数据库,开启多个会话,每个会话执行一个类似下面的SQL语句,边开启新的会话,边检查shared server process的数量,如下所示,你会看到shared server process的数量会一直增加。

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

 

 

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

 

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

 

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

 

[oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
[oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
[oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
[oracle@DB-Server ~]$ ps -ef | grep ora_s00 | grep -v grep
oracle    8396     1  0 17:21 ?        00:00:00 ora_s000_gsp
[oracle@DB-Server ~]$ 

 

 

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

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

 

 

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

SQL> alter system reset "max_shared_servers" scope=spfile;
 
System altered.
 
SQL> shutdown immediate;
 
Database closed.
 
Database dismounted.
 
ORACLE instance shut down.

 

 

关于这个max_shared_servers参数为空值的情况,其实官方文档已经给出了详细描述:

 

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.

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.

 

另外其它相关参数的描述如下所示,仅供参考。

  • 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.

 

  • MAX_SHARED_SERVERS: Specifies the maximum number of shared servers that can run simultaneously.

 

  • 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.

 

  • DISPATCHERS: Configures dispatcher processes in the shared server architecture.

 

  • 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.

 

  • CIRCUITS: Specifies the total number of virtual circuits that are available for inbound and outbound network sessions.

相关文章
|
2月前
|
Oracle 关系型数据库 Java
Oracle 19c 查看隐含参数视图
Oracle 19c 查看隐含参数视图
44 7
|
2月前
修改oracle11g的awr快照参数
修改oracle11g的awr快照参数
16 0
|
2月前
|
SQL 监控 Oracle
Oracle 性能优化之AWR、ASH和ADDM(含报告生成和参数解读)
Oracle 性能优化之AWR、ASH和ADDM(含报告生成和参数解读)
|
2月前
|
运维 Oracle 关系型数据库
Oracle服务器参数文件:数据王国的“调控大师”
【4月更文挑战第19天】Oracle服务器参数文件,数据库的“调控大师”,掌控着内存管理、进程调度等关键设置。通过参数调整如SGA_MAX_SIZE和PROCESSES,实现性能优化和故障防控。虽然挑战重重,但成功的性能调优带来无尽成就感。它在备份恢复中也扮演重要角色,保障数据一致性与可用性。成为真正的“调控大师”,为数据王国效力!
|
2月前
|
存储 SQL Oracle
【Oracle】玩转Oracle数据库(二):体系结构、存储结构与各类参数
【Oracle】玩转Oracle数据库(二):体系结构、存储结构与各类参数
58 7
|
2月前
|
SQL Oracle 关系型数据库
避坑,Oracle中left join 与 (+) 的区别
避坑,Oracle中left join 与 (+) 的区别
|
2月前
|
Oracle 关系型数据库 MySQL
mysql数据库和Oracle的区别
mysql数据库和Oracle的区别
71 1
|
2月前
|
SQL Oracle 关系型数据库
Oracle查询优化-left join、right join、inner join、full join和逗号的区别
【1月更文挑战第5天】【1月更文挑战第13篇】实际查询时,多表联查是常规操作,但是连接方式有多种。
125 0
|
2月前
|
Oracle 关系型数据库 数据库
Oracle查询优化-处理排序空值
【1月更文挑战第3天】【1月更文挑战第8篇】在处理Oracle查询结果排序时,如果涉及到空值(null),Oracle提供了一些特定的语法来帮助您控制排序的顺序。
37 0
|
2月前
|
SQL Oracle 关系型数据库
Oracle查询优化-处理空值
【1月更文挑战第1天】【1月更文挑战第1篇】数据库中的空值(例如:NULL或者 '')会导致一些不可预知的错误,因此需要在查询时就要处理好,确保数据查询的准确性,减轻代码压力。
97 0