Requirements and best practices for system administrators who are configuring Greenplum Database cluster hosts.
Configuration of the Greenplum Database cluster is usually performed as root.
Configuring the Timezone
Greenplum Database selects a timezone to use from a set of internally stored PostgreSQL timezones. The available PostgreSQL timezones are taken from the Internet Assigned Numbers Authority (IANA) Time Zone Database, and Greenplum Database updates its list of available timezones as necessary when the IANA database changes for PostgreSQL.
Greenplum selects the timezone by matching a PostgreSQL timezone with the user specified time zone, or the host system time zone if no time zone is configured. For example, when selecting a default timezone, Greenplum uses an algorithm to select a PostgreSQL timezone based on the host system timezone files. If the system timezone includes leap second information, Greenplum Database cannot match the system timezone with a PostgreSQL timezone. In this case, Greenplum Database calculates a "best match" with a PostgreSQL timezone based on information from the host system.
# gpconfig -s TimeZone # gpconfig -c TimeZone -v 'US/Pacific'You must restart Greenplum Database after changing the timezone. The command gpstop -ra restarts Greenplum Database. The catalog view pg_timezone_names provides Greenplum Database timezone information.
net.ipv4.ip_local_port_range = 10000 65535
PORT_BASE = 6000 MIRROR_PORT_BASE = 7000 REPLICATION_PORT_BASE = 8000 MIRROR_REPLICATION_PORT_BASE = 9000
Set the blockdev read-ahead size to 16384 on the devices that contain data directories. This command sets the read-ahead size for /dev/sdb.
# /sbin/blockdev --setra 16384 /dev/sdb
This command returns the read-ahead size for /dev/sdb.
# /sbin/blockdev --getra /dev/sdb 16384
The deadline IO scheduler should be set for all data directory devices.
# cat /sys/block/sdb/queue/scheduler noop anticipatory [deadline] cfq
* soft nofile 524288 * hard nofile 524288 * soft nproc 131072 * hard nproc 131072
kernel.core_pattern = /var/core/core.%h.%t # grep core /etc/security/limits.conf * soft core unlimited
OS Memory Configuration
The Linux sysctl vm.overcommit_memory and vm.overcommit_ratio variables affect how the operating system manages memory allocation. These variables should be set as follows:
vm.overcommit_ratio is the percent of RAM that is used for application processes. The default is 50 on Red Hat Enterprise Linux. See Resource Queue Segment Memory Configuration for a formula to calculate an optimal value.
Do not enable huge pages in the operating system.
Validate the Operating System
Run gpcheck to validate the operating system configuration. See gpcheck in the Greenplum Database Utility Guide.
Number of Segments per Host
Determining the number of segments to execute on each segment host has immense impact on overall system performance. The segments share the host's CPU cores, memory, and NICs with each other and with other processes running on the host. Over-estimating the number of segments a server can accommodate is a common cause of suboptimal performance.
- Number of cores
- Amount of physical RAM installed in the server
- Number of NICs
- Amount of storage attached to server
- Mixture of primary and mirror segments
- ETL processes that will run on the hosts
- Non-Greenplum processes running on the hosts
Resource Queue Segment Memory Configuration
- Calculate gp_vmem, the host memory available to Greenplum Database,
gp_vmem = ((SWAP + RAM) – (7.5GB + 0.05 * RAM)) / 1.7where SWAP is the host's swap space in GB and RAM is the RAM installed on the host in GB.
- Calculate max_acting_primary_segments. This is the maximum number of primary segments that can be running on a host when mirror segments are activated due to a segment or host failure on another host in the cluster. With mirrors arranged in a 4-host block with 8 primary segments per host, for example, a single segment host failure would activate two or three mirror segments on each remaining host in the failed host's block. The max_acting_primary_segments value for this configuration is 11 (8 primary segments plus 3 mirrors activated on failure).
- Calculate gp_vmem_protect_limit by dividing the total Greenplum
Database memory by the maximum number of acting
gp_vmem_protect_limit = gp_vmem / max_acting_primary_segmentsConvert to megabytes to find the value to set for the gp_vmem_protect_limit system configuration parameter.
gp_vmem = ((SWAP + RAM) – (7.5GB + 0.05 * RAM - (300KB * total_#_workfiles))) / 1.7
For information about monitoring and managing workfile usage, see the Greenplum Database Administrator Guide.
You can calculate the value of the vm.overcommit_ratio operating system parameter from the value of gp_vmem:
vm.overcommit_ratio = (RAM - 0.026 * gp_vmem) / RAM
See OS Memory Configuration for more about about vm.overcommit_ratio.
Resource Queue Statement Memory Configuration
The statement_mem server configuration parameter is the amount of memory to be allocated to any single query in a segment database. If a statement requires additional memory it will spill to disk. Calculate the value for statement_mem with the following formula:
(gp_vmem_protect_limit * .9) / max_expected_concurrent_queries
For example, for 40 concurrent queries with gp_vmem_protect_limit set to 8GB (8192MB), the calculation for statement_mem would be:
(8192MB * .9) / 40 = 184MB
Each query would be allowed 184MB of memory before it must spill to disk.
To increase statement_mem safely you must either increase gp_vmem_protect_limit or reduce the number of concurrent queries. To increase gp_vmem_protect_limit, you must add physical RAM and/or swap space, or reduce the number of segments per host.
Note that adding segment hosts to the cluster cannot help out-of-memory errors unless you use the additional hosts to decrease the number of segments per host.
Spill files are created when there is not enough memory to fit all the mapper output, usually when 80% of the buffer space is occupied.
Also, see Resource Management for best practices for managing query memory using resource queues.
Resource Queue Spill File Configuration
Greenplum Database creates spill files (also called workfiles) on disk if a query is allocated insufficient memory to execute in memory. A single query can create no more than 100,000 spill files, by default, which is sufficient for the majority of queries.
You can control the maximum number of spill files created per query and per segment with the configuration parameter gp_workfile_limit_files_per_query. Set the parameter to 0 to allow queries to create an unlimited number of spill files. Limiting the number of spill files permitted prevents run-away queries from disrupting the system.
A query could generate a large number of spill files if not enough memory is allocated to it or if data skew is present in the queried data. If a query creates more than the specified number of spill files, Greenplum Database returns this error:
ERROR: number of workfiles per query limit exceeded
Before raising the gp_workfile_limit_files_per_query, try reducing the number of spill files by changing the query, changing the data distribution, or changing the memory configuration.
The gp_toolkit schema includes views that allow you to see information about all the queries that are currently using spill files. This information can be used for troubleshooting and for tuning queries:
- The gp_workfile_entries view contains one row for each operator using disk space for workfiles on a segment at the current time. See How to Read Explain Plansfor information about operators.
- The gp_workfile_usage_per_query view contains one row for each query using disk space for workfiles on a segment at the current time.
- The gp_workfile_usage_per_segment view contains one row for each segment. Each row displays the total amount of disk space used for workfiles on the segment at the current time.
See the Greenplum Database Reference Guide for descriptions of the columns in these views.
The gp_workfile_compress_algorithm configuration parameter specifies a compression algorithm to apply to spill files. It can have the value none (the default) or zlib. Setting this parameter to zlib can improve performance when spill files are used.