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 ...
随机推荐
- zk listbox 点击列标题实现排序功能
前台(test.zul): <?page title="测试" contentType="text/html;charset=UTF-8"?> &l ...
- shodan:黑客搜索引擎
Shodan是msfconsole创始人与几个爱好技术的黑客开发的一款黑客搜索引擎,被称为可怕的搜索引擎,详细介绍见百度百科 网站地址:www.shodan.io 免费注册一账号,无账号的话,默认只显 ...
- DBConfigReader.java
package com.vcredit.ddcash.batch.util; import java.sql.Connection;import java.sql.PreparedStatement; ...
- java中内部类使用小结
内部类是指在一个外部类中再定义一个类,类名不需要和文件名相同 内部类可以是静态的,类的修饰符可以是private,default,protect,public修饰 ,而外部类只能是public 和 d ...
- # 20145334赵文豪 《Java程序设计》第7周学习总结
20145334赵文豪 <Java程序设计>第7周学习总结 教材学习内容总结 第十三章 时间与日期 13.1.1时间的度量 1.格林威治时间(GMT):参考太阳到达最高点,有时间误差. 2 ...
- Apache Spark源码走读之23 -- Spark MLLib中拟牛顿法L-BFGS的源码实现
欢迎转载,转载请注明出处,徽沪一郎. 概要 本文就拟牛顿法L-BFGS的由来做一个简要的回顾,然后就其在spark mllib中的实现进行源码走读. 拟牛顿法 数学原理 代码实现 L-BFGS算法中使 ...
- block(代码块)的介绍以及使用方法和变量之间的关系
http://blog.csdn.net/menxu_work/article/details/8762848 block(代码块)的介绍以及使用方法和变量之间的关系 block(代码块)的介绍以及使 ...
- Mongo聚合函数
{ "_id" : ObjectId("57301c7e5fd5d6e2afa221d1"), "a" : "张三", ...
- 转: Linux磁盘扩容
from:https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-mach ...
- c#中关键词out和ref的区别
c#中关键词out和ref用来表明以传引用的方式传递参数. 区别如下: 如果方法的参数用out标记,表示方法被调用前不需初始化参数,方法内不能读取此参数的值,在方法返回前必须向此参数写入值: 如果方法 ...