【问题标题】:PostgreSQL Switchover and Switchback in 9.4.1PostgreSQL 9.4.1 中的切换和切回
【发布时间】:2019-11-20 08:06:29
【问题描述】:

环境:

PostgreSQL EDB 9.4.1 操作系统:rhel 7

我已将流式复制配置为连续归档。 我已执行以下步骤进行切换和切回。

我看过this其他文章。

我很困惑如果存档位置不是共享位置会发生什么。 我已按照以下步骤进行切换和切回。

切换

在主人(192.xxxx.128)

  • pg_ctl -D /opt/PostgresPlus/9.4AS/data stop --mode=fast
    
  • 创建recovery.conf:

    standby_mode = 'on'
    primary_conninfo = 'user=replication password=Replication@123 host=192.xxx.129 port=5432'
    recovery_target_timeline = 'latest'
    trigger_file = '/tmp/node1'
    restore_command = 'rsync -a /home/postgres/restore/%f %p
    
  • pg_ctl -D /opt/PostgresPlus/9.4AS/data start
    
  • psql -U postgres -c "select pg_is_in_recovery()"
    

待机时(192.xx.129):

  • ps -ef | grep postgres
    
  • touch locationoftrigeerfile
    

在主要 (192.xx.129):

  • 连接应用程序和测试

以上步骤完成切换。

现在切换

在主要 (192.xx.129):

  • pg_ctl -D $PGDATA stop --mode=fast
    
  • 创建recovery.conf 并添加

    standby_mode = 'on'
    primary_conninfo = 'user=replication password=postgres host=192.xxx.128 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres'
    restore_command = 'cp %p /home/postgres/restore_5444/%f'
    recovery_target_timeline = 'latest'
    trigger_file='/tmp/pg_promote_5432'`
    
  • pg_ctl -D $PGDATA start --mode=fast
    
  • psql -U postgres -c "select pg_is_in_recovery();"
    

在中学(192.xxx.128):

  • ps -ef | grep postgres
    
  • touch locationoftrigeerfile
    

我的问题:

对于每个促销活动,都会根据 PostgreSQL documentation 创建一个新的时间线 ID。

如果我们使用recovery_target_timeline='latest',那么它将使用在存档中找到的时间线,但在我的环境中存档不是共享挂载点。

如果在存档中找不到时间线,是否通过流复制接收?

【问题讨论】:

    标签: postgresql replication postgresql-9.4


    【解决方案1】:

    是的,包含时间线切换的历史文件也将流式传输到备用服务器。

    它将显示在备用的pg_wal 目录中。相关的日志消息是:

    LOG:  fetching timeline history file for timeline 2 from primary server
    

    备用数据库将能够跨时间轴切换跟随主要数据库。

    【讨论】:

    • 抱歉再次提问我这次测试了相同的场景我没有提到恢复 _target_timeline='latest' 但是当 prod 进入恢复并且在我提示从属到主之后 DR 没有开始复制它显示复制被主服务器终止,即使我已经发送 000002.history 文件以恢复位置到 dr 仍然无法正常工作......请帮助我......如果你愿意,我可以发布新问题
    • 我已经发布了关于这个的新问题,请检查。 stackoverflow.com/questions/59124137/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 2013-06-20
    • 2015-11-21
    相关资源
    最近更新 更多