• CentOS7 PostgreSQL 主从配置( 三)


    postgres 主备切换

    主备查看
    方法
    ps -ef | grep wal (主库 sender)
    postgres 27873 27864 0 5月06 ? 00:00:10 postgres: wal sender process postgres 10.2.0.13(47582) streaming 0/906FF78
    postgres 27874 27864 0 5月06 ? 00:00:11 postgres: wal sender process postgres 10.2.0.15(51872) streaming 0/906FF78


    ps -ef | grep wal (备库 receiver)
    postgres 25875 25828 0 5月06 ? 00:05:28 postgres: wal receiver process streaming 0/906FF78

    备库切换为主库
    1 关掉主库
    pg_ctl stop
    waiting for server to shut down.... done
    server stopped

    查看备库日志

    tail -f /var/lib/pgsql/9.5/data/pg_log/postgresql-Fri.log
    TCP/IP connections on port 5432?

    < 2016-05-13 17:24:09.493 CST >FATAL: could not connect to the primary server: could not connect to server: Connection refused
    Is the server running on host "10.2.0.14" and accepting
    TCP/IP connections on port 5432?

    < 2016-05-13 17:24:14.500 CST >FATAL: could not connect to the primary server: could not connect to server: Connection refused
    Is the server running on host "10.2.0.14" and accepting
    TCP/IP connections on port 5432?

    < 2016-05-13 17:24:19.508 CST >FATAL: could not connect to the primary server: could not connect to server: Connection refused
    Is the server running on host "10.2.0.14" and accepting
    TCP/IP connections on port 5432?

    在备机PGDATA对应目录下生成recovery.conf文件中指定的文件trigger_file = '/home/postgres.trigger' (此时备机正常运行状态)
    touch /home/postgres.trigger

    会看到 recovery.conf 文件变为 recovery.done

    tail -f /var/lib/pgsql/9.5/data/pg_log/postgresql-Fri.log
    TCP/IP connections on port 5432?

    < 2016-05-13 17:27:21.714 CST >FATAL: could not connect to the primary server: could not connect to server: Connection refused
    Is the server running on host "10.2.0.14" and accepting
    TCP/IP connections on port 5432?

    < 2016-05-13 17:27:26.719 CST >FATAL: could not connect to the primary server: could not connect to server: Connection refused
    Is the server running on host "10.2.0.14" and accepting
    TCP/IP connections on port 5432?

    < 2016-05-13 17:27:31.719 CST >LOG: trigger file found: /home/postgres.trigger
    < 2016-05-13 17:27:31.719 CST >LOG: redo is not required
    < 2016-05-13 17:27:31.735 CST >LOG: selected new timeline ID: 2
    < 2016-05-13 17:27:32.282 CST >LOG: archive recovery complete
    < 2016-05-13 17:27:32.331 CST >LOG: MultiXact member wraparound protections are now enabled
    < 2016-05-13 17:27:32.345 CST >LOG: autovacuum launcher started
    < 2016-05-13 17:27:32.347 CST >LOG: database system is ready to accept connections

  • 相关阅读:
    Thrift实现C#调用Java开发步骤详解
    微信小程序项目实战之豆瓣天气
    带有关闭按钮的alertView
    基于olami开放语义平台的微信小程序遥知之源码实现
    iOS-仿智联字符图片验证码
    微信 支付宝支付 友盟登录分享 统计
    优化VMware提高虚拟机运行速度的技巧
    区块链与密码学
    在 Ubuntu 16.04 中安装支持 CPU 和 GPU 的 Google TensorFlow 神经网络软件
    Ubuntu+anaconda环境里安装opencv
  • 原文地址:https://www.cnblogs.com/zhangeamon/p/5490190.html
Copyright © 2020-2023  润新知