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

CentOS7 PostgreSQL 主从配置( 三)的更多相关文章

  1. CentOS7 PostgreSQL 主从配置( 二)

    同步流复制配置PostgreSql的流复制是异步的,缺点是Standby上的数据落后于主库上的数据,如果使用Hot Standby做读写分离,就会存在数据一致性的问题.PostgreSql9.1版本后 ...

  2. CentOS7 PostgreSQL 主从配置( 一)

    主库配置 pg_hba.conf host replication all 10.2.0.0/0 trust postgresql.conf listen_addresses = '*' max_wa ...

  3. Centos7 Openldap主从配置

    转载 https://blog.csdn.net/htvxjl02/article/details/80336788 Centos7 Openldap主从配置 2018年05月16日 15:09:57 ...

  4. postgresql主从配置

    master:10.0.1.114 slaver:10.0.1.116 一.yum安装https://blog.csdn.net/weixin_41048363/article/details/803 ...

  5. postgresql 主从配置

    安装postgresql 主从是否一定需要分两台机器,主从必须要同一个版本,不然启动会报错. 3. 配置Master数据库 su – postgres /usr/local/pgsql/bin/pg_ ...

  6. centos7 postgresql安装配置

    2021-07-15 1.添加用户 # 添加用户 postgres useradd postgres # 给用户 postgres 设置密码 passwd postgres 2.切换到该用户,下载 p ...

  7. postgresql pgsql最新版安装指南及数据存储路径更改及主从配置

    postgresql pgsql最新版安装指南及数据存储路径更改及主从配置 安装指南 首先在apt的list添加你当前系统版本对应的apt列表 目前官网有16.04,14.04,12.04 分别对应下 ...

  8. Redis集群(三):主从配置一

    一.本文目的          Redis的主从配置分为两篇文章,第一篇主要介绍了Redis主从配置的搭建过程及使用,第二篇主要说明各种情况下Redis主从状态,如Master挂掉,Slaver挂掉, ...

  9. CentOS7+mysql5.6配置主从

    一.安装环境 操作系统:CentOS-7-x86_64-DVD-1611.iso数据库版本:mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz数据库地址: 192.1 ...

随机推荐

  1. Python朝花夕拾

    Q1:HTTP Error 403: Forbidden python中经常使用urllib2.urlopen函数提取网页源码,但是有些时候这个函数返回的却是:HTTP Error 403: Forb ...

  2. SQL语句的优化

    1.创建索引 表中数据经常需要用的哪些字段数据进行过滤,则添加该字段的索引,索引相当如一本书的目录,能加快查询数据的速度:同时在新建索引的时候,将需要查询的列,在包含性 列中新增上去,能减少查询语句的 ...

  3. bigdecimal使用

    float和double类型 一般用于科学计算,用于金融的都用bigdecimal类型.在项目中浮点型数据没有指定 默认是double类型.bigdecimal的构造参数有浮点型和String类型.但 ...

  4. DHCP底层参考

    [原创翻译,水平有限] ISC DHCP支持802.1的以太网帧,令牌环和FDDI等网络.为了桥接物理层和DHCP层,它还必须实现IP和UDP协议帧. 这源于UNIX BSD socket 对未配置接 ...

  5. 辽宁OI2016夏令营模拟T2-road

    最短路(road.pas/c/cpp)题目大意有一个点数为 n,边数为 m 的无向图,点的编号为 1 到 n.边的权值均为非负数.现在请你求出从点 1 到点 n 的最短路径条数,若有无限条则输出-1, ...

  6. 统计C语言程序行数

    补充前一篇中统计C语言程序行数的程序 写得比较匆忙,可能有些失误,等弄明白GitHub的用法并完善程序后再补充完整代码链接 没有写成函数,但经过简单修改可以作为一个计算或判断函数使用 判断算法主要为以 ...

  7. 布局常见问题之css实现多行文本溢出显示省略号(…)全攻略

    省略号在ie中可以使用text-overflow:ellipsis了,但有很多的浏览器都需要固定宽度了,同时ff这些浏览器并不支持text-overflow:ellipsis设置了,下文来给各位整理一 ...

  8. 《JS权威指南学习总结--7.10 数组类型》

    内容要点: 一.数组类型 判断它是否为数组通常非常有用.在ES5中,可以使用Array.isArray()函数来做这件事情: Array.isArray([]); //=>true Array. ...

  9. 认识<meta>

    概要:在查看网页源码的时候,经常发现有<meta>标签存在,于是查了一下它的作用,发现有很多功能.下面就简单的阐述一些常见的功能. 一[什么是<meta>标签] meta,即m ...

  10. js nextSibling属性和previousSibling属性概述及使用注意

    1:nextSibling属性 该属性表示当前节点的下一个节点(其后的节点与当前节点同属一个级别):如果其后没有与其同级的节点,则返回null. 需要特别注意的是:该属性在不同的浏览器中的执行结果并不 ...