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. if和switch的原理

    在C语言中,if和switch是条件分支的重要组成部分.if的功能是计算判断条件的值,根据返回的值的不同来决定跳转到哪个部分.值为真则跳转到if语句块中,否则跳过if语句块.下面来分析一个简单的if实 ...

  2. java 中文乱码

    1.URL编码 String str = URLEncoder.encode("中文乱码","UTF-8");//编码 String newStr = URLD ...

  3. eclipse 使用hadoop-plugins 插件出现EOFException问题

    相当郁闷的一个问题,之前也看了好多外国的网站,也没有解答 主要出在了使用http访问 http://192.168.5.128:50030/jobtracker.jsp http://192.168. ...

  4. Linux下安装vnstat流量统计

    1. 下载安装 cd /data/software wget http://humdi.net/vnstat/vnstat-1.11.tar.gz tar zxf vnstat-1.11.tar.gz ...

  5. PostgreSQL 类型转换 -除法

    PostgreSQL 类型转换 类似Oracle ,PostgreSQL也有强大的类型转换函数, 下面仅举两个类型转换例子. --1 例子 postgres=# select 1/4;  ?colum ...

  6. ios 从前台返回到回台 从后台返回到前台 或者 支付宝支付订单后 对界面进行操作

    正常情况下,在AppDelegate中实现下面两个方法,能够监听从后台恢复到前台 - (void)applicationDidEnterBackground:(UIApplication *)appl ...

  7. C语言:全局变量在多个c文件中公用的方法 [转]

    用C语言编写程序的时候,我们经常会遇到这样一种情况:希望在头文件中定义一个全局变量,然后包含到两个不同的c文件中,希望这个全局变量能在两个文件中共用. 举例说明:项目文件夹project下有main. ...

  8. 异常处理try-catch-finally笔记

    当程序发生异常时,我们期望:返回到一种安全状态,并能够让用户执行一些其他的命令:或者 允许用户保存所有操作的结果,并以适当的方式终止程序. 异常处理机制:程序的执行过程中如果出现异常,会自动生成一个异 ...

  9. hdu 1407 测试你是否和LTC水平一样高

    Description 大家提到LTC都佩服的不行,不过,如果竞赛只有这一个题目,我敢保证你和他绝对在一个水平线上! 你的任务是: 计算方程x^2+y^2+z^2= num的一个正整数解.  Inpu ...

  10. amazeui 后台模板

    <!doctype html> <html class="no-js"> <head> <meta charset="utf-8 ...