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 / 问题 / 318788
Accepted
padjee
padjee
Asked: 2022-10-27 10:05:55 +0800 CST2022-10-27 10:05:55 +0800 CST 2022-10-27 10:05:55 +0800 CST

postgresql 12流复制不起作用

  • 772

我想在从站上设置流复制。

在主服务器(服务器 A。Ubuntu 18.04;Postgres 12)上:

  1. sudo nano /etc/postgresql/12/main/postgresql.conf
  2. 放listen_addresses = '*'
  3. postgresql.conf 设置为:

wal_level = "logical"

archive_mode = "ON"

archive_timeout = 3600

checkpoint_timeout = 600

hot_standby = "ON"

max_connections = 700

max_wal_sender = 5

max_wal_size = 16GB

min_wal_size = 2GB

max_worker_processes = 30

synchronous_commit = "OFF"

wal_log_hints = "OFF"

wal_recycle = "ON"

wal_keep_segments = 4000

wal_sync_method = "fdatasync"

此主服务器已托管到另一台服务器的逻辑复制(服务器 B。Ubuntu 18.04;Postgres 12)

在从属服务器上(服务器 C. Ubuntu 22.04;Postgres 12):

  • 更改数据目录
  • 将其设置为从服务器 A 的流式复制。

以下是详细信息:安装 postgres(全新安装)后,我确保它正在运行,然后更改数据目录:

  1. sudo -u postgres psql
  2. SHOW data_directory;. --输出/var/lib/postgresql/12/main
  3. 退出 psql :\q
  4. sudo systemctl stop postgresql
  5. sudo systemctl status postgresql
  6. sudo rsync -av /var/lib/postgresql /data/postgresql2
  7. 重命名文件夹:sudo mv /var/lib/postgresql/12/main /var/lib/postgresql/12/main.bak
  8. 编辑 postgresql.conf :sudo nano /etc/postgresql/12/main/postgresql.conf
  9. 设置到新位置:data_directory = '/data/postgresql2/postgresql/12/main'
  10. 再次启动数据库:sudo systemctl start postgresql

结果很好。Postgres 在服务器 C 上运行良好。当我这样做SHOW data_directory;时,它给出了: /data/postgresql2/postgresql/12/main

然后我在服务器 C 上设置流复制:

  1. 停止从服务器上的服务:systemctl stop [email protected]

  2. su - postgres然后cp -R /data/postgresql2/postgresql/12/main /data/postgresql2/postgresql/12/data_original

  3. 删除旧目录:

    rm -rf /data/postgresql2/postgresql/12/main/*

  4. 然后做基础备份:

    pg_basebackup -h 10.100.9.40 -p 5432 -U rep_user -D /data/postgresql2/postgresql/12/main -Fp -Xs -R -P -v

  5. 重新开始 :systemctl start [email protected]

--给出错误:

*`Job for [email protected] failed because the service did not take the steps required by its unit configuration.
See "systemctl status [email protected]" and "journalctl -xeu [email protected]" for details`*
  1. 然后我开始使用另一种方式:sudo -i -u postgres /usr/lib/postgresql/12/bin/pg_ctl start -D /data/postgresql2/postgresql/12/main

它给出了错误:

waiting for server to start....postgres: could not access the server configuration file "/data/postgresql2/postgresql/12/main/postgresql.conf": No such file or directory

请帮忙。什么可能导致这种情况?

postgresql
  • 1 1 个回答
  • 40 Views

1 个回答

  • Voted
  1. Best Answer
    Laurenz Albe
    2022-10-28T23:46:15+08:002022-10-28T23:46:15+08:00

    您忘记在备用数据库上设置复制。至少,您必须设置restore_command并postgresql.conf创建standby.signal.

    重命名目录和运行的整个rsync过程是不必要的,只需要pg_basebackup.

    • 3

相关问题

  • 我可以在使用数据库后激活 PITR 吗?

  • 运行时间偏移延迟复制的最佳实践

  • 存储过程可以防止 SQL 注入吗?

  • PostgreSQL 中 UniProt 的生物序列

  • PostgreSQL 9.0 Replication 和 Slony-I 有什么区别?

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