【问题标题】:View Binary Logs of GCP Postgres SQL instance查看 GCP Postgres SQL 实例的二进制日志
【发布时间】:2019-03-07 19:41:30
【问题描述】:

如何查看 GCP Postgres SQL 实例的二进制日志(事务日志)?可以在 GCP Console 中查看吗?

我尝试使用 Stackdriver。但它只显示实例使用数据。

谢谢

【问题讨论】:

    标签: postgresql google-cloud-sql binary-log


    【解决方案1】:

    事务(在其他事物的日志中)保存在 WAL 中,您可以(部分)使用提供的工具 pg_waldump 查看它,该工具以更易于阅读的方式显示内容,例如:

    rmgr: Heap        len (rec/tot):     54/    54, tx:    1123429, lsn: 28/0BC386A0, prev 28/0BC38580, desc: LOCK off 10: xid 1123429: flags 0 LOCK_ONLY EXCL_LOCK , blkref #0: rel 262581/261781/274824 blk 0
    rmgr: Heap        len (rec/tot):    401/   401, tx:    1123429, lsn: 28/0BC386D8, prev 28/0BC386A0, desc: UPDATE off 10 xmax 1123429 ; new off 16 xmax 0, blkref #0: rel 262581/261781/274824 blk 1, blkref #1: rel 262581/261781/274824 blk 0
    rmgr: Btree       len (rec/tot):     64/    64, tx:    1123429, lsn: 28/0BC38870, prev 28/0BC386D8, desc: INSERT_LEAF off 19, blkref #0: rel 262581/261781/274826 blk 1
    rmgr: Gin         len (rec/tot):    270/   270, tx:    1123429, lsn: 28/0BC388B0, prev 28/0BC38870, desc: UPDATE_META_PAGE , blkref #0: rel 262581/261781/274827 blk 0, blkref #1: rel 262581/261781/274827 blk 2
    rmgr: Transaction len (rec/tot):     34/    34, tx:    1123429, lsn: 28/0BC389C0, prev 28/0BC388B0, desc: COMMIT 2019-03-08 16:31:54.832416 CET
    rmgr: Standby     len (rec/tot):     50/    50, tx:          0, lsn: 28/0BC389E8, prev 28/0BC389C0, desc: RUNNING_XACTS nextXid 1123430 latestCompletedXid 1123429 oldestRunningXid 1123430
    rmgr: Standby     len (rec/tot):     50/    50, tx:          0, lsn: 28/0BC38A20, prev 28/0BC389E8, desc: RUNNING_XACTS nextXid 1123430 latestCompletedXid 1123429 oldestRunningXid 1123430
    rmgr: XLOG        len (rec/tot):    106/   106, tx:          0, lsn: 28/0BC38A58, prev 28/0BC38A20, desc: CHECKPOINT_ONLINE redo 28/BC38A20; tli 1; prev tli 1; fpw true; xid 0:1123430; oid 282777; multi 2; offset 3; oldest xid 561 in DB 1; oldest multi 1 in DB 1; oldest/newest commit timestamp xid: 0/0; oldest running xid 1123430; online
    rmgr: Standby     len (rec/tot):     50/    50, tx:          0, lsn: 28/0BC38AC8, prev 28/0BC38A58, desc: RUNNING_XACTS nextXid 1123430 latestCompletedXid 1123429 oldestRunningXid 1123430
    rmgr: Heap2       len (rec/tot):     59/  4643, tx:          0, lsn: 28/0BC38B00, prev 28/0BC38AC8, desc: CLEAN remxid 1123429, blkref #0: rel 262581/261781/274824 blk 0 FPW
    rmgr: Heap        len (rec/tot):     65/  6525, tx:    1123430, lsn: 28/0BC39D28, prev 28/0BC38B00, desc: UPDATE off 7 xmax 1123430 ; new off 17 xmax 0, blkref #0: rel 262581/261781/274824 blk 1 FPW
    

    为了更好地介绍如何阅读 WAL 内容,请看这个简洁的小演示:WAL: Everything You Want to Know

    【讨论】:

      【解决方案2】:

      无法在 GCP Console 中找到二进制日志,因为 Postgres 本身不使用二进制日志。

      也许this post in ServerFault 可能对您进一步阅读有用。

      【讨论】:

        猜你喜欢
        • 2021-03-25
        • 2020-05-24
        • 2019-10-27
        • 2021-05-25
        • 1970-01-01
        • 1970-01-01
        • 2018-08-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多