oracle并行相关的parallel_max_server参数

Posted sunkang-dba

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle并行相关的parallel_max_server参数相关的知识,希望对你有一定的参考价值。

这个是测试库的问题,但是过了两天生产库也出现同样的问题了,所以大家彻查了一下原因。

目前了解的情况是与CPU核数过高、数据库的并行参数(paraller_max_server)设置过高(256)等有关,ORACLE的算法在低版本有BUG(在cpu核数超过128、并行参数设置过高时容易触发)。

 Alert日志显示在进行一个insert语句时触发了该bug引起宕机。之后重启时由于并行恢复参数设置问题,同样触发了BUG,导致无法启动。经查询metalink,通过降低CPU核数绕过该bug,完成启动。

目前metalink上未找到当前版本的补丁,后续将开展升级整改。

那么我们就来看看paraller_max_server这个东西是怎么计算的?

metlink上记录:

 

With 11.2.0.2 there is a new method to compute the default for PARALLEL_MAX_SERVERS.

In the Oracle Rdbms Reference Guide we find:
parallel_max_servers = PARALLEL_THREADS_PER_CPU * CPU_COUNT * concurrent_parallel_users * 5
In the formula, the value assigned to concurrent_parallel_users running at the default degree of parallelism on an
instance is dependent on the memory management setting.
- If automatic memory management is disabled (manual mode), then the value of concurrent_parallel_users is 1.
- If PGA automatic memory management is enabled, then the value of concurrent_parallel_users is 2.
- If global memory management or SGA memory target is used in addition to PGA automatic memory management,
then the value of concurrent_parallel_users is 4.
The value is capped by processes -15 (this is true for versions prior 11.2.0.2 as well).
As example we have the following values

parallel_threads_per_cpu = 2
cpu_count = 4
pga_aggregate_target = 500M
sga_target = 900M
processes = 150

parallel_max_servers = 2 * 4 * 4 * 5 = 160
parallel_max_servers = min( 150-15 , 160 ) = 135
So with these values we get a default of 135 for parallel_max_servers.
Note if the parallel_max_servers is reduced due to value of processes, then you see similar to the following in alert log (e.g. at instance start up):
Mon May 06 18:43:06 2013
Adjusting the default value of parameter parallel_max_servers
from 160 to 135 due to the value of parameter processes (150)
Starting ORACLE instance (normal)
所以如果这个参数太高,并行的进程就太大了,导数数据库无法承受。

这个参数值可以通过下面的语句查询:

select * from dba_hist_parameter b where b.parameter_name=‘parallel_max_servers‘ order by b.snap_id desc

从上面的内容看出oracle并行进程不能设置的太高。

 

详解

Oracle数据库并行操作,特别是在RAC环境,一定程度上能够提升数据库的性能,所以对相关的初始化参数的了解是必要的,这篇文章将根据实际的案例讨论Oracle数据库的部分并行参数。

Oracle数据库相关的并行参数:
SQL> show parameter parallel

NAME TYPE VALUE
------------------------------------ ---------------------- --------------------
fast_start_parallel_rollback string LOW
parallel_adaptive_multi_user boolean TRUE
parallel_automatic_tuning boolean FALSE
parallel_degree_limit string CPU
parallel_degree_policy string MANUAL
parallel_execution_message_size integer 16384
parallel_force_local boolean FALSE
parallel_instance_group string
parallel_io_cap_enabled boolean FALSE
parallel_max_servers integer 135
parallel_min_percent integer 0

NAME TYPE VALUE
------------------------------------ ---------------------- --------------------
parallel_min_servers integer 0
parallel_min_time_threshold string AUTO
parallel_server boolean FALSE
parallel_server_instances integer 1
parallel_servers_target integer 64
parallel_threads_per_cpu integer 2
recovery_parallelism integer 0

下面是实际Oracle RAC环境下,Oracle并行参数的设置,我们将优先讨论这些参数:
*.parallel_adaptive_multi_user=FALSE
*.parallel_execution_message_size=16384
*.parallel_max_servers=240
*.parallel_min_servers=0
*.parallel_threads_per_cpu=1

PARALLEL_ADAPTIVE_MULTI_USER
Property Description
Parameter type Boolean
Default value true
Modifiable ALTER SYSTEM
Range of values true | false
PARALLEL_ADAPTIVE_MULTI_USER, when set to true, enables an adaptive algorithm designed to improve performance in multiuser environments that use parallel execution. The algorithm automatically reduces the requested degree of parallelism based on the system load at query startup time. The effective degree of parallelism is based on the default degree of parallelism, or the degree from the table or hints, divided by a reduction factor.
当PARALLEL_ADAPTIVE_MULTI_USER参数设置为TRUE,启用设计的适当算法,在多用户环境下使用并行执行提升性能。这个算法基于查询开始时的系统负载自动减少请求的并行度。有效的并行度是基于默认的并行度,或者来自表或HINT的并行度,通过减少系数进行分割。

The algorithm assumes that the system has been tuned for optimal performance in a single-user environment.
算法假定系统在单用户环境下按照最优性能被调整。

Tables and hints use the default degree of parallelism.
表和HINT使用默认的并行度。


PARALLEL_MAX_SERVERS
Property Description
Parameter type Integer
Default value PARALLEL_THREADS_PER_CPU * CPU_COUNT * concurrent_parallel_users * 5
Modifiable ALTER SYSTEM
Range of values 0 to 3600
Oracle RAC Multiple instances can have different values.
Note:

This parameter applies to parallel execution in exclusive mode as well as in a Real Application Clusters environment.
PARALLEL_MAX_SERVERS specifies the maximum number of parallel execution processes and parallel recovery processes for an instance. As demand increases, Oracle Database increases the number of processes from the number created at instance startup up to this value.
PARALLEL_MAX_SERVERS指定实例最大并行执行进程和并行恢复进程数。随着增长需求,Oracle数据库需要增加进程数,从实例启动时创建的数目到增长值。

In the formula, the value assigned to concurrent_parallel_users running at the default degree of parallelism on an instance is dependent on the memory management setting. If automatic memory management is disabled (manual mode), then the value of concurrent_parallel_users is 1. If PGA automatic memory management is enabled, then the value of concurrent_parallel_users is 2. If global memory management or SGA memory target is used in addition to PGA automatic memory management, then the value of concurrent_parallel_users is 4.
根据上面的公式,分配给concurrent_parallel_users的值,运行在实例的默认并行度依赖于内存管理设置。如果禁用自动内存管理(手动模式),那么concurrent_parallel_user的值是1,如果启用PGA自动内存管理,那么concurrent_parallel_users的值是2。如果除了PGA自动内存管理外,还使用了全局内存管理或者SGA内存target,那么concurrent_parallel_users的值是4。

If you set this parameter too low, then some queries may not have a parallel execution process available to them during query processing. If you set it too high, then memory resource shortages may occur during peak periods, which can degrade performance.
如果设置这个参数过小,那么某些查询在查询过程中可能没有并行执行进程活动。如果设置这个参数过大,那么在峰值期间内存资源可能不足,导致性能下降。

 

PARALLEL_MIN_SERVERS
Property Description
Parameter type Integer
Default value 0
Modifiable ALTER SYSTEM
Range of values 0 to value of PARALLEL_MAX_SERVERS
Oracle RAC Multiple instances can have different values.
Note:

This parameter applies to parallel execution in exclusive mode as well as in a Real Application Clusters environment.
PARALLEL_MIN_SERVERS specifies the minimum number of parallel execution processes for the instance. This value is the number of parallel execution processes Oracle creates when the instance is started.
PARALLEL_MIN_SERVERS指定实例并行执行进程数的最小值。这个值是实例在启动时,Oracle创建的并行执行进程数。


PARALLEL_THREADS_PER_CPU
Property Description
Parameter type Integer
Default value Operating system-dependent, usually 2
Modifiable ALTER SYSTEM
Range of values Any nonzero number
Note:

This parameter applies to parallel execution in exclusive mode as well as in a Real Application Clusters environment.
PARALLEL_THREADS_PER_CPU specifies the default degree of parallelism for the instance and determines the parallel adaptive and load balancing algorithms. The parameter describes the number of parallel execution processes or threads that a CPU can handle during parallel execution.
PARALLEL_THREADS_PER_CPU指定实例默认的并行度,确定合适的并行和负载均衡算法。这个参数描述并行执行进程数,或者在并行执行期间CPU能处理的线程数。

The default is platform-dependent and is adequate in most cases. You should decrease the value of this parameter if the machine appears to be overloaded when a representative parallel query is executed. You should increase the value if the system is I/O bound.
默认值依赖于平台,在大多数情况下都是合适的。当执行一个典型的并行查询时,服务器出现过载的情况,应该减少这个参数的值。如果系统在I/O的边界应该增加这个值。


在并行参数方面,有以下最佳实践:

确保监控活动并行服务器进程的数量并计算要应用于 PARALLEL_MIN_SERVERS 的平均值。可通过以下操作完成:
Select * from v$pq_syssstat;
Then: Get/save the value for row "Servers Highwater"
根据您的硬件情况优化 PARALLEL_MAX_SERVERS的值。最开始可以使用 (2 * ( 2 个线程 ) *(CPU_COUNT)) = 4 x CPU 计算,然后使用测试数据对更高的值重复测试。
考虑设置 FAST_START_PARALLEL_ROLLBACK。此参数可确定将有多少个进程用于事务恢复(在 redo 应用后执行)。为了确保在出现计划外故障后仍能获得高效的工作负载,优化事务恢复显得非常重要。只要系统不大量占用 CPU,最佳实践是将此参数设置为值“HIGH”。这会导致 Oracle 使用四倍于 CPU 个数 (4 X cpu_count) 的并行进程进行事务恢复。此参数的默认值是“LOW”,或两倍的 CPU 计数 (2 X cpu_count)。
对于 11gR2 之前的版本,将 PARALLEL_EXECUTION_MESSAGE_SIZE 从默认值(通常为 2048)增加到 8192。对于基于数据仓库的系统(通过 PQ 传输大量数据),可以将其设置的更高。在版本 11gR2 中,PARALLEL_EXECUTION_MESSAGE_SIZE 的默认值是 16K,经证明,该值在大多数情况下都能够满足要求。

参考文章:《RAC 和 Oracle Clusterware 最佳实践和初学者指南(平台无关部分) [ID 1526083.1]》


告警日志:
在某些数据库启动的时候还能从告警日志的最开始位置看到以下的信息:
Tue May 07 23:38:27 2013
Adjusting the default value of parameter parallel_max_servers
from 1280 to 985 due to the value of parameter processes (1000)
Starting ORACLE instance (normal)

出现此告警的原因是默认计算出的parallel_max_server的值1280超过了process的最大值1000,动态调整到小于process的值。


--end--

 

 

 

 

技术图片

更多内容请关注微信公众号:数据与人

技术图片

以上是关于oracle并行相关的parallel_max_server参数的主要内容,如果未能解决你的问题,请参考以下文章

oracle并行

Spark 并行度

Oracle“并行执行”之四——监控视图

mariadb 并行复制

oracle 怎样使用并行查询

如何查询oracle 数据库并行度