-
Notifications
You must be signed in to change notification settings - Fork 231
zh docs: architecture & concepts #1685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Verolop
wants to merge
21
commits into
prod
Choose a base branch
from
zh-docs-architecture
base: prod
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c254e01
rm vtworker section
Verolop ff8f10a
replace architecture diagram
Verolop 3938b9a
amend diagram svg
Verolop 89ca844
remove topology paragraph:
Verolop 0df0863
add Execution Plan section
Verolop 94cf414
remove duplicated img
Verolop 9c6b4fb
add Move Tables section
Verolop fecebf5
add query-rewriting section; fix execution-plans
Verolop d38b272
add VStream section & diagram; fixes topo
Verolop d2a8ace
separates vtgate, vtctl & vtctld into its own sections
Verolop 9ccd7cb
rm vt concepts from architecture section; link concepts in VTGate sec…
Verolop 9bf8e8c
small nit with a comma
Verolop c02b70b
rm duplicate 'vtctld'
Verolop bcd02ec
remove .DS_Store files & add rule to gitignore
Verolop cb607d8
Update content/zh/docs/19.0/concepts/move-tables.md
Verolop ec7cb8c
one more DS_Store file
Verolop 1f16f6c
Merge branch 'zh-docs-architecture' of https://github.com/vitessio/we…
Verolop 167b1fe
Update content/zh/docs/19.0/overview/architecture.md
Verolop ab254be
Update content/zh/docs/19.0/concepts/execution-plans.md
Verolop 4d3425c
Update content/zh/docs/19.0/concepts/vtctl.md
Verolop b00b26f
Update content/zh/docs/19.0/concepts/vtctl.md
Verolop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,6 @@ tags | |
|
|
||
| # vscode files | ||
| .vscode/ | ||
|
|
||
| # .DS_Store files | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: Execution Plan | ||
| --- | ||
|
|
||
| Vitess在VTGate和VTTablet层面对查询进行解析,目的是找到执行查询的最优方式。这一过程称为查询规划,其结果是生成一份"Execution Plan"。 | ||
|
|
||
| 这个"Execution Plan"既取决于查询本身,也依赖于相关的VSchema。Vitess的规划策略一个核心目标是尽量将工作量下推至底层MySQL实例。当无法实现下推时,Vitess会采取一种方案,通过汇总多个来源的输入并合并结果,以得出正确的查询输出。 | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| title: Move Tables | ||
| --- | ||
|
|
||
| "MoveTables"基于VReplication的新流程,使你能够在零停机时间内将表从一个键空间迁移到另一个,即在不同的物理MySQL实例间搬迁数据。 | ||
|
|
||
| ## 生产流量影响小秘诀 | ||
| 内部来说,MoveTables 操作既包含了表的复制,也涉及到对表更改的实时订阅。Vitess利用批处理技术,旨在提升表复制和应用订阅更改的效率。通俗讲,修改频率低的表迁移会更快一些。 | ||
|
|
||
| 迁移过程中,数据是从副本而非主库复制的,几乎对生产流量无影响。 | ||
|
|
||
| 在 MoveTables 操作的`SwitchTraffic` 阶段,对主库来说,Vitess可能短暂不可用。这种情况通常只持续几秒钟,但如果系统主从复制延迟较大,不可用时间可能会相应增长。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- | ||
| title: Query Rewritting | ||
| --- | ||
|
|
||
| Vitess致力于创造一种用户似乎与单一数据库建立单一连接的假象。实际上,一个单独的查询可能会与多个数据库互动,并且可能使用对同一数据库的多个连接。这里我们 | ||
| 将讨论Vitess做了什么以及这可能对您有何影响。 | ||
|
|
||
| ## Query Splitting | ||
| 8 一个复杂的查询,如果涉及跨分片(join)可能需要首先从保持vindex查找表的tablet获取信息。然后使用这些信息查询两个不同的分片以获取更多数据,随后将接收到的结 | ||
| 果合并成用户收到的单一结果。MySQL接收到的查询往往只是原始查询的一部分,最终结果将在vtgate层面组装完成。 | ||
|
|
||
| ## Connection Pooling | ||
| 11 当一个tablet代表用户与MySQL通讯执行查询时,它不会为每个用户使用专用连接,而是会在用户之间共享底层连接。这意味着在会话中存储任何状态都是不安全的,因为> 您不能确定它会继续在同一连接上执行查询,也不能确定这个连接以后是否会被其他用户使用。 | ||
|
|
||
| ## 用户定义的变量 | ||
| 在与MySQL工作时,用户定义的变量会保留在会话状态中。您可以使用SET命令为它们赋值: | ||
|
|
||
| ```sql | ||
| SET @my_user_variable = 'foobar' | ||
| ``` | ||
|
|
||
| 随后,可以使用例如SELECT的查询: | ||
|
|
||
| ```sql | ||
| > SELECT @my_user_variable; | ||
| +-------------------+ | ||
| | @my_user_variable | | ||
| +-------------------+ | ||
| | foobar | | ||
| +-------------------+ | ||
| ``` | ||
|
|
||
| 如果您通过VTGate执行这些查询,那么第一个SET查询不会被发送到MySQL。而是在VTGate内部进行处理,VTGate会为您维护这个状态。同样,第二个查询也不会下发。像这 | ||
| 类简单的查询,实际上都是直接在VTGate上完全执行的。 | ||
|
|
||
| 如果我们尝试一个更复杂的查询,需要从MySQL获取数据,VTGate会在发送之前重写查询。如果我们要写类似这样的内容: | ||
|
|
||
| ```sql | ||
| WHERE col = @my_user_variable | ||
| ``` | ||
|
|
||
| MySQL将看到的是: | ||
|
|
||
| ```sql | ||
| WHERE col = 'foobar' | ||
| ``` | ||
|
|
||
| 这样一来,在MySQL中评估查询就无需依赖会话状态了。 | ||
|
|
||
| ## 服务器系统变量 | ||
|
|
||
| 用户可能还希望更改MySQL公开的众多不同系统变量中的一个。Vitess通过五种不同方式处理系统变量: | ||
| 无操作:对于某些设置,Vitess将默默地忽略。这适用于在分片设置中没有太大意义,且不会以有趣方式改变MySQL行为的系统变量。 | ||
| 检查并在未预设情况下失败:这些设置不应更改,但如果SET语句尝试将变量设置为其当前值,Vitess会允许。 | ||
| 不支持:尝试更改这些设置将始终返回错误。 | ||
| Vitess感知:这些设置会改变Vitess的行为,不会发送到MySQL。 | ||
| 保留连接:对于某些设置,允许设置它们是合理的,但这会使使用共享连接变得更加困难。默认情况下,Vitess会首先应用这些系统变量,然后为该用户保留连接。连接池 | ||
| 对Vitess的性能至关重要,因此这不应成为Vitess上运行应用程序的常态。只需确保应用程序将设置的全局变量与Vitess的设置值相同,Vitess就可以使用连接池。 | ||
| 此外,Vitess确保@@version包含模拟的MySQL版本和Vitess版本,如:`5.7.9-vitess-14.0.0`。此值可以通过`--mysql_server_version`标志更改。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| --- | ||
| title: topology-service | ||
| title: Topology Service | ||
| description: 拓扑或分布式锁服务 | ||
| --- | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| title: VStream | ||
| --- | ||
|
|
||
| VStream是通过VTGate访问的变更通知服务。VStream的目的是提供等同于Vitess集群底层MySQL分片的MySQL二进制日志的信息。gRPC客户端,包括Vitess组件如VTTablets>,可以订阅VStream以接收来自其他分片的变更事件。VStream从一个或多个位于VTTablet实例上的VStreamer实例拉取事件,这些VStreamer实例反过来从底层MySQL实例的> 二进制日志中拉取事件。这允许高效执行如VReplication之类的功能,订阅者可以间接地从一个或多个MySQL实例分片的二进制日志接收事件,然后将其应用到目标实例。> 用户可以利用VStream获取关于给定Vitess键空间、分片和位置的数据变更事件的深入信息。单个VStream还可以整合来自键空间中多个分片的变更事件,使其成为一个方便 | ||
| 的工具,用于将变更数据捕获(CDC)过程从您的Vitess数据存储下游引导。 | ||
|
|
||
| 请参考下图: | ||
|
|
||
|  | ||
|
|
||
| 请注意:VStream与VStreamer是不同的。前者位于VTGate上,后者位于VTTablet上 | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| title: vtctl | ||
| --- | ||
|
|
||
| vtctl vtctl是一个用于管理Vitess集群的命令行工具。它允许用户或应用程序轻松地与Vitess实现交互。使用vtctl,您可以识别主数据库和副本数据库,创建表,启动故障转移,执行分片(和重新分片)操作等。 | ||
|
Verolop marked this conversation as resolved.
Outdated
|
||
|
|
||
| 当vtctl执行操作时,它会根据需要更lockserver。其他Vitess服务器会观察这些变化并做出相应的反应。例如,如果使用vtctl故障转移到新的主数据库,则vtgate会查看更改并将将写入流量切到新主服务器。 | ||
|
Verolop marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: vtctld | ||
| --- | ||
|
|
||
| vtctld是一个HTTP服务器,允许您浏览存储在lockserver中的信息。它对于故障排除或获取服务器及其当前状态的高层概观非常有用。 | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| title: VTGate | ||
| --- | ||
|
|
||
| vtgate 是一个轻型代理服务器,它将流量路由到正确的vttablet,并将合并的结果返回给客户端。应用程序向vtgate发起查询。客户端使用起来非常简单,它只需要能够找到vtgate实例就能使vitess。 | ||
|
|
||
| 为了路由查询,vtgate综合考虑了分片方案、数据延迟以及vttablet及其对应底层MySQL实例的可用性。 | ||
|
|
||
| 相关Vitess文档 | ||
|
|
||
| * [Execution Plans](../execution-plans) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.