Postgres WAL 文件没有被删除
Postgres WAL file not getting deleted
我有以下存档命令
archive_command = 'rsync -av %p /home/archive/%f'
我们从那里清理文件。
但问题是文件复制到存档文件夹后,并没有从/var/lib/pgsql/9.6/data/pg_xlog
中删除。
我在 Postgres 日志中没有看到任何错误。
这是一主一备配置的Postgres 9.6。
此外,了解这些旧 WAL 文件在处理后删除的过程会很有帮助。
WAL 文件未从 pg_xlog
中删除的原因有多种:
max_wal_size
设置高于 pg_xlog
.
中的 WAL 数量
wal_keep_segments
设置的比pg_xlog
.
中的WAL文件数量多
在比 WAL 文件更早的 WAL 位置有一个复制槽。
要了解复制槽,请尝试以下查询:
SELECT slot_name,
lpad((pg_control_checkpoint()).timeline_id::text, 8, '0') ||
lpad(split_part(restart_lsn::text, '/', 1), 8, '0') ||
lpad(substr(split_part(restart_lsn::text, '/', 2), 1, 2), 8, '0')
AS wal_file
FROM pg_replication_slots;
这将为您提供每个复制槽仍需要的最旧的 WAL 文件的名称。
我遇到了同样的问题。我删除了最旧的复制槽并清理了 postgres pg_xlog。
postgres=# SELECT slot_name,
lpad((pg_control_checkpoint()).timeline_id::text, 8, '0') ||
lpad(split_part(restart_lsn::text, '/', 1), 8, '0') ||
lpad(substr(split_part(restart_lsn::text, '/', 2), 1, 2), 8, '0')
AS wal_file
FROM pg_replication_slots;
slot_name | wal_file
-----------+--------------------------
postgres2 | 0000000100000000000000B0
(1 row)
postgres=# select pg_drop_replication_slot('postgres2');
pg_drop_replication_slot
--------------------------
(1 row)
我有以下存档命令
archive_command = 'rsync -av %p /home/archive/%f'
我们从那里清理文件。
但问题是文件复制到存档文件夹后,并没有从/var/lib/pgsql/9.6/data/pg_xlog
中删除。
我在 Postgres 日志中没有看到任何错误。 这是一主一备配置的Postgres 9.6。
此外,了解这些旧 WAL 文件在处理后删除的过程会很有帮助。
WAL 文件未从 pg_xlog
中删除的原因有多种:
max_wal_size
设置高于pg_xlog
. 中的 WAL 数量
wal_keep_segments
设置的比pg_xlog
. 中的WAL文件数量多
在比 WAL 文件更早的 WAL 位置有一个复制槽。
要了解复制槽,请尝试以下查询:
SELECT slot_name,
lpad((pg_control_checkpoint()).timeline_id::text, 8, '0') ||
lpad(split_part(restart_lsn::text, '/', 1), 8, '0') ||
lpad(substr(split_part(restart_lsn::text, '/', 2), 1, 2), 8, '0')
AS wal_file
FROM pg_replication_slots;
这将为您提供每个复制槽仍需要的最旧的 WAL 文件的名称。
我遇到了同样的问题。我删除了最旧的复制槽并清理了 postgres pg_xlog。
postgres=# SELECT slot_name,
lpad((pg_control_checkpoint()).timeline_id::text, 8, '0') ||
lpad(split_part(restart_lsn::text, '/', 1), 8, '0') ||
lpad(substr(split_part(restart_lsn::text, '/', 2), 1, 2), 8, '0')
AS wal_file
FROM pg_replication_slots;
slot_name | wal_file
-----------+--------------------------
postgres2 | 0000000100000000000000B0
(1 row)
postgres=# select pg_drop_replication_slot('postgres2');
pg_drop_replication_slot
--------------------------
(1 row)