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 / 问题

问题[barman](dba)

Martin Hope
rawmain
Asked: 2020-10-03 15:56:55 +0800 CST

为什么使用 synchronous_standby_names = 'barman_receive_wal' 会导致数据库异常?

  • 0

使用PostgreSQL文件中barman的synchronous_standby_names特性postgresql.conf

synchronous_standby_names = 'barman_receive_wal'

不能做这些操作:

  • 创建用户(挂起)
  • createdb(挂起)
  • repmgr如果用于复制,则无法将数据保存在主数据库中

他们的主要配置是

max_wal_senders = 10
max_replication_slots = 10
shared_preload_libraries = 'repmgr'
wal_level = 'replica'
archive_mode = on
archive_command = 'rsync -a %p barman@backup_server:/var/lib/barman/mydb/incoming/%f'
synchronous_standby_names = 'barman_receive_wal'

如果synchronous_standby_names从此配置中删除,它工作得很好。

postgresql barman
  • 1 个回答
  • 104 Views
Martin Hope
rawmain
Asked: 2020-03-06 17:21:39 +0800 CST

如何在不安装 PostgreSQL 服务器的情况下使用 pg_receivewal 和 pg_basebackup 安装 Barman?

  • 0

按照官方文档,只需通过yum或apt直接安装barman即可:

http://docs.pgbarman.org/release/2.10/#installation

无需在酒保服务器上安装 PostgreSQL 服务器。

但是为了使用酒保,这两个库是必需的:pg_receivewal和pg_basebackup. /usr/pgsql-10/bin/如果安装 PostgreSQL 服务器,它们在路径中。

如何在不安装 PostgreSQL 服务器的情况下制作它们?到底有没有?

postgresql barman
  • 2 个回答
  • 652 Views
Martin Hope
rawmain
Asked: 2020-03-05 20:11:02 +0800 CST

为什么 Barman 的备份数据库无法结束(待定)?

  • 2

做过操作:

barman cron
barman receive-wal --create-slot pg
barman receive-wal pg
barman switch-wal --force --archive pg

然后运行检查和备份命令:

-bash-4.2$ barman check pg
Server pg:
    PostgreSQL: OK
    is_superuser: OK
    PostgreSQL streaming: OK
    wal_level: OK
    replication slot: OK
    directories: OK
    retention policy settings: OK
    backup maximum age: OK (no last_backup_maximum_age provided)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
    minimum redundancy requirements: OK (have 0 backups, expected at least 0)
    pg_basebackup: OK
    pg_basebackup compatible: OK
    pg_basebackup supports tablespaces mapping: OK
    systemid coherence: OK (no system Id stored on disk)
    pg_receivexlog: OK
    pg_receivexlog compatible: OK
    receive-wal running: OK
    archive_mode: OK
    archive_command: OK
    archiver errors: OK
-bash-4.2$ barman backup pg
Starting backup using postgres method for server pg in /var/lib/barman/pg/base/20200305T124531
Backup start at LSN: 0/5100A7B8 (000000010000000000000051, 0000A7B8)
Starting backup copy via pg_basebackup for 20200305T124531
(pending)

很长一段时间后它无法完成。检查/var/lib/barman/pg/base/20200305T124531/路径:

  • 备份信息
  • 数据

在data中,似乎已经复制了来自 pg 服务器的数据。请参阅中的内容backup.info:

backup_label=None
begin_offset=42936
begin_time=2020-03-05 12:45:31.020705+09:00
begin_wal=000000010000000000000051
begin_xlog=0/5100A7B8
config_file=/var/lib/pgsql/10/data/postgresql.conf
copy_stats=None
deduplicated_size=None
end_offset=None
end_time=None
end_wal=None
end_xlog=None
error=None
hba_file=/var/lib/pgsql/10/data/pg_hba.conf
ident_file=/var/lib/pgsql/10/data/pg_ident.conf
included_files=None
mode=postgres
pgdata=/var/lib/pgsql/10/data
server_name=pg
size=None
status=STARTED
systemid=6795775088862271947
tablespaces=None
timeline=1
version=100012
xlog_segment_size=16777216

检查过程,得到:

barman    5661  0.0  0.2 258560 19204 ?        Ss   12:45   0:00 /usr/bin/python2 /bin/barman -c /etc/barman.conf -q receive-wal pg
barman    5671  0.0  0.0 176384  3416 ?        S    12:45   0:00 /usr/pgsql-10/bin/pg_receivewal --dbname=dbname=replication host=pg options=-cdatestyle=iso replication=true user=streaming_barman application_name=barman_receive_wal --verbose --no-loop --no-password --directory=/var/lib/barman/pg/streaming --slot=barman
postgres  5675  0.0  0.0 397052  3844 ?        Ss   12:45   0:00 postgres: wal sender process streaming_barman 127.0.0.1(41570) streaming 0/534365C8
barman    5745  0.0  0.2 258564 19080 pts/0    S+   12:45   0:00 /usr/bin/python2 /bin/barman backup pg
barman    5751  0.0  0.0 176132  3316 pts/0    S+   12:45   0:00 /bin/pg_basebackup --dbname=dbname=replication host=pg options=-cdatestyle=iso replication=true user=streaming_barman application_name=barman_streaming_backup -v --no-password --pgdata=/var/lib/barman/pg/base/20200305T124531/data --no-slot --wal-method=none
postgres  5752  0.0  0.0 396724  7980 ?        Ss   12:45   0:00 postgres: wal sender process streaming_barman 127.0.0.1(41618) sending backup "pg_basebackup base backup"

为什么不能完成?status=STARTED未更新完成状态。

postgresql barman
  • 1 个回答
  • 873 Views
Martin Hope
rawmain
Asked: 2020-03-05 06:03:59 +0800 CST

如何使用 barman 正确备份 PostgreSQL 数据库?

  • 1

我现在正在使用 PostgreSQL 10。在 RHEL 7 上安装了最新的 Barman。

当我由酒保用户运行此命令时:

-bash-4.2$ barman receive-wal pg
Starting receive-wal for server pg
ERROR: ArchiverFailure:pg_receivexlog not present in $PATH

官方介绍

WAL streaming

Barman can reduce the Recovery Point Objective (RPO) by allowing users to add continuous WAL streaming from a PostgreSQL server, on top of the standard archive_command strategy.

Barman relies on pg_receivewal, a utility that has been available from PostgreSQL 9.2 which exploits the native streaming replication protocol and continuously receives transaction logs from a PostgreSQL server (master or standby). Prior to PostgreSQL 10, pg_receivewal was named pg_receivexlog.

IMPORTANT: Barman requires that pg_receivewal is installed on the same server. For PostgreSQL 9.2 servers, you need pg_receivexlog of version 9.2 installed alongside Barman. For PostgreSQL 9.3 and above, it is recommended to install the latest available version of pg_receivewal, as it is back compatible. Otherwise, users can install multiple versions of pg_receivewal/pg_receivexlog on the Barman server and properly point to the specific version for a server, using the path_prefix option in the configuration file.

In order to enable streaming of transaction logs, you need to:

setup a streaming connection as previously described
set the streaming_archiver option to on
The cron command, if the aforementioned requirements are met, transparently manages log streaming through the execution of the receive-wal command. This is the recommended scenario.

However, users can manually execute the receive-wal command:
barman receive-wal <server_name>

它说:

Prior to PostgreSQL 10, pg_receivewal was named pg_receivexlog.

为什么是版本10,有pg_receivexlog错误?


检查备份

当我检查备份时,得到:

-bash-4.2$ barman check pg
Server pg:
    WAL archive: FAILED (please make sure WAL shipping is setup)
    PostgreSQL: OK
    is_superuser: OK
    PostgreSQL streaming: OK
    wal_level: OK
    replication slot: FAILED (slot 'barman' not initialised: is 'receive-wal' running?)
    directories: OK
    retention policy settings: OK
    backup maximum age: OK (no last_backup_maximum_age provided)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
    minimum redundancy requirements: OK (have 0 backups, expected at least 0)
    pg_basebackup: OK
    pg_basebackup compatible: OK
    pg_basebackup supports tablespaces mapping: OK
    systemid coherence: OK (no system Id stored on disk)
    pg_receivexlog: FAILED
    pg_receivexlog compatible: FAILED (PostgreSQL version: 10.12, pg_receivexlog version: None)
    receive-wal running: FAILED (See the Barman log file for more details)
    archiver errors: OK

如何修复失败的项目?


编辑

当我pg_receivewal按postgres用户检查时:

$ sudo su - postgres
-bash-4.2$ pg_receivewal
-bash: pg_receivewal: command not found
-bash-4.2$ psql
psql (9.2.24, server 10.12)
WARNING: psql version 9.2, server version 10.0.
         Some psql features might not work.
Type "help" for help.

PostgreSQL 版本:10.12,pg_receivewal不存在?

postgresql barman
  • 2 个回答
  • 1835 Views
Martin Hope
Mikhail Aksenov
Asked: 2019-12-18 01:57:51 +0800 CST

barman-wal-archive 与 -WAL 存档:失败(请确保设置了 WAL 运输)

  • 0

我正在尝试使用“barman-wal-archive”找不到解决问题的位置或如何调试它,无论如何有一个全新的 barman 2.10 并且它是日志:

2019-12-16 10:44:08,908 [16653] barman.server INFO: Received file '0000000100000004000000A3' with checksum 'e3fced48b20b874fc34e89dc0ce87adf' by put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:44:08,913 [16653] barman.server ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:44:13,132 [16670] barman.server INFO: Received file '0000000100000004000000A3' with checksum 'e3fced48b20b874fc34e89dc0ce87adf' by put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:44:13,137 [16670] barman.server ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:45:02,234 [16725] barman.wal_archiver INFO: Found 1 xlog segments from file archival for postgres-server. Archive all segments in one run.
2019-12-16 10:45:02,234 [16725] barman.wal_archiver INFO: Archiving segment 1 of 1 from file archival: postgres-server/0000000100000004000000A3
2019-12-16 10:45:16,625 [16743] barman.server INFO: Received file '0000000100000004000000A3' with checksum 'e3fced48b20b874fc34e89dc0ce87adf' by put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:45:16,638 [16743] barman.cli ERROR: [Errno 13] Permission denied
See log file for more details.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/barman/cli.py", line 1355, in main
    p.dispatch(pre_call=global_config)
  File "/usr/lib/python2.7/site-packages/argh/helpers.py", line 55, in dispatch
    return dispatch(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/usr/lib/python2.7/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/usr/lib/python2.7/site-packages/argh/dispatching.py", line 231, in _call
    result = function(namespace_obj)
  File "/usr/lib/python2.7/site-packages/barman/cli.py", line 912, in put_wal
    server.put_wal(stream)
  File "/usr/lib/python2.7/site-packages/barman/server.py", line 1904, in put_wal
    fsync_file(item.path)
  File "/usr/lib/python2.7/site-packages/barman/utils.py", line 332, in fsync_file
    os.fsync(file_fd)
OSError: [Errno 13] Permission denied
2019-12-16 10:45:20,840 [16759] barman.server INFO: Received file '0000000100000004000000A3' with checksum 'e3fced48b20b874fc34e89dc0ce87adf' by put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:45:20,845 [16759] barman.server ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:45:25,059 [16776] barman.server INFO: Received file '0000000100000004000000A3' with checksum 'e3fced48b20b874fc34e89dc0ce87adf' by put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:45:25,064 [16776] barman.server ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
2019-12-16 10:46:01,647 [16827] barman.wal_archiver INFO: Found 1 xlog seg

postgres-server.conf

[postgres-server]
description =  "Saint Petersburg PostgreSQL server to test backups"
conninfo = host=192.3.2.1 user=barman dbname=postgres
backup_method = postgres
# backup_method = rsync
archiver = on

postgresql.conf

archive_mode = on
wal_level = 'replica'
archive_command = 'barman-wal-archive barman-server postgres-server %p'

顺便说一句,当我在酒保服务器上发出 barman-wal-archive 时,它​​会要求输入密码:

[barman@barman-server ~]$ barman-wal-archive --test barman-server postgres-server DUMMY
barman@ldn-postgres-barman's password:
Ready to accept WAL files for the server postgres-server

[postgres@postgres-server ~] barman-wal-archive --test barman-server postgres-server DUMMY
Ready to accept WAL files for the server postgres-server

一些postgres日志:

2019-12-16 19:06:50.074 MSK,,,14552,,5df79de2.38d8,197,,2019-12-16 18:08:18 MSK,,0,LOG,00000,"archive command failed with exit code 1","The failed archive command was: barman-wal-archive barman-server postgres-server pg_wal/0000000100000004000000A3",,,,,,,,""
2019-12-16 19:06:54.306 MSK,,,14552,,5df79de2.38d8,198,,2019-12-16 18:08:18 MSK,,0,LOG,00000,"archive command failed with exit code 1","The failed archive command was: barman-wal-archive barman-server postgres-server pg_wal/0000000100000004000000A3",,,,,,,,""
2019-12-16 19:06:58.509 MSK,,,14552,,5df79de2.38d8,199,,2019-12-16 18:08:18 MSK,,0,LOG,00000,"archive command failed with exit code 1","The failed archive command was: barman-wal-archive barman-server postgres-server pg_wal/0000000100000004000000A3",,,,,,,,""
2019-12-16 19:06:58.509 MSK,,,14552,,5df79de2.38d8,200,,2019-12-16 18:08:18 MSK,,0,WARNING,01000,"archiving write-ahead log file ""0000000100000004000000A3"" failed too many times, will try again later",,,,,,,,,""
EXCEPTION: [Errno 13] Permission denied
See log file for more details.
ERROR: Remote 'barman put-wal' command has failed!
ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
ERROR: Remote 'barman put-wal' command has failed!
ERROR: Impossible to write already existing file '0000000100000004000000A3' in put-wal for server 'postgres-server' (SSH host: 192.3.2.1)
ERROR: Remote 'barman put-wal' command has failed!

这件事是我看到第一个 WAL 被接收,然后整个过程就停留在第一个 WAL 上。并且再次重现相同的错误消息?如何定义缺少哪些权限?

我将 /usr/lib/python2.7/site-packages/* 的完全访问权限授予了酒保服务器上的所有用户。酒保权限似乎是文件,因为 WAL 可以由酒保创建。

我在配置中错过了什么?

试过:

[barman@barman-server ~]$ barman switch-wal --force --archive postgres-server
The WAL file 0000000100000004000000A8 has been closed on server 'postgres-server'
Waiting for the WAL file 0000000100000004000000A8 from server 'postgres-server' (max: 30 seconds)
Processing xlog segments from file archival for postgres-server
        0000000100000004000000A7
Processing xlog segments from file archival for postgres-server
        0000000100000004000000A7
Processing xlog segments from file archival for postgres-server
        0000000100000004000000A7
Processing xlog segments from file archival for postgres-server
        0000000100000004000000A7
ERROR: The WAL file 0000000100000004000000A8 has not been received in 30 seconds

它说 - “未收到”,文件在 wal 目录中,但过程因错误而中断。我们有 4 行“为 postgres-server 处理文件归档中的 xlog 段”是否可以?

更新。我安装了 cifs (samba) 并且酒保想使用它。这是与此处相同的未解决问题:https ://sourceforge.net/p/pgbarman/tickets/80/

postgresql barman
  • 1 个回答
  • 1606 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