10 配置Greenplum数据库
服务器配置参数影响Greenplum数据的行为。他们是PostgreSQL的“Grand Unified Configuration”系统的一部分,所以它们有时被称为“GUCs”。大多数Greenplum数据服务器的配置参数的相同PostgreSQL的配置参数,但也有一些Greenplum的特异性。
10.1 关于Greenplum的主节点和本地参数
服务器配置文件包含配置服务器行为参数。在Greenplum的数据库配置文件,postgresqi.conf,驻留在数据库实例的数据目录。
master和每段实例都有自己的postgresqi.conf文件。一些参数是地方:每段实例检查它的postgresqi.conf文件,以获取参数的值。在主并在每段实例设置本地参数。
其他参数,你在master实例设置主参数。该值向下传递给(或在某些情况下忽略)在查询运行时该段实例。
看到Greenplum数据参考指南有关本地和主服务器配置参数的信息。
10.2 设置配置参数
许多配置参数限制谁可以改变它们在哪里或当他们可以设置。例如,要改变某些参数,你必须是一个Greenplum数据引擎超级用户。其他参数只能在postgresqi.conf文件系统级设置或需要重新启动系统才能生效。
许多配置参数是会话参数。您可以在系统级别上设置会话参数,数据库级别,角色级别或会话级。数据库用户可以将其会话中改变大多数会话参数,但有些需要超级用户权限。
看到Greenplum数据参考指南有关设置服务器配置参数信息。
10.2.1设置本地参数
若要更改跨多个段的本地配置参数,在每个目标市场中的postgresql.conf文件更新参数,主区段和镜像段。使用gpconfig效用在所有的Greenplum postgresql.conf文件来设置的参数。 例如:
$gpconfig-c gp_vmem_protect_limit-v4096MB
重新启动Greenplum数据引擎,以使配置更改生效:
$ gpstop -r
10.2.2 设置主节点配置参数
要设置主配置参数,在Greenplum的主实例设置。如果它也是一个会话参数,可以设置一个特定的数据库,角色或会话参数。如果参数设置多层次的,最精细的级别优先。例如,session将覆盖role,角色将覆盖数据库和数据库覆盖系统。
主postgresql.conf文件主参数设置系统范围的默认值。要设置主参数:
1.编辑$ MASTER_DATA_DIRECTORY/postgresql.conf文件。
2.找到参数来设置,取消注释(删除前面的#字符),然后键入所需的值。
3.保存并关闭文件。
4.对于不需要重新启动服务器,上传在postgresql.conf变化如下会话参数:
$ gpstop -u
5.对于需要重新启动服务器,如下所示重启Greenplum数据引擎的参数变化:
$ gpstop –r
有关服务器配置参数的详细信息,请参阅Greenplum数据参考指南。
使用ALTER DATABASE在数据库级别设置参数。例如:
=# ALTERDATABASE mydatabase SET search_path TO myschema;
当你在数据库级别设置会话参数,每一个连接到数据库会话使用该参数设置。在在系统级数据库级别覆盖的设置。
使用alter role在角色级别设置的参数。例如:
=# ALTER ROLE bob SET search_path TO bobschema;
当你在角色级别设置会话参数,该角色发起的每个会话使用该参数设置。在数据库级别角色级别覆盖的设置。
任何会话参数可以在活跃数据库会话使用SET命令来设置。例如:
=# SETstatement_mem TO '200MB';
参数设置是有效的该会话结束或直到发出复位命令。例如:
=# RESET statement_mem;
在会话级别的设置将覆盖那些角色级别。
10.3 查看服务器参数设置
SQL命令SHOW允许您查看当前服务器配置参数设置。例如,可查看所有参数的设置:
$ psql -c 'SHOW ALL;'
SHOW列出了只有主实例的设置。要查看整个系统(主机和所有段)的特定参数的值,使用gpconfig实用工具。 例如:
$ gpconfig--show MAX_CONNECTIONS
10.4 配置参数目录
配置参数影响服务器的行为,如资源消耗,查询优化和认证的类别。以下主题描述了Greenplum数据引擎配置参数类别。
有关配置参数类别的详情,请参阅Greenplum数据参考指南。
•配置参数分类
•系统资源消耗参数
•查询调整参数
•错误报告和记录参数
•系统监测参数
•运行时统计信息收集参数
•自动统计数据收集参数
•客户端连接默认参数
•锁定管理参数
•工作负荷管理参数
•外部表的参数
•数据库表参数
•数据库和表空间/文件空间参数
•过去PostgreSQL的版本兼容性参数
•Greenplum的阵列配置参数
•Greenplum的法师和段镜像参数
•Greenplum的数据库扩展参数
10.4.1 运行时统计信息收集参数
这些参数控制服务器统计数据收集功能。如果启用了统计信息收集,您可以访问使用pg_stat和系统目录视图pg_statio family统计数据。
stats_queue_level | track_counts |
track_activities | update_process_title |
10.4.2 自动统计数据收集参数
当启用自动统计数据收集,可以运行在同一个事务自动分析
作为一个INSERT,UPDATE,删除,复制或CREATE TABLE...当行的特定阈值的影响(on_change)AS SELECT语句,或者当一个新产生的表中没有统计(on_no_stats)。
要启用此功能,请在Greenplum的主postgresqi.conf文件中设置下面的服务器配置参数并重新启动Greenplum数据:
•gp_autostats_mode
•gp_autostats_mode_in_functions
•log_autostats
•gp_autostats_on_change_threshold
警告:根据您的数据库操作的具体性质,自动统计数据收集可以有一个负面的性能影响。仔细评估on_no_stats的默认设置是否适合您的系统。
10.4.3锁管理参数
• deadlock_timeout
• max_locks_per_transaction
10.4.4工作负载管理参数
以下配置参数配置Greenplum的数据库工作负载管理功能(资源队列),查询优先级,内存利用率和并发控制。
gp gp_resqueue_priority gp_resqueue_priority_cpucores_per_segment gp_resqueue_priority_sweeper_interval gp_vmem_idle_resource_timeout gp_vmem_protect_limit gp_vmem_protect_segworker_cache_limit | max_resource_portals_per_transaction resource_cleanup_gangs_on_wait resource_select_only runaway_detector_activation_percent stats_queue_level |
10.4.5外部表参数
下面的参数配置Greenplum数据的外部表功能。请参阅访问基于文件的外部表有关外部表的详细信息。
gp_external_enable_exec gp_external_grant_privileges gp_external_max_segs | gp_initial_bad_row_limit gp_reject_percent_threshold readable_external_table_timeout writable_external_table_bufsize |
10.4.6数据库表参数
为Greenplum的数据库表下面的参数配置的默认选项设置。
请参阅有关的Greenplum数据库表的详细信息创建和管理表。
• gp_create_table_random_default_distribution
• gp_default_storage_options
• gp_enable_exchange_default_partition
Append-Optimized Table Parameters
下面的参数配置Greenplum数据引擎的附加优化表功能。见追加最优化的存储有关附加优化表的详细信息。
• gp_default_storage_options
• max_appendonly_tables
• gp_appendonly_compaction
• gp_appendonly_compaction_threshold
10.4.6.1 数据库和表空间/文件空间参数
下面的参数设置数据库,表空间,文件空间在系统中的最大数maximum number
• gp_max_tablespaces
• gp_max_filespaces
• gp_max_databases
10.4.7 Past PostgreSQL Version Compatibility Parameters
下面的参数提供对旧的PostgreSQL版本兼容。你并不需要更改Greenplum数据这些参数。
add missing from | regex flavor |
array nulls | standard conforming strings |
backslash quote | transform null equals |
escape string warning |
|
10.4.8 Greenplum Master and Segment Mirroring Parameters
下面的参数是控制primary master 和 standby master之间的复制功能参数。keep_wal_segments
• repl_catchup_within_range
• replication_timeout
• wal_receiver_status_interval
This parameter controls validation betweenGreenplum Database primary segment and standby segment during incrementalresynchronization.
• filerep_mirrorvalidation_during_resync
10.4.9 Greenplum Database Extension Parameters
The parameters in this topic control theconfiguration of Greenplum Database extensions.
• pgcrypto.fips
• pljava_classpath
• pljava_statement_cache_size
• pljava_release_lingering_savepoints
• pljava_vmoptions
10.4.10 连接和认证参数
这些参数控制客户端如何连接和认证Greenplum。
SeeManaging GreenplumDatabase Access for information aboutconfiguring client authentication.
gp_connection_send_timeout gp_vmem_idle_resource_timeout listen_addresses max_connections max_prepared_transactions superuser_reserved_connections |
|
10.4.10.2 Security and Authentication Parameters
authentication_timeout db_user_namespace krb_caseins_users krb_server_keyfile | krb_srvname password_encryption password_hash_algorithm ssl ssl_ciphers |
10.4.11 系统资源消耗参数
这些参数控制系统的内存使用情况。您可以调整gp_vmem_protect_limit避免查询处理过程中电量耗尽的在段上的主机内存。Theseparameters control system memory usage. You can adjust gp_vmem_protect_limitto avoid running out of memory at the segment hosts during query processing.
gp_vmem_idle_resource_timeout gp_vmem_protect_limit gp_vmem_protect_segworker_cache_limit gp_workfile_limit_files_per_query gp_workfile_limit_per_query gp_workfile_limit_per_segment max_appendonly_tables max_prepared_transactions | max_stack_depth shared_buffers temp_buffers |
10.4.11.2 Free Space Map Parameters
These parameters control the sizing of the free space map, which contains expired rows. Use vacuum to reclaim the free space map disk space.
SeeVacuum and Analyze forQuery Optimization for information aboutvacuuming a database.
• max_fsm_pages
• max_fsm_relations
10.4.11.3 OS Resource Parameters
• max_files_per_process
• shared_preload_libraries
10.4.11.4 Cost-Based Vacuum Delay Parameters
Warning: Pivotal does not recommend cost-basedvacuum delay because it runs asynchronously among the segment instances. Thevacuum cost limit and delay is invoked at the segment level without taking intoaccount the state of the entire Greenplum array.
You can configure the execution cost of vacuum and analyze commandsto reduce the I/O impact on concurrent database activity. When the accumulatedcost of I/O operations reaches the limit, the process performing the operationsleeps for a while, Then resets the counter and continues execution
vacuum cost delay | vacuum cost page hit |
vacuum cost limit | vacuum cost page miss |
vacuum cost page dirty |
|
10.4.11.5 Transaction ID Management Parameters
• xid_stop_limit
• xid warn limit
10.4.12 Query Tuning Parameters
10.4.12.1 Pivotal Query Optimizer Configuration Parameters
• optimizer
• optimizer_analyze_root_partition
• optimizer_control
• optimizer_enable_master_only_queries
下面的参数控制类型的操作计划legacy query optimizer可以使用的。启用或禁用计划的操作,迫使传统的查询优化器选择不同的规划。这是用于测试,并使用不同的规划类型比较查询性能非常有用。The following parameters control the types of plan operations the legacyquery optimizer can use. Enable or disable plan operations to force the legacyquery optimizer to choose a different plan. This is useful for testing andcomparing query performance using different plan types.
enable_bitmapscan | gp_enable_agg_distinct_pruning |
enable_groupagg | gp_enable_direct_dispatch |
enable_hashagg | gp_enable_fallback_plan |
enable_hashjoin | gp_enable_fast_sri |
enable_indexscan | gp_enable_groupext_distinct_ gather |
enable_mergejoin | gp_enable_groupext_distinct_ pruning |
enable_nestloop | gp_enable_multiphase_agg |
enable_seqscan | gp_enable_predicate_ propagation |
enable_sort | gp_enable_preunique |
enable_tidscan | gp_enable_sequential_window_ plans |
gp_enable_adaptive_nestloop | gp_enable_sort_distinct |
gp_enable_agg_distinct | gp_enable_sort_limit |
10.4.12.3 Legacy Query Optimizer Costing Parameters
Warning: Pivotal recommends that you do not adjustthese query costing parameters. They are tuned to reflect Greenplum Databasehardware configurations and typical workloads. All of these parameters arerelated. Changing one without changing the others can have adverse effects onperformance.
cpu_index_tuple_cost | gp_motion_cost_per_row |
cpu_operator_cost | gp_segments_for_planner |
cpu_tuple_cost | random_page_cost |
cursor_tuple_fraction | seq_page_cost |
effective_cache_size |
|
这些参数调整由ANALYZE操作取样的数据量。调整这些参数会影响统计数据收集系统范围。您可以通过使用ALTER TABLE SET STATISTICS子句配置在特定的表和列统计信息收集。
• default_statistics_target
• gp_analyze_relative_error
• gp_enable_sort_distinct
• gp_enable_sort_limit
10.4.12.6 Aggregate Operator Configuration Parameters
gp_enable_agg_distinct | gp_enable_groupext_distinct_ gather |
gp_enable_agg_distinct_pruning | gp_enable_groupext_distinct_ pruning |
gp_enable_multiphase_agg | gp_workfile_compress_algorithm |
gp_enable_preunique |
|
10.4.12.7 Join Operator Configuration Parameters
join_collapse_limit | gp_statistics_use_fkeys |
gp_adjust_selectivity_for_outerjoins | gp_workfile_compress_algorithm |
gp_hashjoin_tuples_per_bucket |
|
10.4.12.8 Other Legacy Query Optimizer Configuration Parameters
• from_collapse_limit
• gp_enable_predicate_propagation
• gp_max_plan_size
• gp_statistics_pullup_from_child_partition
10.4.13 Error Reporting and LoggingParameters
log_rotation_age | log_truncate_on_rotation |
log_rotation_size |
|
10.4.13.2 When to Log | |
client_min_messages | log_min_error_statement |
log_error_verbosity | log_min_messages |
log_min_duration_statement log_min_duration_statement = 10000 #单位为ms,大于这个时间的语句会被记录 | optimizer_minidump |
debug_pretty_print | log_executor_stats |
debug_print_parse | log_hostname |
debug_print_plan | log_parser_stats |
debug_print_prelim_plan | log_planner_stats |
debug_print_rewritten | log_statement |
debug_print_slice_table | log_statement_stats |
log_autostats | log_timezone |
log_connections | gp_debug_linger |
log_disconnections | gp_log_format |
log_dispatch_stats | gp_max_csv_line_length |
log_duration(#每一个完成的语句的持续时间被记录,记录会很多,建议关闭) | gp_reraise_signal |
10.4.14 System Monitoring Parameters
The following parameters send SNMP notificationswhen events occur.
gp_snmp_community | gp_snmp_use_inform_or_trap |
gp_snmp_monitor_address |
|
The following parameters configure the system tosend email alerts for fatal error events, such as a segment going down or aserver crash and reset.
gp_email_from | gp_email_smtp_userid |
gp_email_smtp_password | gp_email_to |
gp_email_smtp_server |
|
10.4.14.3 GreenplumCommand Center Agent
The following parameters configure the datacollection
gp_enable_gpperfmon | gpperfmon_log_alert_level |
gp_gpperfmon_send_interval | gpperfmon_port |
10.4.15 Client Connection DefaultParameters
10.4.15.1 Statement Behavior Parameters
check_function_bodies | search_path |
default_tablespace | statement_timeout |
default_transaction_isolation | vacuum_freeze_min_age |
default_transaction_read_only |
|
10.4.15.2 Locale and Formatting Parameters
client_encoding | lc_messages |
DateStyle | lc_monetary |
extra_float_digits | lc_numeric |
IntervalStyle | lc_time |
lc_collate | TimeZone |
lc_ctype |
|
10.4.15.3 Other Client Default Parameters
dynamic_library_path | local_preload_libraries |
explain_pretty_print |
|
10.4.16 Greenplum Array ConfigurationParameters
The parameters in this topic control theconfiguration of the Greenplum Database array and its components: segments,master, distributed transaction manager, master mirror, and interconnect.
10.4.16.1 Interconnect Configuration Parameters
gp_interconnect_fc_method | gp_interconnect_setup_timeout |
gp_interconnect_hash_multiplier | gp_interconnect_type |
gp_interconnect_queue_depth | gp_max_packet_size |
gp_interconnect_snd_queue_depth |
|
Note: The Greenplum Database interconnect types TCPand UDP are deprecated. In the next major release, only the UDPIFC interconnecttype will be supported by Greenplum Database. The server configurationparameter gp_interconnect_type controls the interconnect type.
10.4.16.2 Dispatch Configuration Parameters
gp_cached_segworkers_threshold | gp_segment_connect_timeout |
gp_connections_per_thread | gp_set_proc_affinity |
gp_enable_direct_dispatch |
|
10.4.16.3 FaultOperation Parameters
gp_set_read_only | gp_fts_probe_threadcount |
gp_fts_probe_interval |
|
10.4.16.4 Distributed Transaction Management Parameters
• gp_max_local_distributed_cache
10.4.16.5 Read-Only Parameters
• gp_command_count
• gp_content
• gp_dbid
• gp_num_contents_in_cluster
• gp_role
• gp_session_id
若需要使参数生效,使用:
SELECT pg_reload_conf();