thinking multi-master PostgreSQL environment

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:
今天一位开发的同事把我拉去开会,其中有聊到多IDC部署数据库的需求,并且数据库之间要求数据同步。后来因为复杂度并且应用程序可以忍受主库DOWN机,所以决定不上multi-master。不过还是引发了一下我对multi-master的思考。
大概是一个这样的场景:
thinking multi-master PostgreSQL environment - 德哥@Digoal - The Heart,The World.
 

多个IDC之间会需要同步部分数据,每个IDC有自己的本地数据(不需要同步),最终每个IDC的数据库中的全局数据要求一致。
然后各个IDC要有自己的hot-standby数据库。

首先是同步使用到的技术:
1. sync方案,two phase commit,
可以让应用来做跨库事务,那就不需要数据库惨和了。
或者用PostgreSQL 自身的dblink和two phase commit 技术。
2. async方案,数据库复制软件,例如 slony-I . 
3. async方案,数据库触发器和dblink.

然后是全局数据表的设计:
1. 分表,使用不同的表名字,相互复制记录逻辑上隔离,不需要考虑冲突的问题。
分表的目的是使用单向复制软件,如slony-I。
例如IDC A:
global_table_a rw
global_table_b replication from IDC B,read only in IDC A.
global_table_c replication from IDC C,read only in IDC A.

IDC B:
global_table_a replication from IDC A,read only in IDC B.
global_table_b rw
global_table_c replication from IDC C,read only in IDC B.

IDC C:
global_table_a replication from IDC A,read only in IDC C.
global_table_b replication from IDC B,read only in IDC C.
global_table_c rw

优点是不需要考虑冲突,而且可以使用单向复制软件。
缺点是增加MASTER节点的话,需要新建表。可能还需要改程序。当然也可以建立父表,增加继承表的方式,不改程序,但是又会引起和SLONY-I不兼容的问题,如触发器。

2. 共享表,使用同一个表名,相互复制同一个表里面的记录,可能需要考虑冲突的问题。
例如IDC A:
global_table 
IDC B:
global_table
IDC C:
global_table
优点是所有节点使用一个表名,增加节点比较方便,对应用透明。
确定是可能需要考虑冲突,但是这个应该在应用设计的阶段避免修改从别的IDC同步过来的记录。

先thinking这些。
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
SQL 关系型数据库 MySQL
mysql 报错 is too long for user name (should be no longer than 16)
mysql 报错 is too long for user name (should be no longer than 16)
236 0
|
存储 JSON 数据格式
MySQL8.0.17 - Multi-Valued Indexes 简述
本文主要简单介绍下8.0.17新引入的功能multi-valued index, 顾名思义,索引上对于同一个Primary key, 可以建立多个二级索引项,实际上已经对array类型的基础功能做了支持 (感觉官方未来一定会推出类似pg的array 列类型), 并基于array来构建二级索引,这意味着该二级索引的记录数可以是多于聚集索引记录数的,因而该索引不可以用于通常意义的查询,只能通过特定的接口函数来使用,下面的例子里会说明。
1728 0
|
关系型数据库 数据库 PostgreSQL
|
关系型数据库 PostgreSQL RDS
Cloud Massive Task Scheduling System Database Design - Alibaba Cloud RDS PostgreSQL Cases
PostgreSQL is crucial to cloud massive task scheduling system. Here we will describe how to design a system database for cloud massive task scheduling.
1199 0
Cloud Massive Task Scheduling System Database Design - Alibaba Cloud RDS PostgreSQL Cases
|
SQL MySQL 关系型数据库
Why You Should Use HybridDB for MySQL for Online and Offline Data Separation
HybridDB for MySQL helps you separate online and offline data in a precise, economical, and secure way.
2350 0
Why You Should Use HybridDB for MySQL for Online and Offline Data Separation
|
SQL 关系型数据库 C语言
Principles and Applications of the Index Types Supported by PostgreSQL
Open data interfaces that allow PostgreSQL to support a wide range of different data types.
1673 0
|
NoSQL 数据库
How Should I Backup MongoDB Databases?
MongoDB replica set is composed of a group of MongoDB instances (processes), including one primary node and multiple secondary nodes.
1553 0
|
SQL 关系型数据库
Reverse Engineering Custom DataTypes -> GUID() in SQL Server to PostgreSQL
原文 https://archive.sap.com/discussions/thread/3641585   First you reverse engineer from a script where the GUID is, into the PDM, there you should get an "internal" type CLS in the model.
1050 0