PostgreSQL Hot Standby的主备切换
二、系统环境
系统平台:CentOS 6.2
三、搭建步骤
四、模拟主库出现故障
五、激活备库
六、激活原主库
recovery_target_timeline = 'latest' standby_mode = 'on' primary_conninfo = 'host=192.168.1.201 port=5432 user=repuser password=li0924' trigger_file = '/data/pgdata/trigger_standby'
2. 假如其现主库运行一段时间;需要同步日志;可以直接将$PGDATA目录下面的pg_xlog同步过去。
3. 在第2个延伸;在9.5版本提供一个特性-pg_rewind;用它来同步wal日志
pg_rewind --target-pgdata $PGDATA --source-server='host=192.168.1.201 port=5432 user=postgres dbname=mydb'
七、检测切换结果
[postgres@sdserver40_222 ~]$ ps -ef | grep postgres postgres 1206 32271 0 11:57 pts/0 00:00:00 ps -ef postgres 1207 32271 0 11:57 pts/0 00:00:00 grep postgres root 32269 31857 0 11:09 pts/0 00:00:00 su - postgres postgres 32271 32269 0 11:09 pts/0 00:00:00 -bash postgres 32347 1 0 11:11 pts/0 00:00:00 /opt/pgsql/bin/postgres postgres 32357 32347 0 11:11 ? 00:00:00 postgres: checkpointer process postgres 32358 32347 0 11:11 ? 00:00:00 postgres: writer process postgres 32359 32347 0 11:11 ? 00:00:00 postgres: wal writer process postgres 32360 32347 0 11:11 ? 00:00:00 postgres: autovacuum launcher process postgres 32361 32347 0 11:11 ? 00:00:00 postgres: archiver process postgres 32362 32347 0 11:11 ? 00:00:00 postgres: stats collector process postgres 32371 32347 0 11:11 ? 00:00:00 postgres: wal sender process repuser 192.168.1.202(59806) streaming 0/2F0008B0
查看现备库进程
[postgres@sdserver40_210 pgdata]$ ps -ef | grep postgres root 1193 31003 0 11:09 pts/1 00:00:00 su - postgres postgres 1194 1193 0 11:09 pts/1 00:00:00 -bash postgres 1280 1 0 11:11 pts/1 00:00:00 /opt/pgsql95/bin/postgres postgres 1287 1280 0 11:11 ? 00:00:00 postgres: startup process recovering 00000007000000000000002F postgres 1288 1280 0 11:11 ? 00:00:00 postgres: checkpointer process postgres 1289 1280 0 11:11 ? 00:00:00 postgres: writer process postgres 1290 1280 0 11:11 ? 00:00:00 postgres: stats collector process postgres 1291 1280 0 11:11 ? 00:00:00 postgres: wal receiver process streaming 0/2F0008B0 postgres 2625 1194 0 11:58 pts/1 00:00:00 ps -ef postgres 2626 1194 0 11:58 pts/1 00:00:00 grep postgres [postgres@sdserver40_210 pgdata]$
参考地址:
手动切换: http://francs3.blog.163.com/blog/static/405767272011724103133766/
自动切换:德哥:https://github.com/digoal/PostgreSQL_HA_with_primary_standby_2vip
PostgreSQL Hot Standby的主备切换的更多相关文章
- (摘)DataGuard物理standby管理 - 主备切换
DataGuard物理standby管理 - 主备切换 Dataguard的切换分为两种,switchover和failover. switchover一般用于数据库或硬件升级,这时只需要较短时间中断 ...
- Oracle 12C 物理Standby 主备切换switchover
Oracle 12C 物理Standby 主备切换switchover Oracle 12C 物理Standby 主备切换switchover Table of Contents 1. 简述 2. 切 ...
- KingbaseES R6 集群主机锁冲突导致的主备切换案例
案例说明: 主库在业务高峰期间,客户执行建表等DDL操作,主库产生"AccessExclusiveLock "锁,导致大量的事务产生锁冲突,大量的会话堆积,客户端session ...
- Spark系列(五)Master主备切换机制
Spark Master主备切换主要有两种机制,之中是基于文件系统,一种是基于Zookeeper.基于文件系统的主备切换机制需要在Active Master挂掉后手动切换到Standby Master ...
- 测试redis+keepalived实现简单的主备切换【转载】
转自: 测试redis+keepalived实现简单的主备切换 - Try My Best 尽力而为 - ITeye技术网站http://raising.iteye.com/blog/2311757 ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇
1. dataguard主备切换 1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,appl ...
- Postgres主备切换
主备查询 主备不会自动切换(即需要实现线上环境主数据库宕掉之后,从数据库能够自动切换为主数据库,需要借用第三方软件,例如heartbeat等) (1)如何查看是primary还是standby 方法1 ...
- 在Azure云上实现postgres主备切换
以下是工作上实现postgres主备切换功能所用到的代码和步骤,中间走了不少弯路,在此记录下.所用到的操作系统为centos 7.5,安装了两台服务器,hostname为VM7的为Master,VM8 ...
- Oracle DataGuard主备切换(switchover)
Oracle DataGuard主备切换可以使用传统的手动命令切换,也可以使用dgmgr切换,本文记录手动切换. (一)将主库切换为物理备库 STEP1:查看主库状态 SQL> SELECT O ...
随机推荐
- php修改指定文件的指定内容
<?php $origin_str = file_get_contents('路径/文件.txt'); $update_str = str_replace('qwe=0', 'qwe=1', $ ...
- bzoj3504: [Cqoi2014]危桥--最大流
题目大意:给张无向图,有两个人a,b分别从各自的起点走向各自的终点,走A,B个来回,图里有些边只能走两次,求问是否能满足a,b的需求 按照题目给的表建图 S连a1,b1 a2,b2连T 跑最大流看是否 ...
- 【iCore3 双核心板_ uC/OS-III】例程七:信号量——任务同步
实验指导书及代码包下载: http://pan.baidu.com/s/1kVjeN2n iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- ORACLE常见错误代码的分析与解决
(一)在使用ORACLE的过程过,我们会经常遇到一些ORACLE产生的错误,对于初学者而言,这些错误可能有点模糊,而且可能一时不知怎么去处理产生的这些错误,本人就使用中出现比较频繁的错误代码一一做出分 ...
- c#组元(Tuple)的使用
组元(Tuple)是C# 4.0引入的一个新特性,可以在.NET Framework 4.0或更高版本中使用.组元使用泛型来简化类的定义,多用于方法的返回值.在函数需要返回多个类型的时候,就不必使用o ...
- Tomcat性能调优
1.集成apache 虽然Tomcat也可以作web服务器,但是处理静态html的速度比不上apache,且其作为web服务器的功能远不如Apache,因此把apache和tomcat集成起来,讲ht ...
- IE8兼容H5语义标签
//IE浏览器定义的特殊属性,通过hack方式判断IE版本来执行不同的代码,IE8以下浏览器自动创建html5语义标签,从而实现兼容<!--[if lte IE 8] <script sr ...
- Java-马士兵设计模式学习笔记-代理模式-动态代理 调用Proxy.newProxyInstance()
一.概述 1.目标:不自己写代理类,利用Proxy.newProxyInstance()动态生成 2.用到的知识点: (1)//编译源码,生成class,注意编译环境要换成jdk才有compiler, ...
- JBoss和Tomcat版本、及Servlet、JSP规范版本对应一览 【转】
原文地址:http://blog.csdn.net/hills/article/details/40896357 JBoss和Tomcat版本.及Servlet.JSP规范版本对应一览 JBossAS ...
- 【C51】UART串口通信
我们常需要单片机和其他模块进行通信,数据传输,常用的方式就是串口通信技术. 常用来 单片机<-->电脑, 单片机<-->单片机之间通信. 串行通信 versus 并行通信 并 ...