3

每天晚上,我们使用以下命令转储和恢复 200 GB 的数据库:

# Production, PG 9:
pg_dump DATNAME | some-irrelevant-pipe

# QA, PG 8.3:
some-irrelevant-pipe | psql -d DATNAME

为了从 9 到 8.3 恢复转储,我不得不进行基于文本的备份。

恢复过程非常缓慢且不合理。我注意到我的日志充满了这些:

2011-05-22 08:02:47 CDT LOG:  checkpoints are occurring too frequently (9 seconds apart)
2011-05-22 08:02:47 CDT HINT:  Consider increasing the configuration parameter "checkpoint_segments".
2011-05-22 08:02:54 CDT LOG:  checkpoints are occurring too frequently (7 seconds apart)
2011-05-22 08:02:54 CDT HINT:  Consider increasing the configuration parameter "checkpoint_segments".

我的问题是:设置是否可能checkpoint_segments是瓶颈?我可以调整哪些其他参数来加快流程?

那台机器有 4 GB RAM。postgresql.conf 中其他可能相关的设置是:

shared_buffers = 1000MB
work_mem = 200MB
maintenance_work_mem = 200MB
effective_cache_size = 2000MB
# fsync and checkpoint settings are default
4

2 回答 2

4

你读过这个吗?特别参见第14.4.9 节

于 2011-05-26T16:34:15.270 回答
3

为了恢复数据库,更改:

# I don't think PostgreSQL 8.3 supports synchronous_commit
synchronous_commit = off
# only change fsync = off if your version of PG is too old to support synchronous_commit. If you do support synchronous_commit, don't ever change fsync to anything but on. Ever.
#fsync = off
checkpoint_segments = 25

关于checkpoint_segments,将该值设置为磁盘控制器写入缓冲区的大小。25 = 400MB

此外,请确保您psql在单个事务中加载所有内容:

some-irrelevant-pipe | psql -1 -d DATNAME
于 2011-05-26T18:26:48.607 回答