PostgreSQL的 Slony-I 数据同步
原文--http://www.tuicool.com/articles/mMvARf
先谈谈slony的局限性:
1. DDL动作是不会被复制到;
2. 如果想使用slony来同步数据,表必须是带有主键的
内容大家看原文;个人感觉总结的很好!
下面是为slony维护;定制的脚本
包括了服务启动/关闭;以及slony set删除/安装。
#!/bin/sh SLONIK=/opt/pgsql/bin/slonik SLON=/opt/pgsql/bin/slon CLUSTER_NAME=lottu_cluster MASTERDBNAME=masterdb SLAVEDBNAME=slavedb MASTERHOST=192.168.8.121 SLAVEHOST=192.168.8.120 REPLICATIONUSER=postgres PASSWORD=li0924 uninstall() { $SLONIK << _EOF_ cluster name = $CLUSTER_NAME; node admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLICATIONUSER password=$PASSWORD'; node admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST user=$REPLICATIONUSER password=$PASSWORD'; uninstall node (id = ); uninstall node (id = ); _EOF_ } install() { $SLONIK << _EOF_ #-- # define the namespace the replication system # uses in our example it is slony_example #-- cluster name = $CLUSTERNAME; #-- # admin conninfo's are used by slonik to connect to # the nodes one for eachnode on each side of the cluster, # the syntax is that of PQconnectdb in # the C-API # -- node admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLICATIONUSER password=$PASSWORD'; node admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST user=$REPLICATIONUSER password=$PASSWORD'; #-- # init the first node. Its id MUST be 1. This creates # the schema _$CLUSTERNAME containing all replication # system specific database objects. #-- init cluster ( id=, comment = 'Master Node'); #-- # Slony-I organizes tables into sets. The smallest unit # a node can subscribe is a set. The master or origin of # the set is node 1. #-- create set (id=, origin=, comment='All lottu tables'); set add table (set id=, origin=, id=, fully qualified name = 'public.lottu', comment='lottu table'); # set add sequence (set id=1, origin = 1, id = 1, # fully qualified name = 'public.t1_id_seq', # comment = 't1 id sequence'); #-- # Create the second node (the slave) tell the 2 nodes how # to connect to each other and how they should listen for events. #-- store node (id=, comment = ); store path (server = , client = , conninfo='dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLICATIONUSER password=$PASSWORD'); store path (server = , client = , conninfo='dbname=$SLAVEDBNAME host=$SLAVEHOST user=$REPLICATIONUSER password=$PASSWORD'); _EOF_ } start() { $SLON $CLUSTER_NAME "dbname=$MASTERDBNAME host=$MASTERHOST user=$REPLICATIONUSER password=$PASSWORD" >> /home/postgresql/master.log & # $SLON $CLUSTER_NAME "$SLAVE" >> /home/postgresql/slave.log & } stop() { # killall slon `ps axu|grep 'dbname=masterdb' |grep -v grep|awk '{print $2}'` } case $ in 'install') install ;; 'uninstall') uninstall ;; 'start') start ;; 'stop') stop ;; *) echo "usage: $0 {install|uninstall|start|stop} " ;; esac
PostgreSQL的 Slony-I 数据同步的更多相关文章
- 数据同步DataX
数据同步那些事儿(优化过程分享) 简介 很久之前就想写这篇文章了,主要是介绍一下我做数据同步的过程中遇到的一些有意思的内容,和提升效率的过程. 当前在数据处理的过程中,数据同步如同血液一般充满全过 ...
- 转载:MySQL和Redis 数据同步解决方案整理
from: http://blog.csdn.net/langzi7758521/article/details/52611910 最近在做一个Redis箱格信息数据同步到数据库Mysql的功能. 自 ...
- oracle数据同步
随着各行业信息化水平的不断提升,各种各样的信息管理系统都被广泛使用,各系统间数据完全独立,形成了大量的信息孤岛.出于管理及决策方面的需求,实现各平台的数据同步是一个很迫切的需求,TreeSoft数据库 ...
- mysql数据同步
随着各行业信息化水平的不断提升,各种各样的信息管理系统都被广泛使用,各系统间数据完全独立,形成了大量的信息孤岛.出于管理及决策方面的需求,实现各平台的数据同步是一个很迫切的需求,TreeSoft数据库 ...
- 基于TreeSoft实现异构数据同步
一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路. TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...
- 基于TreeSoft实现mysql、oracle、sql server的数据同步
一.为了解决数据同步汇聚,数据分发,数据转换,数据维护需求,TreeSoft推出了数据同步,数据处理等丰富功能 . TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之间架起沟通的桥 ...
- Oracle数据同步交换
一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路. TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...
- SQL Server数据同步交换
一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路. TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...
- MySQL数据同步交换
一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路. TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...
- 环境篇:数据同步工具DataX
环境篇:数据同步工具DataX 1 概述 https://github.com/alibaba/DataX DataX是什么? DataX 是阿里巴巴集团内被广泛使用的离线数据同步工具/平台,实现包括 ...
随机推荐
- CentOS 学习笔记
整理基础的CentOS常用命令 http://os.51cto.com/art/201003/190801.htm 在Hyper-V中的CentOS虚拟机中使用网络 http://blog.earth ...
- jeasyui datagrid 使用记
1. 一开始想用$('#dg').datagrid('getChanges')来保存整个table修改的行, 结果发现当前编辑的行不算,要失去焦点才有记录 2. 然后改用 $('#dg') ...
- BenchmarkSQL测试脚本实现
sqlTableCreates DROP SCHEMA IF EXISTS benchmarksql CASCADE; CREATE SCHEMA benchmarksql; create table ...
- PostgreSQL数据导出导入COPY
[postgres@DELL-R720 bin]$ ./psql -p 6432psql (9.4.5)Type "help" for help. postgres=# postg ...
- .NET: WPF DependencyProperty
DependencyProperty and DependencyObject is the core of WPF data binding. We can use this two class t ...
- extjs 4.2 日期控件 选择时分秒功能
因为不支持时分秒,然后在网上也找了一段时间的插件,但是感觉起来都不大方便,最后找一个插件,只需要引用js文件,然后修改类型,就可以实现extjs下面的datafield带时分秒功能了. 步骤: 只需要 ...
- C++之路进阶——codevs2460(树的统计)
2460 树的统计 2008年省队选拔赛浙江 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 一棵树上有n个节 ...
- yii2封装一个类控制div宽度,高度
1.首先,封装一个类,放在文件夹vendor下,命名为articls.php. <?phpclass Articles{ //测试 function add() { r ...
- 02---Net基础加强
将普通日期格式:“2014年7月8日”转换成汉字日期格式:“二零一四年七月八日”.(暂时不考虑10日,13日,23日) class Program { static void Main(string[ ...
- 夺命雷公狗ThinkPHP项目之----企业网站20之网站前台头尾分离
我们的网站直接让他头尾进行分离即可: 然后在代码里面找到id 为header的这段代码: 然后将整个div的内容都给弄出来,然后在view里面创建一个Public的目录,然后在创建一个header.h ...