-
Notifications
You must be signed in to change notification settings - Fork 1.2k
how-to: add TiUP quick start doc quick-start-with-tidb.md #2710
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
8af2abd
Merge branch 'master' of github.com:pingcap/docs-cn
dad2cc3
Merge branch 'master' of github.com:pingcap/docs-cn
2522c5b
Merge remote-tracking branch 'upstream/master'
dcb74cf
Merge branch 'master' of github.com:pingcap/docs-cn
89db6ca
Merge branch 'master' of github.com:pingcap/docs-cn
7272fcf
Merge remote-tracking branch 'upstream/master'
5ace768
Merge remote-tracking branch 'upstream/master'
a5a5d42
Merge remote-tracking branch 'upstream/master'
4f56b72
Merge remote-tracking branch 'upstream/master'
c7be3c5
Merge remote-tracking branch 'upstream/master'
3f0d54f
Merge remote-tracking branch 'upstream/master'
392f030
Add gather_timeout parameter
bf098af
fix some details
superlzs0476 5943b8e
Merge branch 'master' into add-tiup-getstart
lonng 0012ac4
Add getstart for tiup
3ec7b6c
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 12ea907
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 41db2fb
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 6734e40
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb a57fb8c
Update deploy-tidb-from-tiup.md
kissmydb 51ed68f
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 58a1fa5
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb b6dc73d
Update deploy-tidb-from-tiup.md
kissmydb c4d8c71
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 8859421
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 0ffcc5e
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 39edf72
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 2900b38
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 a3840df
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 784fa3a
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 8a523b2
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb ae47008
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 4717c39
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 565ee8c
Update how-to/get-started/deploy-tidb-from-tiup.md
kissmydb 97f2b01
Add getstart for tiup
f24d09f
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 9901d4b
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 847eac9
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 7d819fb
Update how-to/get-started/deploy-tidb-from-tiup.md
superlzs0476 dab5306
Format/content edits; add to TOC; change filename
61149bd
Merge branch 'master' into add-tiup-getstart
yikeke 8ac45d1
Merge branch 'master' into add-tiup-getstart
sre-bot 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
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,316 @@ | ||
| --- | ||
| title: 如何快速体验 TiDB 集群 | ||
| category: how-to | ||
| --- | ||
|
|
||
| # 如何快速体验 TiDB 集群 | ||
|
|
||
| 本文介绍如何快速体验 TiDB 分布式数据库。有以下 3 种体验方式供用户选择。 | ||
|
|
||
| > **警告:** | ||
| > | ||
| > 对于生产环境,不要使用本文介绍的方式进行部署,而应使用 [TiUP 部署 TiDB 集群](/how-to/deploy/orchestrated/tiup.md)。 | ||
|
|
||
| - [第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库](#第一种使用-tidb-wasm-一键体验-tidb-数据库) | ||
| - [第二种:使用 TiUP Playground 快速部署本地测试环境](#第二种使用-tiup-playground-快速部署本地测试环境) | ||
| - [第三种:使用 TiUP cluster 模拟单机下的准生产测试环境](#第三种使用-tiup-cluster-模拟单机下的准生产测试环境) | ||
|
|
||
| ## 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 | ||
|
|
||
| - 适用场景:初步极速体验 TiDB 数据库的语法、兼容性等基本功能 | ||
| - 耗时:即时体验 | ||
|
|
||
| TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用。TiDB-Wasm 可直接进行 SQL 执行、兼容性验证等基本操作。 | ||
|
|
||
| 试用 TiDB-Wasm 直接点击网址:[https://tour.pingcap.com](https://tour.pingcap.com),之后会在内存中构建 TiDB 数据库,预计耗时 10 秒左右。 | ||
|
|
||
| ## 第二种:使用 TiUP Playground 快速部署本地测试环境 | ||
|
|
||
| - 适用场景:利用本地 Mac 或者单机 Linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 TiDB、TiKV、PD、监控等基础组件的运行。 | ||
| - 耗时:1 分钟 | ||
|
|
||
| 作为一个分布式系统,最基础的 TiDB 测试集群通常由 2 个 TiDB 实例、3 个 TiKV 实例和 3 个 PD 实例来构成。通过 TiUP Playground,可以快速搭建出上述的一套基础测试集群。 | ||
|
|
||
| 1. 下载并安装 TiUP。 | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | ||
| ``` | ||
|
|
||
| 2. 声明全局环境变量。 | ||
|
|
||
| > **注意:** | ||
| > | ||
| > TiUP 安装完成会提示对应的 profile 文件的绝对路径,以下 source 操作需要根据实际位置进行操作。 | ||
|
|
||
| {< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| source .bash_profile | ||
| ``` | ||
|
|
||
| 3. 安装 TiUP Playground。 | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup install playground | ||
| ``` | ||
|
|
||
| 如果曾经安装过 TiUP Playground,则执行以下命令升级至最新版: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup update playground | ||
| ``` | ||
|
|
||
| 4. 在当前 session 执行以下命令启动集群。 | ||
|
|
||
| - 直接运行 `tiup playground` 命令会运行最新版本的 TiDB 集群,其中 TiDB、TiKV 和 PD 实例各 1 个: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup playground | ||
| ``` | ||
|
|
||
| - 也可以指定版本以及组件实例个数: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup playground v4.0.0-rc --db 2 --pd 3 --kv 3 --monitor | ||
| ``` | ||
|
|
||
| 上述命令会在本地下载并启动一个 v4.0.0-rc 版本的集群,`--monitor` 表示同时部署监控组件。运行结果将显示集群的访问方式: | ||
|
|
||
| ```log | ||
| CLUSTER START SUCCESSFULLY, Enjoy it ^-^ | ||
| To connect TiDB: mysql --host 127.0.0.1 --port 4000 -u root | ||
| To connect TiDB: mysql --host 127.0.0.1 --port 4001 -u root | ||
| To view the dashboard: http://127.0.0.1:2379/dashboard | ||
| To view the monitor: http://127.0.0.1:9090 | ||
| ``` | ||
|
|
||
| 5. 新开启一个 session 以访问 TiDB 数据库。 | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| mysql --host 127.0.0.1 --port 4000 -u root | ||
| ``` | ||
|
|
||
| 6. 通过 <http://127.0.0.1:9090> 访问 TiDB 的 Prometheus 管理界面。 | ||
|
|
||
| 7. 通过 <http://127.0.0.1:2379/dashboard> 访问 TiDB 的 Dashboard 页面,默认用户名为 root,密码为空。 | ||
|
|
||
| 8. 测试完成后清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行以下命令: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup clean --all | ||
| ``` | ||
|
|
||
| ## 第三种:使用 TiUP cluster 模拟单机下的准生产测试环境 | ||
|
|
||
| - 适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产的部署步骤。 | ||
| - 耗时:10 分钟 | ||
|
|
||
| 本节介绍如何参照 TiUP 最小拓扑的一个 YAML 文件部署 TiDB 集群。 | ||
|
|
||
| ### 准备环境 | ||
|
|
||
| 准备一台部署主机,确保其软件满足需求: | ||
|
|
||
| - 推荐安装 CentOS 7.3 及以上版本 | ||
| - Linux 操作系统开放外网访问,用于下载 TiDB 及相关软件安装包 | ||
|
|
||
| 最小规模的 TiDB 集群拓扑: | ||
|
|
||
| | 实例 | 个数 | IP | 配置 | | ||
| |:-- | :-- | :-- | :-- | | ||
| | TiKV | 3 | 10.0.1.1 <br> 10.0.1.1 <br> 10.0.1.1 | 避免端口和目录冲突 | | ||
| | TiDB | 1 | 10.0.1.1 | 默认端口 <br> 全局目录配置 | | ||
| | PD | 1 | 10.0.1.1 | 默认端口 <br> 全局目录配置 | | ||
| | TiFlash | 1 | 10.0.1.1 | 默认端口 <br> 全局目录配置 | | ||
| | Monitor | 1 | 10.0.1.1 | 默认端口 <br> 全局目录配置 | | ||
|
|
||
| 部署主机软件和环境要求: | ||
|
|
||
| - 部署需要使用部署主机的 root 用户及密码 | ||
| - 部署主机[关闭防火墙](/how-to/deploy/orchestrated/tiup.md#如何关闭部署机器的防火墙)或者开放 TiDB 集群的节点间所需端口 | ||
| - 目前 TiUP 仅支持在 x86_64 (AMD64) 架构上部署 TiDB 集群(TiUP 将在 4.0 GA 时支持在 ARM 架构上部署) | ||
| - 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 | ||
| - 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系操作步骤: | ||
|
|
||
| ### 实施部署 | ||
|
|
||
| > **注意:** | ||
| > | ||
| > 你可以使用 Linux 系统的任一普通用户或 root 用户登录主机,以下步骤以 root 用户为例。 | ||
|
|
||
| 1. 下载并安装 TiUP: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | ||
| ``` | ||
|
|
||
| 2. 安装 TiUP 的 cluster 组件: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup cluster | ||
| ``` | ||
|
|
||
| 3. 如果机器已经安装 TiUP cluster,需要更新软件版本: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup update cluster | ||
| ``` | ||
|
|
||
| 4. 由于模拟多机部署,需要通过 `root` 用户调大 sshd 服务的连接数限制: | ||
|
|
||
| 1. 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20。 | ||
| 2. 重启 sshd 服务: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| service sshd restart | ||
| ``` | ||
|
|
||
| 5. 创建并启动集群 | ||
|
|
||
| 按下面的配置模板,编辑配置文件,命名为 `topology.yaml`,其中: | ||
|
|
||
| - `user: "tidb"` 表示通过 `tidb` 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 | ||
yikeke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - 设置 `replication.enable-placement-rules` 这个 PD 参数来确保 TiFlash 正常运行 | ||
| - host 改为本部署主机的 IP | ||
yikeke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 配置模板如下: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```yaml | ||
| # # Global variables are applied to all deployments and as the default value of | ||
| # # them if the specific deployment value missing. | ||
|
|
||
| global: | ||
| user: "tidb" | ||
| ssh_port: 22 | ||
| deploy_dir: "/tidb-deploy" | ||
| data_dir: "/tidb-data" | ||
|
|
||
| # # Monitored variables are used to all the machine | ||
| monitored: | ||
| node_exporter_port: 9100 | ||
| blackbox_exporter_port: 9115 | ||
|
|
||
| server_configs: | ||
| tidb: | ||
| log.slow-threshold: 300 | ||
| tikv: | ||
| readpool.storage.use-unified-pool: true | ||
| readpool.coprocessor.use-unified-pool: true | ||
| pd: | ||
| replication.enable-placement-rules: true | ||
| tiflash: | ||
| logger.level: "info" | ||
|
|
||
| pd_servers: | ||
| - host: 10.0.1.1 | ||
|
|
||
| tidb_servers: | ||
| - host: 10.0.1.1 | ||
|
|
||
| tikv_servers: | ||
| - host: 10.0.1.1 | ||
| port: 20160 | ||
| status_port: 20180 | ||
|
|
||
| - host: 10.0.1.1 | ||
| port: 20161 | ||
| status_port: 20181 | ||
|
|
||
| - host: 10.0.1.1 | ||
| port: 20162 | ||
| status_port: 20182 | ||
|
|
||
| tiflash_servers: | ||
| - host: 10.0.1.1 | ||
|
|
||
| monitoring_servers: | ||
| - host: 10.0.1.1 | ||
|
|
||
| grafana_servers: | ||
| - host: 10.0.1.1 | ||
| ``` | ||
|
|
||
| 6. 执行集群部署命令: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup cluster deploy <cluster-name> <tidb-version> ./topo.yaml --user root | ||
| ``` | ||
|
|
||
| - 参数 `<cluster-name>` 表示设置集群名称 | ||
| - 参数 `<tidb-version>` 表示设置集群版本,可以通过 `tiup list tidb --refresh` 命令来选择当前支持部署的 TiDB 版本 | ||
|
|
||
| 按照引导,输入”y”及 root 密码,来完成部署: | ||
|
|
||
| ```log | ||
| Do you want to continue? [y/N]: y | ||
| Input SSH password: | ||
| ``` | ||
|
|
||
| 7. 启动集群: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup cluster start <cluster-name> | ||
| ``` | ||
|
|
||
| 8. 访问集群: | ||
|
|
||
| - 访问 TiDB 数据库,密码为空: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| mysql -h 10.0.1.1 -P 4000 -u root | ||
| ``` | ||
|
|
||
| - 访问 TiDB 的 Grafana 监控: | ||
|
|
||
| 通过 <http://{grafana-ip}:3000> 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。 | ||
|
|
||
| - 访问 TiDB 的 Dashboard: | ||
|
|
||
| 通过 <http://{pd-ip}:2379/dashboard> 访问集群 TiDB Dashboard 监控页面,默认用户名为 root,密码为空。 | ||
|
|
||
| - 执行以下命令确认当前已经部署的集群列表: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup cluster list | ||
| ``` | ||
|
|
||
| - 执行以下命令查看集群的拓扑结构和状态: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```shell | ||
| tiup cluster display <cluster-name> | ||
| ``` | ||
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.