数据库分片
1、数据分片
数据库IO特别大时,将一张表的数据分片到多个数据库服务器上,降低数据库服务器压力
分片目标
分片特点
2、实现方式
2-1、硬编码实现数据分片

2-2、映射表外部存储
可以建立多个映射表,用多个方式进行映射,较为灵活;
在实践中不多见,原因:
1、一次查询变成两次查询;
2、对应用程序增加复杂性,带来数据不一致性;

3、分布式数据库中间件
由分布式数据库中间件,进行路由选择
原理:
1、配置路由规则;
2、

Cobar系统组件模型

4、当数据库服务器增加时,应该如何处理?
先作业务分片
再对客户
5、数据库部署方案

2、NoSQL
2-1、CAP原理
1、一致性Consistency
一致性是说,每次读取的数据都应该是最近写入的数据或者返回一个错误(Every read receives the most recent write or an error), 而不是过期数据,也就是数据是一致的;
操作是不保证的,但是数据一定是最新的
2、可用性Availability
不保证数据是最新的,但是操作一定是对的

3、分区忍受性

4、CAP原理
当网络分区失效发生的时候,我们要么取消操作,这样数据就是一致的,但是系统却不可用;
要么我们继续写入数据,但是数据的一致性就等不到保证;

满足分区耐受性情况下,可用性和一致性无法同时满足
两个数据库同时写,可用性降低;
2-2、CAP原理与数据一致性冲突

2-3、最终一致性
完全高可用的系统代价非常大;
2-4、最终一致性

2-4-1、最终一致性写冲突

2-4-2、客户端冲突解决

2-5、投票解决冲突(Cassandra)
这个是不是双写或者叫三写?同时写入多个数据源?
降低了可用性;
只有一个节点成功,写入数据失败;

Cassandra分布式架构

2-6、HBase架构
HBase不需要选择HRegionServer,通过HMaster询问选择
Zookeeper选择一个Master,当Master宕机,Zookeeper重新选举;
Zookeeper解决一致性
脑裂
服务器宕机数据不会丢失

可用性:一个Key只会由一个HRegionServer保证读写;
HBase可用性较差,当一个HRegionServer宕机后,宕机Server负责的Key,需要重新分配给其他Server;



1、doris

版权声明: 本文为 InfoQ 作者【Arthur】的原创文章。
原文链接:【http://xie.infoq.cn/article/400f35da1ff24b27e8a68ba4d】。未经作者许可,禁止转载。
评论