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 ...
随机推荐
- Many2one类型的fields Compute得到的值 搜索
v8 默认情况下compute的值不存储于数据库中,在高级搜索中也不可以进行搜索 想要对这种类型的值搜索,需要在field的定义中添加search参数,在search的函数中编写搜索逻辑. 例子: r ...
- 异常 java.util.regex.PatternSyntaxException:
可变参数是在JDK1.5之后出来的一个行特性,也是一个比较好用的东西 想起好多jfinal还有其他框架的查询方法就有好多用到了可变参数,自己也写了个这样的方法 public class Test{ ...
- Linux下配置SVN
1.安装svn yum -y install subversion 2.创建SVN版本库目录 mkdir -p /var/svn/svnrepos (-p参数:如果没有这个目录,则创建这个目录) 3. ...
- zk label控件内容换行
Label控件本身无法换行,不过div却可以,只要设置了div的宽度,那么就想如果在Label控件外套个div会怎样,结果可喜可乐: <div width="80px"> ...
- ArcGIS AddIN 之 DockPanel 界面空白
辛辛苦苦写了个AddIn插件,自己用一切正常,发给别人就弹不出DockPanel, 或者弹出时只有Panel,没有具体的控件.经多次排查,原因是: 使用了第三方的界面控件DotNetBar,开发环境中 ...
- bootstrap学习笔记之一
一.概要 bootstrap是最受欢迎的HTML.css和js框架,用于开发响应式布局,移动设备优先的WEB项目. 二.CSS部分 1.bootstrap已经设定了基本的全局样式,如font-fami ...
- WPF 程序启动显示为通知区域的图标方法
首先需要引用 System.Windows; System.Drawing; public partial class MainWindow : Window { public MainWindo ...
- javascript对象的一点理解
<script type="text/javascript"> /* js对象:对象的职责是调用属性和调用方法 */ //1.对象的创建的三种方式 var obj = ...
- 深入了解ios系统机制
1.什么叫ios? ios一般指ios(Apple公司的移动操作系统) . 苹果iOS是由苹果公司开发的移动操作系统.苹果公司最早于2007年1月9日的Macworld大会 ...
- malloc_free_new_delete
malloc, free 是c的库函数,只会分配内存大小,不会调用构造函数,析构函数 new, delete C++关键字,操作符,不仅可以分配内存大小,还可以调用构造函数,析构函数 在执 ...