我正在尝试在 postgres 8.4 机器上运行 vacuum 完整分析,其中 autovacuum 似乎无法跟上。数据库很大,负载很重。
问题始于 postgres 拒绝更新,因为它没有事务。我唯一的选择是让我们的业务脱机并进行手动吸尘。
问题是它需要很长时间,我一直在寻找一种可靠的方法来加速它。我不想在数据库处于未知状态时任意更改配置文件。
这是服务器的 postgres.conf 配置。
listen_addresses = '*'
port = 5476
max_connections = 1000
### logging
log_destination = 'syslog'
constraint_exclusion = partition
### work_mem for vacuuming
maintenance_work_mem = 128MB # min 1MB
# DEFAULT 16MB
# -----------------------------
# CHANGE THESE DEPENDING ON SYSTEM
# VALUES BASED ON 2G RAM
# -----------------------------
### RAM * 1/4
shared_buffers = 512MB # min 128kB or max_connections*16kB
# DEFAULT: 24MB
#### very import. all work happens here, needs to be as big as possible
temp_buffers = 64MB
#### session-local buffers used to access temporary tables on a per-session basis
### not more than RAM / connections
work_mem = 20MB # min 64kB
# DEFAULT: 1MB
#### used for sorting in memory
### raise this if log complains or to reduce checkpoints
wal_buffers = 3MB # min 32kB
# DEFAULT: 64kB
checkpoint_segments = 16 # in logfile segments, min 1, 16MB each
# DEFAULT: 3
#### stores changes to shared buffer. higher value = fewer checkpoints/flushes
### RAM * 2/3
effective_cache_size = 1365MB
# DEFAULT: 128MB
#### size of largest possible object
### multiplied defaults by 0.2
cpu_tuple_cost = 0.002 # (same)
cpu_index_tuple_cost = 0.001 # (same)
cpu_operator_cost = 0.0005 # (same)
#### do this. based on older slower hardware.
### milliseconds vacuum will delay when its cost reaches threshold
vacuum_cost_delay = 20 # default = 0
# -----------------------------
# OPTIONAL DEBUG/LOGGING PARAMS
# -----------------------------
### uncomment the following 6 lines to enable query logging
#silent_mode = on
#log_min_duration_statement = 0
#log_duration = on
#log_statement = 'none'
任何有关我可以做些什么来尽快备份此服务器的想法都将不胜感激。
编辑
这是我们收到的确切错误消息,对此深表歉意。
ERROR: database is not accepting commands to avoid wraparound data loss in database "live"
这个特殊的错误伴随着文档中提到的提示,在Routine vacuuming (8.4)中:
这是一个危急情况,如果 autovacuum 可以完成它的工作,通常不应该发生。当您重新联机时,您应该尝试找出发生这种情况的原因(错误的真空设置?)。
同时,必须做的只是 HINT 告诉的内容:
VACUUM
没有附加参数。正如评论中提到的,VACUUM FULL
是一个不同的命令,尽管它的名字并不明显。它完全重写了表格,速度慢得多,在这种情况下是不可取的。更多详细信息,请访问https://wiki.postgresql.org/wiki/VACUUM_FULL