database runtime_error ai_generated true

错误:归档命令失败,退出代码 1:cp pg_wal/000000010000000000000001 /archive/000000010000000000000001

ERROR: archive command failed with exit code 1: cp pg_wal/000000010000000000000001 /archive/000000010000000000000001

ID: database/postgresql-wal-archiver-failed

其他格式: JSON · Markdown 中文 · English
82%修复率
88%置信度
1证据数
2023-09-05首次发现

版本兼容性

版本状态引入弃用备注
PostgreSQL 14.x active
PostgreSQL 15.x active
PostgreSQL 16.x active

根因分析

PostgreSQL 归档进程无法将 WAL 段复制到归档目标,通常由于磁盘满、权限问题或缺少目录。

English

The PostgreSQL archiver process fails to copy WAL segments to the archive destination, typically due to disk full, permission issues, or missing directory.

generic

官方文档

https://www.postgresql.org/docs/16/continuous-archiving.html

解决方案

  1. 检查磁盘空间和权限:df -h /archive; ls -ld /archive;然后确保归档目录存在:mkdir -p /archive && chown postgres:postgres /archive
  2. 手动测试归档命令:su - postgres -c 'cp /var/lib/postgresql/16/main/pg_wal/000000010000000000000001 /archive/000000010000000000000001' 并修复错误(例如 SELinux 上下文)。

无效尝试

常见但无效的做法:

  1. Restarting PostgreSQL without fixing the archive destination 95% 失败

    Restarting does not resolve the underlying issue; the archiver will continue to fail on the next WAL segment.

  2. Setting archive_mode to off to stop archiving 90% 失败

    Disabling archiving can lead to WAL accumulation and potential data loss in case of a disaster recovery scenario.