blob: 7a8a664c02d53c68f3e4dfee11aeda74f45331a1 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>弹性伸缩 on ShardingSphere</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/scaling/</link>
<description>Recent content in 弹性伸缩 on ShardingSphere</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<atom:link href="https://shardingsphere.apache.org/document/current/cn/features/scaling/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/scaling/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/scaling/concept/</guid>
<description>弹性伸缩作业 指一次将数据由旧分片规则伸缩至新分片规则的完整流程。
数据节点 同数据分片中的数据节点
存量数据 在弹性伸缩作业开始前,数据分片中已有的数据。
增量数据 在弹性伸缩作业执行过程中,业务系统所产生的新数据。</description>
</item>
<item>
<title>实现原理</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/scaling/principle/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/scaling/principle/</guid>
<description>原理说明 考虑到 Apache ShardingSphere 的弹性伸缩模块的几个挑战,目前的弹性伸缩解决方案为:临时地使用两个数据库集群,伸缩完成后切换的方式实现。
这种实现方式有以下优点:
伸缩过程中,原始数据没有任何影响 伸缩失败无风险 不受分片策略限制 同时也存在一定的缺点:
在一定时间内存在冗余服务器 所有数据都需要移动 弹性伸缩模块会通过解析旧分片规则,提取配置中的数据源、数据节点等信息,之后创建伸缩作业工作流,将一次弹性伸缩拆解为4个主要阶段
准备阶段 存量数据迁移阶段 增量数据同步阶段 规则切换阶段 执行阶段说明 准备阶段 在准备阶段,弹性伸缩模块会进行数据源连通性及权限的校验,同时进行存量数据的统计、日志位点的记录,最后根据数据量和用户设置的并行度,对任务进行分片。
存量数据迁移阶段 执行在准备阶段拆分好的存量数据迁移作业,存量迁移阶段采用 JDBC 查询的方式,直接从数据节点中读取数据,并使用新规则写入到新集群中。
增量数据同步阶段 由于存量数据迁移耗费的时间受到数据量和并行度等因素影响,此时需要对这段时间内业务新增的数据进行同步。 不同的数据库使用的技术细节不同,但总体上均为基于复制协议或 WAL 日志实现的变更数据捕获功能。
MySQL:订阅并解析 binlog PostgreSQL:采用官方逻辑复制 test_decoding 这些捕获的增量数据,同样会由弹性伸缩模块根据新规则写入到新数据节点中。当增量数据基本同步完成时(由于业务系统未停止,增量数据是不断的),则进入规则切换阶段。
规则切换阶段 在此阶段,可能存在一定时间的业务只读窗口期,通过设置数据库只读或ShardingSphere的熔断机制,让旧数据节点中的数据短暂静态,确保增量同步已完全完成。
这个窗口期时间短则数秒,长则数分钟,取决于数据量和用户是否需要对数据进行强校验。 确认完成后,Apache ShardingSphere 可通过配置中心修改配置,将业务导向新规则的集群,弹性伸缩完成。</description>
</item>
<item>
<title>使用规范</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/scaling/use-norms/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/scaling/use-norms/</guid>
<description>支持项 将外围数据迁移至 Apache ShardingSphere 所管理的数据库; 将 Apache ShardingSphere 的数据节点进行扩容或缩容。 不支持项 不支持无主键表的扩容和缩容。 </description>
</item>
</channel>
</rss>