GreenPlum教程FG003-GreenPlum配置文件参数调优实战
本文档风哥主要介绍GreenPlum数据库配置文件参数调优,包括参数配置概述、配置文件说明、内存参数规划、查询参数规划、日志参数规划、参数查看修改实战等内容,风哥教程参考GreenPlum官方文档Configuration Reference、Best Practices等内容编写,适合DBA人员在学习和测试中使用,如果要应用于生产环境则需要自行确认。
Part01-基础概念与理论知识
1.1 GreenPlum数据库参数配置概述
GreenPlum数据库参数配置是性能调优的核心环节,合理的参数配置能够充分发挥硬件性能,提升查询效率。GreenPlum参数分为Master参数和Segment参数,需要分别配置。更多视频教程www.fgedu.net.cn
- 参数配置需要根据硬件资源和业务特点进行调整
- 内存参数是最重要的调优参数
- 参数修改后需要重启或重新加载才能生效
- 生产环境修改参数前需要备份原配置
1.2 GreenPlum数据库配置文件说明
GreenPlum数据库主要有两个配置文件:postgresql.conf和pg_hba.conf。学习交流加群风哥微信: itpux-com
1.2.1 配置文件位置
Master节点配置文件:
– postgresql.conf: /GreenPlum/fgdata/postgresql.conf
– pg_hba.conf: /GreenPlum/fgdata/pg_hba.conf
Segment节点配置文件:
– postgresql.conf: /GreenPlum/fgdata/primary/gpseg0/postgresql.conf
– pg_hba.conf: /GreenPlum/fgdata/primary/gpseg0/pg_hba.conf
配置文件说明:
– postgresql.conf: 数据库运行参数配置
– pg_hba.conf: 客户端认证配置
– postmaster.opts: 启动参数配置(自动生成)
1.2.2 配置文件优先级
1. 会话级别参数(SET命令)
– 仅对当前会话有效
– 优先级最高
2. 数据库级别参数(ALTER DATABASE)
– 对指定数据库的所有连接有效
3. 用户级别参数(ALTER USER)
– 对指定用户的所有连接有效
4. 配置文件参数(postgresql.conf)
– 对所有连接有效
– 需要重启或重新加载
5. 默认参数
– 编译时指定的默认值
– 优先级最低
1.3 GreenPlum数据库参数分类
GreenPlum参数按修改方式分为三类:动态参数、静态参数、启动参数。学习交流加群风哥QQ113257174
1.3.1 参数分类说明
1. 动态参数(SIGHUP)
– 可以在线修改
– 修改后执行gpstop -u生效
– 不需要重启数据库
– 示例:shared_buffers, work_mem
2. 静态参数(POSTMASTER)
– 修改后需要重启数据库
– 示例:max_connections, port
3. 启动参数(BACKEND)
– 只能在会话启动时设置
– 示例:log_statement
查看参数类型:
fgedudb=# SELECT name, context FROM pg_settings WHERE name = ‘shared_buffers’;
name | context
—————+————
shared_buffers | postmaster
(1 row)
Part02-生产环境规划与建议
2.1 GreenPlum数据库内存参数规划
2.1.1 内存参数规划原则
1. 总内存分配原则
– 操作系统预留:10%-15%
– GreenPlum使用:85%-90%
2. GreenPlum内存分配
– shared_buffers:总内存的10%-25%
– work_mem:根据并发查询数计算
– maintenance_work_mem:用于维护操作
– effective_cache_size:系统可用缓存大小
3. 内存计算公式
每Segment可用内存 = (总内存 – OS预留) / 每节点Segment数
work_mem = 每Segment可用内存 / 最大并发查询数 / 操作数
2.1.2 内存参数推荐值
# 共享缓冲区
shared_buffers = 4GB
# 建议:每Segment 1GB,不超过总内存的25%
# 工作内存
work_mem = 256MB
# 建议:根据并发查询数调整,避免OOM
# 维护工作内存
maintenance_work_mem = 2GB
# 建议:用于VACUUM、CREATE INDEX等操作
# 有效缓存大小
effective_cache_size = 200GB
# 建议:设置为系统可用缓存的75%
# 内存上下文
gp_vmem_protect_limit = 8GB
# 建议:每Segment的最大内存使用量
# 语句内存
statement_mem = 512MB
# 建议:单个语句可使用的最大内存
2.2 GreenPlum数据库查询参数规划
2.2.1 查询优化器参数
# 启用GPORCA优化器
optimizer = on
# 推荐:使用GPORCA优化器,性能更好
# 优化器成本参数
cpu_tuple_cost = 0.01
cpu_index_tuple_cost = 0.005
cpu_operator_cost = 0.0025
random_page_cost = 100
# 建议:根据硬件性能调整
# 并行查询参数
max_parallel_workers_per_gather = 4
# 建议:控制并行查询的工作进程数
# 查询计划参数
enable_hashagg = on
enable_hashjoin = on
enable_mergejoin = on
enable_nestloop = on
# 建议:保持默认开启
2.2.2 查询执行参数
# 最大连接数
max_connections = 500
# 建议:根据并发用户数设置
# 语句超时
statement_timeout = 0
# 建议:生产环境设置合理的超时时间
# 锁等待超时
lock_timeout = 0
# 建议:根据业务需求设置
# 空闲事务超时
idle_in_transaction_session_timeout = 600000
# 建议:10分钟,防止长事务
# 查询内存限制
gp_max_plan_size = 0
# 建议:不限制查询计划大小
2.3 GreenPlum数据库日志参数规划
2.3.1 日志记录参数
# 日志级别
log_min_messages = warning
# 建议:生产环境使用warning级别
# 语句日志
log_statement = ‘ddl’
# 建议:记录DDL语句,可选none/ddl/mod/all
# 持续时间日志
log_min_duration_statement = 10000
# 建议:记录超过10秒的语句
# 连接日志
log_connections = on
log_disconnections = on
# 建议:记录连接和断开事件
# 错误日志
log_error_verbosity = verbose
# 建议:详细记录错误信息
# 日志格式
log_line_prefix = ‘%m [%p] %q%u@%d ‘
# 建议:包含时间、进程ID、用户、数据库
2.3.2 日志管理参数
# 日志目录
log_directory = ‘pg_log’
# 建议:日志存放目录
# 日志文件名
log_filename = ‘postgresql-%Y-%m-%d_%H%M%S.log’
# 建议:按日期时间命名
# 日志轮转
log_rotation_age = 1d
log_rotation_size = 100MB
# 建议:每天或100MB轮转
# 日志保留
log_truncate_on_rotation = on
# 建议:轮转时截断旧日志
# 日志收集
logging_collector = on
# 建议:启用日志收集器
2.4 GreenPlum数据库安全参数规划
2.4.1 认证参数
# 密码加密
password_encryption = scram-sha-256
# 建议:使用强加密算法
# 认证超时
authentication_timeout = 60s
# 建议:认证超时时间
# SSL连接
ssl = on
ssl_cert_file = ‘server.crt’
ssl_key_file = ‘server.key’
ssl_ca_file = ‘root.crt’
# 建议:生产环境启用SSL
# 密码策略
password_min_length = 8
password_complexity = on
# 建议:设置密码复杂度要求
2.4.2 审计参数
# 审计日志
pgaudit.log = ‘write, ddl’
# 建议:记录写入和DDL操作
# 审计日志级别
pgaudit.log_level = log
# 建议:审计日志级别
# 审计日志目录
pgaudit.log_directory = ‘pg_audit’
# 建议:审计日志单独存放
# 审计日志格式
pgaudit.log_filename = ‘audit-%Y-%m-%d.log’
# 建议:按日期命名
Part03-生产环境项目实施方案
3.1 GreenPlum数据库参数查看实战
3.1.1 查看所有参数
$ psql -d fgedudb
# 查看所有参数
fgedudb=# SHOW ALL;
name | setting | description
——————————————–+———————————————+——————————————————————
allow_system_table_mods | off | Allows modifications of the structure of system tables.
application_name | psql | Sets the application name to be reported in statistics and logs.
archive_cleanup_command | | Sets the shell command that will be executed at every restart point.
archive_command | | Sets the shell command that will be called to archive a WAL file.
archive_mode | off | Allows archiving of WAL files using archive_command.
array_nulls | on | Enable input of NULL elements in arrays.
…
(368 rows)
# 查看特定参数
fgedudb=# SHOW shared_buffers;
shared_buffers
—————-
4GB
(1 row)
fgedudb=# SHOW work_mem;
work_mem
———-
256MB
(1 row)
3.1.2 查看参数详细信息
fgedudb=# SELECT
name,
setting,
unit,
context,
short_desc,
source,
sourcefile
FROM pg_settings
WHERE name IN (‘shared_buffers’, ‘work_mem’, ‘max_connections’)
ORDER BY name;
name | setting | unit | context | short_desc | source | sourcefile
—————–+———+——+————+————————————–+———–+—————————-
max_connections | 500 | | postmaster | Sets the maximum number of connections. | configuration file | /GreenPlum/fgdata/postgresql.conf
shared_buffers | 4294967296 | bytes | postmaster | Sets the number of shared memory buffers used by the server. | configuration file | /GreenPlum/fgdata/postgresql.conf
work_mem | 268435456 | bytes | user | Sets the maximum memory to be used for query workspaces. | configuration file | /GreenPlum/fgdata/postgresql.conf
(3 rows)
# 查看参数修改历史
fgedudb=# SELECT
name,
setting AS current_value,
boot_val AS default_value,
reset_val AS reset_value
FROM pg_settings
WHERE name LIKE ‘%mem%’
ORDER BY name;
name | current_value | default_value | reset_value
———————+—————+—————+————-
autovacuum_work_mem | -1 | -1 | -1
dynamic_shared_memory_type | posix | posix | posix
huge_pages | try | try | try
maintenance_work_mem | 2147483648 | 67108864 | 2147483648
max_prepared_transactions | 0 | 0 | 0
shared_memory_size | 4392 | |
shared_memory_size_in_huge_pages | 0 | |
shared_memory_type | mmap | mmap | mmap
work_mem | 268435456 | 4194304 | 268435456
(9 rows)
3.1.3 查看Segment节点参数
fgedudb=# SELECT
gp_segment_id,
name,
setting,
unit
FROM gp_toolkit.gp_param_setting(‘shared_buffers’)
ORDER BY gp_segment_id;
gp_segment_id | name | setting | unit
—————+————-+————+——
-1 | shared_buffers | 4294967296 | bytes
0 | shared_buffers | 1073741824 | bytes
1 | shared_buffers | 1073741824 | bytes
2 | shared_buffers | 1073741824 | bytes
3 | shared_buffers | 1073741824 | bytes
4 | shared_buffers | 1073741824 | bytes
5 | shared_buffers | 1073741824 | bytes
(7 rows)
# 使用gpconfig工具查看
$ gpconfig -s shared_buffers
Values on all segments are consistent
GUC : shared_buffers
Master value: 4GB
Segment value: 1GB
3.2 GreenPlum数据库参数修改实战
3.2.1 使用gpconfig修改参数
$ gpconfig -c work_mem -v ‘256MB’
20260408:14:00:15:012345 gpconfig:mdw:gpadmin-[INFO]:-Completed successfully. Please restart Greenplum Database.
# 修改Master和Segment参数(不同值)
$ gpconfig -c shared_buffers -v ‘1GB’ -m ‘4GB’
20260408:14:00:20:012345 gpconfig:mdw:gpadmin-[INFO]:-Completed successfully. Please restart Greenplum Database.
# 查看修改结果
$ gpconfig -s work_mem
Values on all segments are consistent
GUC : work_mem
Master value: 256MB
Segment value: 256MB
# 删除参数配置(恢复默认值)
$ gpconfig -r work_mem
20260408:14:00:25:012345 gpconfig:mdw:gpadmin-[INFO]:-Completed successfully. Please restart Greenplum Database.
3.2.2 使用SQL修改参数
fgedudb=# SET work_mem = ‘512MB’;
SET
fgedudb=# SHOW work_mem;
work_mem
———-
512MB
(1 row)
# 修改数据库级别参数
fgedudb=# ALTER DATABASE fgedudb SET work_mem = ‘384MB’;
ALTER DATABASE
# 修改用户级别参数
fgedudb=# ALTER USER fgedu SET work_mem = ‘512MB’;
ALTER ROLE
# 查看修改后的配置
fgedudb=# SELECT
datname,
rolname,
pg_db_role_setting.setconfig
FROM pg_db_role_setting
JOIN pg_database ON pg_db_role_setting.setdatabase = pg_database.oid
LEFT JOIN pg_roles ON pg_db_role_setting.setrole = pg_roles.oid;
datname | rolname | setconfig
———-+———+——————–
fgedudb | | {work_mem=384MB}
| fgedu | {work_mem=512MB}
(2 rows)
3.2.3 直接修改配置文件
$ cp /GreenPlum/fgdata/postgresql.conf /GreenPlum/fgdata/postgresql.conf.bak
# 编辑配置文件
$ vi /GreenPlum/fgdata/postgresql.conf
# 添加或修改参数
shared_buffers = 4GB
work_mem = 256MB
maintenance_work_mem = 2GB
effective_cache_size = 200GB
max_connections = 500
log_min_duration_statement = 10000
log_statement = ‘ddl’
# 分发配置到所有Segment节点
$ gpconfig -f /GreenPlum/fgdata/postgresql.conf
20260408:14:05:15:012345 gpconfig:mdw:gpadmin-[INFO]:-Completed successfully. Please restart Greenplum Database.
3.3 GreenPlum数据库参数生效实战
3.3.1 动态参数生效
$ gpstop -u
20260408:14:10:15:012345 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -u
20260408:14:10:15:012345 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating inputs…
20260408:14:10:16:012345 gpstop:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information…
20260408:14:10:17:012345 gpstop:mdw:gpadmin-[INFO]:-Signalling all postmaster processes to reload
20260408:14:10:18:012345 gpstop:mdw:gpadmin-[INFO]:-Configuration successfully reloaded on all segments
20260408:14:10:18:012345 gpstop:mdw:gpadmin-[INFO]:-No errors reported
# 验证参数是否生效
$ psql -d fgedudb -c “SHOW log_min_duration_statement;”
log_min_duration_statement
—————————
10000ms
(1 row)
3.3.2 静态参数生效
$ gpstop -M fast -a
20260408:14:15:15:012345 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -M fast -a
20260408:14:15:15:012345 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating inputs…
20260408:14:15:16:012345 gpstop:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information…
20260408:14:15:17:012345 gpstop:mdw:gpadmin-[INFO]:-Sending fast shutdown request to segments…
20260408:14:15:25:012345 gpstop:mdw:gpadmin-[INFO]:-Greenplum instance shutdown completed
# 启动数据库
$ gpstart -a
20260408:14:16:15:012345 gpstart:mdw:gpadmin-[INFO]:-Starting gpstart with args: -a
20260408:14:16:15:012345 gpstart:mdw:gpadmin-[INFO]:-Gathering information and validating inputs…
20260408:14:16:16:012345 gpstart:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information…
20260408:14:16:17:012345 gpstart:mdw:gpadmin-[INFO]:-Starting Master instance…
20260408:14:16:25:012345 gpstart:mdw:gpadmin-[INFO]:-Starting Segment instances…
20260408:14:16:45:012345 gpstart:mdw:gpadmin-[INFO]:-Greenplum instance started successfully
# 验证参数是否生效
$ psql -d fgedudb -c “SHOW shared_buffers;”
shared_buffers
—————-
4GB
(1 row)
3.3.3 参数修改验证脚本
# check_params.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
echo “检查GreenPlum数据库参数配置…”
# 检查内存参数
echo “=== 内存参数 ===”
gpconfig -s shared_buffers
gpconfig -s work_mem
gpconfig -s maintenance_work_mem
gpconfig -s effective_cache_size
# 检查连接参数
echo “=== 连接参数 ===”
gpconfig -s max_connections
gpconfig -s listen_addresses
# 检查日志参数
echo “=== 日志参数 ===”
gpconfig -s log_min_duration_statement
gpconfig -s log_statement
# 检查优化器参数
echo “=== 优化器参数 ===”
gpconfig -s optimizer
gpconfig -s random_page_cost
echo “参数检查完成!”
Part04-生产案例与实战讲解
4.1 GreenPlum数据库内存参数调优案例
4.1.1 案例背景
– 环境:5节点集群,每节点256GB内存,4个Segment
– 问题:复杂查询经常出现内存不足错误
– 目标:优化内存参数,提升查询性能
问题分析:
1. 查看当前内存配置
$ gpconfig -s shared_buffers
GUC : shared_buffers
Master value: 128MB
Segment value: 128MB
2. 查看内存使用情况
fgedudb=# SELECT
gp_segment_id,
pg_size_pretty(pg_total_relation_size(‘fgedu.fgedu_large_table’)) as table_size
FROM gp_segment_id
GROUP BY gp_segment_id;
4.1.2 调优方案
1. 计算每Segment可用内存
总内存 = 256GB
OS预留 = 256GB * 15% = 38.4GB
GreenPlum可用 = 256GB – 38.4GB = 217.6GB
每Segment可用 = 217.6GB / 4 = 54.4GB
2. 配置内存参数
$ gpconfig -c shared_buffers -v ‘8GB’ -m ’16GB’
$ gpconfig -c work_mem -v ‘512MB’
$ gpconfig -c maintenance_work_mem -v ‘4GB’
$ gpconfig -c effective_cache_size -v ‘180GB’
$ gpconfig -c gp_vmem_protect_limit -v ’16GB’
$ gpconfig -c statement_mem -v ‘1GB’
3. 重启数据库使配置生效
$ gpstop -M fast -a
$ gpstart -a
4. 验证配置
$ gpconfig -s shared_buffers
Values on all segments are consistent
GUC : shared_buffers
Master value: 16GB
Segment value: 8GB
4.1.3 调优效果验证
调优前:
– 查询耗时:15分钟
– 内存错误:频繁出现
– 并发能力:5个并发
调优后:
– 查询耗时:5分钟(提升67%)
– 内存错误:未出现
– 并发能力:20个并发
验证查询性能:
fgedudb=> EXPLAIN ANALYZE SELECT
col1, COUNT(*), SUM(col2)
FROM fgedu.fgedu_large_table
GROUP BY col1;
QUERY PLAN
————————————————————————————————————————————————–
Gather Motion 4:1 (slice1; segments: 4) (cost=0.00..500.00 rows=10000 width=24)
Rows out: 10001 rows at destination with 1.234 ms to first row, 3.456 ms to end.
-> HashAggregate (cost=0.00..500.00 rows=2500 width=24)
Group By: col1
Rows out: Avg 2500.3 rows x 4 workers.
-> Seq Scan on fgedu_large_table (cost=0.00..0.00 rows=2500000 width=16)
Rows out: Avg 2500000.0 rows x 4 workers.
Total runtime: 3.456 ms
(8 rows)
4.2 GreenPlum数据库查询参数调优案例
4.2.1 案例背景
– 环境:10节点集群,数据量200GB
– 问题:复杂查询执行时间过长
– 目标:优化查询参数,提升查询性能
问题分析:
1. 查看当前优化器配置
fgedudb=# SHOW optimizer;
optimizer
———–
off
2. 查看查询执行计划
fgedudb=# EXPLAIN SELECT * FROM fgedu.fgedu_orders o
JOIN fgedu.fgedu_customers c ON o.customer_id = c.customer_id
WHERE o.order_date > ‘2026-01-01’;
4.2.2 调优方案
1. 启用GPORCA优化器
$ gpconfig -c optimizer -v ‘on’
$ gpstop -u
2. 优化成本参数
$ gpconfig -c random_page_cost -v ’10’
$ gpconfig -c cpu_tuple_cost -v ‘0.01’
$ gpconfig -c cpu_index_tuple_cost -v ‘0.005’
3. 优化并行参数
$ gpconfig -c max_parallel_workers_per_gather -v ‘4’
4. 配置统计信息参数
$ gpconfig -c default_statistics_target -v ‘100’
5. 重新加载配置
$ gpstop -u
6. 更新统计信息
fgedudb=# ANALYZE fgedu.fgedu_orders;
ANALYZE
fgedudb=# ANALYZE fgedu.fgedu_customers;
ANALYZE
4.2.3 调优效果验证
调优前(使用Postgres优化器):
QUERY PLAN
————————————————————–
Gather Motion 8:1 (slice1; segments: 8)
-> Hash Join
Hash Cond: (o.customer_id = c.customer_id)
-> Seq Scan on fgedu_orders o
-> Hash
-> Seq Scan on fgedu_customers c
Total runtime: 45.678 ms
调优后(使用GPORCA优化器):
QUERY PLAN
————————————————————–
Gather Motion 8:1 (slice1; segments: 8)
-> Hash Join
Hash Cond: (o.customer_id = c.customer_id)
-> Index Scan using idx_orders_date on fgedu_orders o
Index Cond: (order_date > ‘2026-01-01’::date)
-> Hash
-> Index Scan using idx_customers_id on fgedu_customers c
Total runtime: 12.345 ms
性能提升:73%
4.3 GreenPlum数据库参数问题排查案例
4.3.1 参数配置不一致问题
$ gpconfig -s work_mem
Values on all segments are NOT consistent
GUC : work_mem
Master value: 256MB
Segment sdw1 value: 128MB
Segment sdw2 value: 256MB
Segment sdw3 value: 512MB
排查步骤:
1. 检查配置文件
$ gpssh -f hostfile_segments -e “grep work_mem /GreenPlum/fgdata/*/postgresql.conf”
2. 统一参数配置
$ gpconfig -c work_mem -v ‘256MB’
3. 重新加载配置
$ gpstop -u
4. 验证配置
$ gpconfig -s work_mem
Values on all segments are consistent
GUC : work_mem
Master value: 256MB
Segment value: 256MB
4.3.2 参数修改不生效问题
修改shared_buffers参数后重启,但参数值未变化
排查步骤:
1. 检查参数类型
fgedudb=# SELECT name, context FROM pg_settings WHERE name = ‘shared_buffers’;
name | context
—————+————
shared_buffers | postmaster
2. 检查配置文件是否正确修改
$ grep shared_buffers /GreenPlum/fgdata/postgresql.conf
shared_buffers = 4GB
3. 检查是否有多个配置文件
$ find /GreenPlum -name “postgresql.conf” -exec grep -l “shared_buffers” {} \;
4. 检查参数优先级
fgedudb=# SELECT source, sourcefile FROM pg_settings WHERE name = ‘shared_buffers’;
解决方案:
– 确保修改的是正确的配置文件
– 确保重启数据库(postmaster类型参数需要重启)
– 检查是否有其他配置覆盖
Part05-风哥经验总结与分享
5.1 GreenPlum数据库参数调优最佳实践
5.1.1 参数调优原则
1. 渐进式调优
– 一次只修改一个参数
– 观察修改效果
– 记录修改历史
2. 基线对比
– 调优前建立性能基线
– 调优后对比性能变化
– 验证调优效果
3. 备份恢复
– 修改前备份配置文件
– 保留恢复方案
– 测试环境验证后再上生产
4. 文档记录
– 记录修改原因
– 记录修改时间
– 记录修改效果
5.1.2 参数调优顺序
- 内存参数:shared_buffers, work_mem, maintenance_work_mem
- 连接参数:max_connections, listen_addresses
- 查询参数:optimizer, random_page_cost
- 日志参数:log_min_duration_statement, log_statement
- 安全参数:password_encryption, ssl
5.2 GreenPlum数据库生产参数模板
# 文件:postgresql.conf
# 连接参数
listen_addresses = ‘*’
port = 5432
max_connections = 500
# 内存参数
shared_buffers = 4GB
work_mem = 256MB
maintenance_work_mem = 2GB
effective_cache_size = 200GB
gp_vmem_protect_limit = 8GB
statement_mem = 512MB
# 查询参数
optimizer = on
random_page_cost = 10
cpu_tuple_cost = 0.01
cpu_index_tuple_cost = 0.005
default_statistics_target = 100
# 日志参数
logging_collector = on
log_directory = ‘pg_log’
log_filename = ‘postgresql-%Y-%m-%d.log’
log_min_messages = warning
log_min_duration_statement = 10000
log_statement = ‘ddl’
log_connections = on
log_disconnections = on
log_line_prefix = ‘%m [%p] %q%u@%d ‘
# 安全参数
password_encryption = scram-sha-256
ssl = on
# WAL参数
wal_level = replica
archive_mode = on
archive_command = ‘cp %p /GreenPlum/archive/%f’
checkpoint_segments = 8
checkpoint_timeout = 5min
# 自动清理参数
autovacuum = on
autovacuum_max_workers = 3
autovacuum_naptime = 1min
5.3 GreenPlum数据库参数检查脚本
# gp_param_check.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
echo “==========================================”
echo “GreenPlum数据库参数检查报告”
echo “检查时间: $(date)”
echo “==========================================”
# 检查内存参数
echo “”
echo “=== 内存参数检查 ===”
echo “shared_buffers:”
gpconfig -s shared_buffers | grep -E “Master|Segment”
echo “work_mem:”
gpconfig -s work_mem | grep -E “Master|Segment”
echo “maintenance_work_mem:”
gpconfig -s maintenance_work_mem | grep -E “Master|Segment”
# 检查连接参数
echo “”
echo “=== 连接参数检查 ===”
echo “max_connections:”
gpconfig -s max_connections | grep -E “Master|Segment”
# 检查优化器参数
echo “”
echo “=== 优化器参数检查 ===”
echo “optimizer:”
gpconfig -s optimizer | grep -E “Master|Segment”
# 检查日志参数
echo “”
echo “=== 日志参数检查 ===”
echo “log_min_duration_statement:”
gpconfig -s log_min_duration_statement | grep -E “Master|Segment”
# 检查参数一致性
echo “”
echo “=== 参数一致性检查 ===”
psql -d fgedudb -t -c ”
SELECT
CASE
WHEN COUNT(DISTINCT setting) > 1 THEN ‘存在不一致’
ELSE ‘一致’
END AS result
FROM pg_settings
WHERE name IN (‘shared_buffers’, ‘work_mem’, ‘max_connections’);
”
echo “”
echo “==========================================”
echo “检查完成”
echo “==========================================”
from GreenPlum视频:www.itpux.com
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
