AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题

问题[write-ahead-logging](dba)

Martin Hope
ordinary_guy
Asked: 2022-10-10 05:29:13 +0800 CST

使用 WAL 模式归档 SQLite DB

  • 0

我有一个gapongasi.db使用 WAL 模式配置的 SQLite 数据库,我希望使用 tar(1) 进行每日存档。使用 WAL,有两个文件被使用 (1)gapongasi.db-wal和 (2) gapongasi.db-shm,这两个文件是否与归档相关?

sqlite write-ahead-logging
  • 1 个回答
  • 22 Views
Martin Hope
Yusuf K
Asked: 2021-10-21 13:44:07 +0800 CST

如果事务在中间中止,写入的 WAL 日志会发生什么?[复制]

  • 1
这个问题在这里已经有了答案:
Postgresql 回滚回滚 1 个回答
12 个月前关闭。

我在考虑下面的场景。

BEGIN TRANSACTION;

INSERT SOMETHING;
INSERT SOMETHING;
##CLIENT COMPUTER EXPLODES

如果我理解正确,在每个 INSERT 语句之后,都会将一个日志条目写入数据库服务器的 WAL。

在这种情况下,WAL 中现在有 2 行新行,但由于客户端计算机爆炸,COMMIT 语句将永远不会执行。那么写入 WAL 的 2 行会发生什么?连接断开后它们会被删除吗?它们会作为不完整交易的残余物永久保存吗?客户端断开连接后,ABORT 语句是否会插入到 WAL 中?

postgresql write-ahead-logging
  • 1 个回答
  • 81 Views
Martin Hope
sha
Asked: 2021-09-17 11:07:17 +0800 CST

postgres WAL 文件中 LSN 的排序

  • 0

debezium 的源代码中有一条神秘的注释,它说 LSN 不需要在 WAL 文件中排序。这怎么可能?如果 LSN 表示 WAL 中的字节偏移量,怎么能不排序呢?在我们讨论的时候,有人可以准确地解释 XLOG 记录是如何在并发事务期间写入的吗?例如,tx1 提交,并且 tx1 的 XLOG 记录正在写入 WAL。现在 tx2 提交,因此 tx2 的 XLOG 记录将与 tx1 的 XLOG 记录混合。例如,以下顺序是否可行?

tx1_begin, tx2_begin, tx1_xlog1, tx2_xlog1, tx1_commit, tx2_commit
postgresql write-ahead-logging
  • 1 个回答
  • 244 Views
Martin Hope
tallharish
Asked: 2021-05-19 08:53:40 +0800 CST

Postgresql 13 更改 WAL 段大小

  • 3

在我的 Ubuntu 20 服务器上,我使用 apt 管理器安装了 PostgreSQL 13。我阅读了一些关于 PostgreSQL [1] 性能调整的文章,并考虑增加 WAL 段大小(默认为 16MB)。我看到以下说明,但是,我不知道在哪里运行它。

initdb -D ./data --wal-segment=1024

我猜文档是指从 PostgreSQL 源代码安装,我不打算这样做。如何更改 WAL 段大小?

[1] https://software.intel.com/content/dam/develop/external/us/en/documents/Open-Source-Database-Tuning-Guide-on-3rd-Generation-Intel-Xeon-Scalable-Processors .pdf


按照丹尼尔的回答,我做了以下步骤

$ pg_lsclusters
$ sudo pg_dropcluster --stop 13 main
$ sudo pg_createcluster 13 main -- --wal-segsize=256
$ sudo pg_ctlcluster 13 main start

您可以将 WAL 段的大小验证为

# du -hcs /var/lib/postgresql/13/main/pg_wal/*
postgresql write-ahead-logging
  • 2 个回答
  • 1478 Views
Martin Hope
Marcus
Asked: 2019-12-23 09:01:21 +0800 CST

在典型的 COW 文件系统上,数据库 WAL 是否冗余(理论上)?

  • 0

编辑:我错误地假设所有 COW 文件系统都有 WAL。它似乎 BTRFS 没有,所以这个问题基本上只适用于 ZFS。

典型的 COW 文件系统,如 ZFS,有自己的 WAL 形式(ZIL,在 ZFS 的情况下)。

在非 COW 文件系统上,DB WAL 对性能(因为它是顺序的)和完整性原因(因为缺乏写完整性保证)都是有意义的;在 COW 文件系统上,这些角色由 FS (WAL) 完成。

正因为如此,在 COW 文件系统上存储 DB 数据不会使 DB WAL 变得多余吗?

transaction-log write-ahead-logging
  • 2 个回答
  • 194 Views
Martin Hope
sazary
Asked: 2019-09-01 04:10:09 +0800 CST

Barman 在 WAL 大小上表现出巨大的差异

  • 0

我正在使用酒保从 postgresql 中获取备份。这是结果list-backup:

prod 20190831T000005 - Sat Aug 31 00:04:58 2019 - Size: 16.0 GiB - WAL Size: 654.2 MiB
prod 20190830T000005 - Fri Aug 30 00:04:41 2019 - Size: 16.1 GiB - WAL Size: 2.1 GiB
prod 20190829T000004 - Thu Aug 29 00:04:10 2019 - Size: 16.0 GiB - WAL Size: 1.3 GiB
prod 20190828T000004 - Wed Aug 28 00:03:21 2019 - Size: 15.9 GiB - WAL Size: 872.6 MiB
prod 20190827T204148 - Tue Aug 27 20:48:11 2019 - Size: 15.9 GiB - WAL Size: 129.3 MiB

如您所见,此处报告的 WAL 大小存在巨大差异。是什么原因?可以吗?

barman 2.9 postgresql 9.6

postgresql write-ahead-logging
  • 1 个回答
  • 192 Views
Martin Hope
eger
Asked: 2018-04-28 02:26:35 +0800 CST

为什么 PostgreSQL 删除或添加 WAL 文件?

  • 2

我有 MySQL 和 Oracle 数据库的管理经验。我最近开始使用 PostgreSQL,但找不到 PostgreSQL 根据wal_keep_segments,max_wal_size和的设置通过删除或添加来管理 WAL 文件的原因min_wal_size。

MySQL 只是继续生成新的事务文件,而 Oracle 会使用 REDO 日志文件和存档来轮换事务文件。不知道PostgreSQL为什么要通过改变WAL文件的数量来管理WAL。为什么不只保留固定数量的 WAL 文件?

postgresql write-ahead-logging
  • 1 个回答
  • 489 Views
Martin Hope
rookie099
Asked: 2018-01-05 07:21:13 +0800 CST

归档 WAL 文件的文件创建日期与 PostgreSQL 9.6 中的 archive_timeout 不一致

  • 1

我已经archive_timeout = 5为 PostgreSQL 9.6 数据库配置(即 5 秒),以便围绕时间点恢复进行测试。我archive_command调用cp到本地存档目录。

如果我检查该本地存档目录中的文件修改日期,我会发现 WAL 文件通常只在大约 每 20 秒间隔一次,即远远超过配置的 5 秒。这是针对在轻负载系统上的 Docker 容器内运行的 PostgreSQL 9.6。

什么可以解释这种巨大的差异?

postgresql write-ahead-logging
  • 1 个回答
  • 212 Views
Martin Hope
Saurabh Nanda
Asked: 2017-12-02 04:44:07 +0800 CST

无法使用酒保接收 WAL 文件

  • 6

我一直在摸索解决以下错误,但没有取得太大进展:

$ barman switch-wal --force --archive --archive-timeout 180 pg

The WAL file 0000000100000059000000FF has been closed on server 'pg'
Waiting for the WAL file 0000000100000059000000FF from server 'pg' (max: 180 seconds)
ERROR: The WAL file 0000000100000059000000FF has not been received in 180 seconds

我之前在一次性 VPS 上配置了酒保,一切正常。但是当我尝试在我们的最终 EC2 实例上复制它时,我遇到了上面提到的问题。我已经确保了以下内容(即使我不记得在 VPS 上这样做了):

  • 来自酒吧的 SSH => pg 正在工作
  • 来自 pg => barman 的 SSH 正在工作
  • 'pg' 上的所有防火墙规则已被暂时禁用

这里可能是什么问题?

编辑:添加输出barman check pg

Server pg:
2017-12-08 05:56:31,841 [14559] barman.server ERROR: Check 'WAL archive' failed for server 'pg'
    WAL archive: FAILED (please make sure WAL shipping is setup)
    PostgreSQL: OK
    is_superuser: OK
    PostgreSQL streaming: OK
    wal_level: OK
2017-12-08 05:56:34,174 [14559] barman.server ERROR: Check 'replication slot' failed for server 'pg'
    replication slot: FAILED (slot 'pgbackup' not active: is 'receive-wal' running?)
    directories: OK
    retention policy settings: OK
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'backup maximum age' failed for server 'pg'
    backup maximum age: FAILED (interval provided: 14 days, latest backup age: No available backups)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'minimum redundancy requirements' failed for server 'pg'
    minimum redundancy requirements: FAILED (have 0 backups, expected at least 3)
    pg_basebackup: OK
    pg_basebackup compatible: OK
    pg_basebackup supports tablespaces mapping: OK
    pg_receivexlog: OK
    pg_receivexlog compatible: OK
2017-12-08 05:56:34,367 [14559] barman.server ERROR: Check 'receive-wal running' failed for server 'pg'
    receive-wal running: FAILED (See the Barman log file for more details)
    archiver errors: OK

编辑:添加的输出barman receive-wal pg

$ sudo barman receive-wal pg
2017-12-10 01:48:01,129 [25410] barman.utils WARNING: Failed opening the requested log file. Using standard error instead.
Starting receive-wal for server pg
2017-12-10 01:48:01,138 [25410] barman.server INFO: Starting receive-wal for server pg
2017-12-10 01:48:03,087 [25410] barman.wal_archiver INFO: Activating WAL archiving through streaming protocol
pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)
2017-12-10 01:48:03,391 [25410] barman.command_wrappers INFO: pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)

^CSIGINT received. Terminate gracefully.
2017-12-10 01:50:42,512 [25410] barman.wal_archiver INFO: SIGINT received. Terminate gracefully.

编辑:配置文件——

; --------------------
; Contents of /etc/barman.conf after removing all commented lines.
; --------------------

[barman]
barman_user = ubuntu
path_prefix = /home/ubuntu/pg/bin
configuration_files_directory = /home/ubuntu/barman.conf.d
barman_home = /home/ubuntu/barman
log_file = /var/log/barman/barman.log
log_level = INFO
compression = bzip2
retention_policy = RECOVERY WINDOW OF 1 MONTH
last_backup_maximum_age = 2 WEEKS
minimum_redundancy = 3
retention_policy = RECOVERY WINDOW OF 4 WEEKS

/home/ubuntu/barman.conf.d/pg.conf:

; --------------------
; Contents of /home/ubuntu/barman.conf.d/pg.conf after removing all commented lines.
; --------------------

[pg]
description =  "Postgres DB"
conninfo = host=REDACTED user=REDACTED dbname=REDACTED
backup_method = postgres
archiver = off
streaming_conninfo =  host=REDACTED user=REDACTED dbname=REDACTED
streaming_archiver = on
slot_name = pgbackup
postgresql write-ahead-logging
  • 2 个回答
  • 11971 Views
Martin Hope
user2274074
Asked: 2017-11-07 09:10:26 +0800 CST

未记录表的缺点

  • 8

为了使更新更快,我正在使用:

ALTER TABLE imagingresourceplanning.opnav_fact_revenue_costs SET UNLOGGED ;

这个命令有什么缺点?

如果更新期间系统崩溃会怎样?表中存在的所有数据是否都已删除?或者只有正在进行的更新会丢失?

postgresql write-ahead-logging
  • 2 个回答
  • 5361 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve