9.4.1中的PostgreSQL切换和切回 [英] PostgreSQL Switchover and Switchback in 9.4.1

查看:231
本文介绍了9.4.1中的PostgreSQL切换和切回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:

PostgreSQL EDB 9.4.1
OS:rhel 7

PostgreSQL EDB 9.4.1 OS:rhel 7

我有配置了具有连续归档功能的流复制。
我已经执行了以下用于切换和切回的步骤。

I have configured streaming replication with continuous archiving. I have performed the steps below for switch-over and switchback.

我已阅读其他文章。

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

I am confused what happens if the archive location is not a shared location. I have followed the steps below for switchover and switchback.


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()"
    



    ps -ef | grep postgres
    


  • touch locationoftrigeerfile
    



    • 连接应用程序并测试

    切换之前为完成上述步骤。

    Switch-over was completed with the above steps.


    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();"
    



    ps -ef | grep postgres
    


  • touch locationoftrigeerfile
    


  • 我的问题:

    对于每个促销活动,都会根据 PostgreSQL文档

    For every promotion a new timeline id is created as per the PostgreSQL documentation.

    如果我们使用 recovery_target_timeline ='latest'那么它将使用在归档文件中找到的时间轴,但是在我的环境中,归档文件不是共享的安装点。

    If we use recovery_target_timeline='latest' then it will use the timeline which was found in the archive, but in my environment archive is not a shared mount point.

    如果在归档文件中找不到时间轴,是通过流复制接收的吗?

    If the timeline is not found in the archive, is it received via streaming replication?

    推荐答案

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

    Yes, the history file containing the timeline switch will also be streamed to the standby server.

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

    It will show up in the standby's pg_wal directory. The associated log message is:

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

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

    The standby will be able to follow the primary across the timeline switch.

    这篇关于9.4.1中的PostgreSQL切换和切回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆