[英]WAL Archive hangs in postgres when gzip is used
I have enabled the WAL Archiving with following archive command: 我已使用以下归档命令启用了WAL归档:
wal_keep_segments = 32
archive_mode = on
archive_command = 'gzip < %p > /mnt/nfs/archive/%f'
and on Slave I have restore command as: 在从站上,我的还原命令为:
restore_command = 'gunzip < /mnt/nfs/archive/%f > %p'
archive_cleanup_command = '/opt/PostgreSQL/9.4/bin/pg_archivecleanup -d /mnt/nfs/archive %r'
on Master I could see that many files are stuck. 在Master上,我看到很多文件被卡住了。 around 327 files are yet to be archived.
大约有327个文件尚未归档。 Ideally it should be only 32 only.
理想情况下,它应该仅为32。
the px command shows: px命令显示:
-bash-4.1$ ps x
PID TTY STAT TIME COMMAND
3302 ? S 0:00 /opt/PostgreSQL/9.4/bin/postgres -D /opt/PostgreSQL/9.4/data
3304 ? Ss 0:00 postgres: logger process
3306 ? Ss 0:09 postgres: checkpointer process
3307 ? Ss 0:00 postgres: writer process
3308 ? Ss 0:06 postgres: wal writer process
3309 ? Ss 0:00 postgres: autovacuum launcher process
3311 ? Ss 0:00 postgres: stats collector process
3582 ? S 0:00 sshd: postgres@pts/1
3583 pts/1 Ss 0:00 -bash
3628 ? Ss 0:00 postgres: archiver process archiving 000000010000002D000000CB
3673 ? S 0:00 sh -c gzip < pg_xlog/000000010000002D000000CB > /mnt/nfs/archive/000000010000002D000000CB
3674 ? D 0:00 gzip
3682 ? S 0:00 sshd: postgres@pts/0
3683 pts/0 Ss 0:00 -bash
4070 ? Ss 0:00 postgres: postgres postgres ::1(34561) idle
4074 ? Ss 0:00 postgres: postgres sorriso ::1(34562) idle
4172 pts/0 S+ 0:00 vi postgresql.conf
4192 pts/1 R+ 0:00 ps x
-bash-4.1$ ls | wc -l
327
-bash-4.1$
gzip
and gunzip
without flags expect to work with files, compressing or uncompressing them in-place. 不带标志的
gzip
和gunzip
期望可以处理文件,就地压缩或解压缩文件。 You're trying to use them as stream processors. 您正在尝试将它们用作流处理器。 That's not going to work.
那是行不通的。
You want to use gzip -c
and zcat
(or gunzip -c
) to tell them to use stdio. 您想使用
gzip -c
和zcat
(或gunzip -c
)告诉他们使用stdio。
Additionally, though, you should probably use a simple script as the archive_command
that: 但是,此外,您可能应该使用一个简单的脚本作为
archive_command
:
gzip -c
to a temp file gzip -c
写入临时文件 mv
mv
将临时文件移动到最终位置 This ensures that the file is not read by the replica until it's fully written by the master. 这样可以确保副本文件在由主服务器完全写入之前不会被副本读取。
Also, unless the master and replica are sharing the same network file system (or are both on the same host), you might actually need to use scp
or similar to transfer the archive files. 另外,除非主数据库和副本数据库共享同一网络文件系统(或都位于同一主机上),否则您实际上可能需要使用
scp
或类似文件来传输存档文件。 The restore_command
uses paths on the replica , not on the master, so unless the replica server can access the WAL archive via NFS/CIFS/etc, you're going to need to copy the files. 该
restore_command
使用上的副本路径,而不是在主,所以除非副本服务器可以通过NFS / CIFS /等访问WAL归档,你将需要复制的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.