如何读取PostgreSQL wal文件数据?是否有任何命令可以将 PostgreSQL 二进制文件转换为可读的文本格式? [英] How to read PostgreSQL wal file data? Is there is any command to convert PostgreSQL binary to readable text format?

查看:87
本文介绍了如何读取PostgreSQL wal文件数据?是否有任何命令可以将 PostgreSQL 二进制文件转换为可读的文本格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取 PostgreSQL wal 文件.它是一个二进制文件,我无法以文本格式读取 wal 文件数据.任何人都可以帮助我.有没有什么命令或者什么东西可以读取wal文件数据?

I am trying to read PostgreSQL wal file. Its a binary file and I am not able to read wal file data in text format. Can anyone help me for this. Is there any command or something to read the wal file data?

推荐答案

通常,Postgres 中有两个选项可以以某种人类可读的格式呈现 WAL:

Generally, there are two options in Postgres for presenting WALs in some human-readable format:

  1. pg_waldump 实用程序,但它是仅在 9.3+ 中可用.您可以尝试将 9.3 中的 pg_waldump 与 9.2 WAL 一起使用,但我不确定是否成功.它可能会起作用,因为 9.2 中不应该有任何新的 WAL 记录类型,而这些类型在 9.3 中不存在.注意:pg_waldump 在 Postgres 10.0 之前被称为 pg_xlogdump
  2. 也可以使用逻辑解码,但它从 9.4 开始可用.无论如何,通过逻辑解码,您可以使用 各种插件,例如 wal2json以人类可读的格式导出记录.注意:逻辑解码可能不会解码每个 WAL 记录,主要是关于 DML(插入/更新/删除)
  1. pg_waldump utility, but it is available only in 9.3+. You can try using pg_waldump from 9.3 with 9.2 WALs, but I am not sure in success. It may work, since there should not be any new WAL record types in 9.2, which do not exist in 9.3. Note: pg_waldump was called pg_xlogdump until Postgres 10.0
  2. Also it is possible to utilize logical decoding, but it is available since 9.4. Anyway, with logical decoding one can use various plugins like wal2json to export records in the human-readable format. Note: logical decoding may do not decode every WAL record, it is mostly about DML (insert/update/delete)

因此,我强烈建议您至少将集群升级到 Postgres 9.4.

Thus, I would strongly recommend to upgrade your cluster to Postgres 9.4 at least.

这篇关于如何读取PostgreSQL wal文件数据?是否有任何命令可以将 PostgreSQL 二进制文件转换为可读的文本格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆