• 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

  • 相关阅读:
    go golang 代码记录
    ERROR org.apache.hadoop.yarn.server.resourcemanager.ResourceManager: RECEIVED SIGNAL 15
    hbase启动之后master和regionserver相继自动断掉
    Native memory allocation (malloc) failed to allocate 32744 bytes for ChunkPool::allocate
    虚拟机中二次安装cdh重新启动hadoop集群报错
    cdh在虚拟机中二次安装时无法选择之前管理的主机
    sqoop生成与关系数据库表结构对应的hive表结构,但在hive却找不到table
    Sqoop将hive数据导出到MySQL中文乱码了怎么办?
    idea通过maven打jar包不成功或无法加载主类或打成功也找不到jar包
    一个牛公司的关于oracle数据的面试题
  • 原文地址:https://www.cnblogs.com/zhangeamon/p/5490190.html
Copyright © 2020-2023  润新知