From 392f030e9d6040ef0b4cd23b6a701534c8f3b353 Mon Sep 17 00:00:00 2001 From: superlzs0476 Date: Sun, 12 Apr 2020 13:47:32 +0800 Subject: [PATCH 01/28] Add gather_timeout parameter --- how-to/get-started/deploy-tidb-from-tiup.md | 211 ++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 how-to/get-started/deploy-tidb-from-tiup.md diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md new file mode 100644 index 000000000000..251408a68fea --- /dev/null +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -0,0 +1,211 @@ +--- +title: 使用 TiUP cluster 快速构建 TiDB 集群 +category: how-to +--- + +# 使用 TiUP cluster 快速构建 TiDB 集群 + +本文档介绍如何通过 TiUP 快速一键部署单机 TiDB 测试集群以及最小拓扑的 TiDB 集群。[TiUP 最小拓扑](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 可以通过一个 YAML 文件定义多个服务,然后一键部署、启动、停止、销毁。 + +> **警告:** +> +> 对于生产环境,不要使用 TiUP 单机版或者最小拓扑模版进行部署,而应使用 [TiUP 部署 TiDB 集群](/how-to/deploy/orchestrated/tiup.md)。 + +## 准备环境 + +确保你的主机(中控机或者单机搭建环境)的软件满足需求: + +- 推荐安装 CentOS 7.3 及以上版本 Linux 操作系统 +- 开放外网访问,用于下载 TiDB 及相关软件安装包 +- 安装 TiUP 组件 + +## 快速部署 + +1. 下载 `TiUP` + + {{< copyable "shell-regular" >}} + + ```bash + curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh + ``` + + 预期输出 + + ```shell + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 100 3418k 100 3418k 0 0 2878k 0 0:00:01 0:00:01 --:--:-- 2880k + Detected shell: /bin/bash + Shell profile: /home/tidb/.bash_profile + Installed path: /home/tidb/.tiup/bin/tiup + =============================================== + Have a try: tiup playground + =============================================== + ``` + +2. 声明全局环境变量 + + {{< copyable "shell-regular" >}} + + ```bash + source .bash_profile + ``` + +3. 在当前 session 启动集群 + + {{< copyable "shell-regular" >}} + + ```bash + tiup playground + ``` + +4. 创建新的会话来访问集群 + +- 访问 TiDB 数据库 + + {{< copyable "shell-regular" >}} + + ```bash + mysql -h 10.0.1.1 -P 4000 -u root + ``` + +- 访问 TiDB 的 Grafana 监控 + + 访问集群 Grafana 监控页面: 默认用户名和密码均为 admin。 + +- 访问 TiDB 的 Dashboard + + 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 + +## 部署最小规模的 TiDB 集群 + +- 部署集群信息 + +|实例 | 个数 | IP |配置 | +| :-- | :-- | :-- | :-- | :-- | +| TiKV | 3 | 10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | +| TiDB |1 | 10.0.1.1 | 默认端口
全局目录配置 | +| PD | 3 |10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | +| TiFlash | 1 | 10.0.1.2 | 默认端口
全局目录配置 | + +- 部署节点软件和环境要求 + + - 中控机可以使用部署节点的 root 用户或者具体 sudo 权限的用户的密钥或者密码可以直接 ssh 登陆; + + - 所有的机器关闭防火墙或者开放 TiDB 集群的节点间所需端口 + + - 目前 TiUP 仅支持在 x86_64 (AMD64) 架构上部署 TiDB 集群(TiUP 将在 4.0 GA 时支持在 ARM 架构上部署) + + - 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 + + - 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系统 + +1. 安装 TiUP 的 cluster 组件(TiUP 已经安装完成) + + {{< copyable "shell-regular" >}} + + ```bash + tiup cluster + ``` + +2. 如果已经安装 TiUP cluster 的机器更新软件版本 + + {{< copyable "shell-regular" >}} + + ```bash + tiup update cluster + ``` + +3. 创建并启动集群 + + - 复制[最小集群拓扑的 YAML](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 文件到目标机器,创建 topo.yaml 文件。 + + - 通过 tidb 用户部署集群(如部署前未创建,部署命令会自动创建),默认使用 22 端口通过 ssh 登陆目标机器,在 tidb 用户 `/home/tidb` 目录下面创建部署目录 `/home/tidb/deploy` 和数据目录 `/home/tidb/data`。 + + - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 + + - 所有节点服务均采用默认配置(包括:端口、目录、参数文件)。 + + {{< copyable "shell-regular" >}} + + ```yaml + # The topology template is used deploy a minimal TiDB cluster, which suitable + # for scenarios with only three machinescontains. The minimal cluster contains + # - 3 PD nodes + # - 3 TiKV nodes + # - 1 TiDB nodes + # You can change the hosts according your environment + + global: + user: "tidb" + ssh_port: 22 + deploy_dir: "deploy" + data_dir: "data" + + server_configs: + pd: + replication.enable-placement-rules: true + + pd_servers: + - host: 10.0.1.1 + - host: 10.0.1.2 + - host: 10.0.1.2 + + tikv_servers: + - host: 10.0.1.1 + - host: 10.0.1.2 + - host: 10.0.1.3 + + tidb_servers: + - host: 10.0.1.1 + + tiflash_servers: + - host: 10.0.1.2 + + monitoring_servers: + - host: 10.0.1.3 + + grafana_servers: + - host: 10.0.1.3 + + alertmanager_servers: + - host: 10.0.1.3 + ``` + +4. 部署集群 + + - 设置集群名称,可以通过 `tiup cluster list` 命令来确认当前已经部署的集群信息。 + - 设置部署集群的 TiDB 版本,可以通过 `tiup list tidb --refresh` 命令来确认当前支持部署的 TiDB 版本情况。 + - 设置密钥登陆,如果使用密码登陆,可以去掉 `-i` 配置,`Entered` 可以直接进入密码交互窗口。 + + {{< copyable "shell-regular" >}} + + ```bash + tiup cluster deploy ./topo.yaml --user root -i + ``` + +5. 启动集群 + + {{< copyable "shell-regular" >}} + + ```bash + tiup cluster start + ``` + +6. 访问集群 + +- 访问 TiDB 数据库 + + {{< copyable "shell-regular" >}} + + ```bash + mysql -h 10.0.1.1 -P 4000 -u root + ``` + +- 访问 TiDB 的 Grafana 监控 + + 访问集群 Grafana 监控页面: 默认用户名和密码均为 admin。 + +- 访问 TiDB 的 Dashboard + + 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 \ No newline at end of file From bf098af7411f0d35812c50a91d9a46596ba68903 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Sun, 12 Apr 2020 13:54:56 +0800 Subject: [PATCH 02/28] fix some details --- how-to/get-started/deploy-tidb-from-tiup.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 251408a68fea..fc5660fd591e 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -5,7 +5,7 @@ category: how-to # 使用 TiUP cluster 快速构建 TiDB 集群 -本文档介绍如何通过 TiUP 快速一键部署单机 TiDB 测试集群以及最小拓扑的 TiDB 集群。[TiUP 最小拓扑](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 可以通过一个 YAML 文件定义多个服务,然后一键部署、启动、停止、销毁。 +本文档介绍如何通过 TiUP 快速一键部署单机 TiDB 测试集群以及最小拓扑的 TiDB 集群。[TiUP 最小拓扑](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 可以通过一个 YAML 文件定义多个服务,然后一键部署. > **警告:** > @@ -82,7 +82,7 @@ category: how-to - 部署集群信息 |实例 | 个数 | IP |配置 | -| :-- | :-- | :-- | :-- | :-- | +| :-- | :-- | :-- | :-- | | TiKV | 3 | 10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | | TiDB |1 | 10.0.1.1 | 默认端口
全局目录配置 | | PD | 3 |10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | @@ -118,7 +118,7 @@ category: how-to 3. 创建并启动集群 - - 复制[最小集群拓扑的 YAML](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 文件到目标机器,创建 topo.yaml 文件。 + - 复制[最小集群拓扑的 YAML](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 文件到中控机,创建 topo.yaml 文件。 - 通过 tidb 用户部署集群(如部署前未创建,部署命令会自动创建),默认使用 22 端口通过 ssh 登陆目标机器,在 tidb 用户 `/home/tidb` 目录下面创建部署目录 `/home/tidb/deploy` 和数据目录 `/home/tidb/data`。 @@ -174,9 +174,9 @@ category: how-to 4. 部署集群 - - 设置集群名称,可以通过 `tiup cluster list` 命令来确认当前已经部署的集群信息。 - - 设置部署集群的 TiDB 版本,可以通过 `tiup list tidb --refresh` 命令来确认当前支持部署的 TiDB 版本情况。 - - 设置密钥登陆,如果使用密码登陆,可以去掉 `-i` 配置,`Entered` 可以直接进入密码交互窗口。 + - `` 设置集群名称,可以通过 `tiup cluster list` 命令来确认当前已经部署的集群信息。 + - `` 设置部署集群的 TiDB 版本,可以通过 `tiup list tidb --refresh` 命令来确认当前支持部署的 TiDB 版本情况。 + - `` 设置密钥登陆,如果使用密码登陆,可以去掉 `-i` 配置,`Entered` 可以直接进入密码交互窗口。 {{< copyable "shell-regular" >}} @@ -208,4 +208,4 @@ category: how-to - 访问 TiDB 的 Dashboard - 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 \ No newline at end of file + 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 From 0012ac4d956ed3f5a6a9cd639ba33341e3d1ab5c Mon Sep 17 00:00:00 2001 From: superlzs0476 Date: Wed, 15 Apr 2020 11:10:37 +0800 Subject: [PATCH 03/28] Add getstart for tiup --- how-to/get-started/deploy-tidb-from-tiup.md | 383 ++++++++++++-------- 1 file changed, 240 insertions(+), 143 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index fc5660fd591e..47e93ad55dde 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -3,209 +3,306 @@ title: 使用 TiUP cluster 快速构建 TiDB 集群 category: how-to --- -# 使用 TiUP cluster 快速构建 TiDB 集群 +本文档介绍如何快速地体验 TiDB 分布式数据库。有以下 3 种体验方式供用户选择。 -本文档介绍如何通过 TiUP 快速一键部署单机 TiDB 测试集群以及最小拓扑的 TiDB 集群。[TiUP 最小拓扑](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 可以通过一个 YAML 文件定义多个服务,然后一键部署. +- 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 +- 第二种:使用 TiUP Playground 快速部署本地测试环境 +- 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 -> **警告:** -> -> 对于生产环境,不要使用 TiUP 单机版或者最小拓扑模版进行部署,而应使用 [TiUP 部署 TiDB 集群](/how-to/deploy/orchestrated/tiup.md)。 +> **警告:** 对于生产环境,不要使用本文档介绍的方式进行部署,而应使用 TiUP 部署 TiDB 集群。 -## 准备环境 +# 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 + +- 适用场景:初步极速体验 TiDB 数据库的语法、兼容性等基本功能 +- 耗时:即时体验 + +TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用。TiDB-Wasm 可直接进行 SQL 执行、兼容性验证等基本功能。 -确保你的主机(中控机或者单机搭建环境)的软件满足需求: +试用请点击网址:[https://tour.pingcap.com](https://tour.pingcap.com),之后会在内存中构建 TiDB 数据库,预计消耗 10s 左右时间。 -- 推荐安装 CentOS 7.3 及以上版本 Linux 操作系统 -- 开放外网访问,用于下载 TiDB 及相关软件安装包 -- 安装 TiUP 组件 -## 快速部署 +# 第二种:使用 TiUP Playground 快速部署本地测试环境 -1. 下载 `TiUP` +- 适用场景:利用本地 mac 或者单机 linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 tidb/tikv/pd/监控等基础组件的运行。 +- 耗时:1 分钟 - {{< copyable "shell-regular" >}} +作为一个分布式系统,最基础的 TiDB 测试集群通常由 2 个 TiDB 组件、3 个 TiKV 组件和 3 个 PD 组件来构成。通过 TiUP Playground,可以快速搭建出上述的一套基础测试集群。 - ```bash - curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh - ``` +1. 下载并安装 TiUP - 预期输出 +{{< copyable "shell-regular" >}} - ```shell - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed - 100 3418k 100 3418k 0 0 2878k 0 0:00:01 0:00:01 --:--:-- 2880k - Detected shell: /bin/bash - Shell profile: /home/tidb/.bash_profile - Installed path: /home/tidb/.tiup/bin/tiup - =============================================== - Have a try: tiup playground - =============================================== - ``` +```shell +curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh +``` 2. 声明全局环境变量 - {{< copyable "shell-regular" >}} +{{< copyable "shell-regular" >}} - ```bash - source .bash_profile - ``` +```shell +source .bash_profile +``` -3. 在当前 session 启动集群 +3. 安装 Playground + +{{< copyable "shell-regular" >}} - {{< copyable "shell-regular" >}} +```shell +tiup install playground +``` + +- 如果曾经安装过,请升级至最新版 + +{{< copyable "shell-regular" >}} - ```bash - tiup playground - ``` +```shell +tiup update playground` +``` -4. 创建新的会话来访问集群 +4. 在当前 session 启动集群 -- 访问 TiDB 数据库 +- 直接运行 tiup playground 会运行最新版本的 TiDB 集群,其中组件 tidb/tikv/pd 各 1 个。 - {{< copyable "shell-regular" >}} +{{< copyable "shell-regular" >}} - ```bash - mysql -h 10.0.1.1 -P 4000 -u root - ``` +```shell +tiup playground +``` -- 访问 TiDB 的 Grafana 监控 +- 也可以指定版本以及组件个数 - 访问集群 Grafana 监控页面: 默认用户名和密码均为 admin。 +{{< copyable "shell-regular" >}} -- 访问 TiDB 的 Dashboard - - 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 +```shell +tiup playground v4.0.0-rc --db 2 --pd 3 --kv 3 --monitor +``` -## 部署最小规模的 TiDB 集群 +会在本地下载并启动一个 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 +``` -|实例 | 个数 | IP |配置 | -| :-- | :-- | :-- | :-- | -| TiKV | 3 | 10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | -| TiDB |1 | 10.0.1.1 | 默认端口
全局目录配置 | -| PD | 3 |10.0.1.1
10.0.1.2
10.0.1.3 | 默认端口
全局目录配置 | -| TiFlash | 1 | 10.0.1.2 | 默认端口
全局目录配置 | +5. 新开启 session 访问 TiDB 数据库 -- 部署节点软件和环境要求 +{{< copyable "shell-regular" >}} - - 中控机可以使用部署节点的 root 用户或者具体 sudo 权限的用户的密钥或者密码可以直接 ssh 登陆; +```shell +mysql --host 127.0.0.1 --port 4000 -u root +``` - - 所有的机器关闭防火墙或者开放 TiDB 集群的节点间所需端口 +6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:9090 默认用户名和密码均为 admin。 - - 目前 TiUP 仅支持在 x86_64 (AMD64) 架构上部署 TiDB 集群(TiUP 将在 4.0 GA 时支持在 ARM 架构上部署) +7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 - - 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 +8. 测试完成,清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行 - - 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系统 +{{< copyable "shell-regular" >}} -1. 安装 TiUP 的 cluster 组件(TiUP 已经安装完成) +```shell +tiup clean --all +``` - {{< copyable "shell-regular" >}} +# 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 - ```bash - tiup cluster - ``` +- 适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产的部署步骤。 +- 耗时:10 分钟 -2. 如果已经安装 TiUP cluster 的机器更新软件版本 +本文档介绍如何参照 TiUP 最小拓扑 的一个 YAML 文件部署 TiDB 集群。 - {{< copyable "shell-regular" >}} +## 准备环境 - ```bash - tiup update cluster - ``` +准备一台部署主机,确保其软件满足需求: -3. 创建并启动集群 +- 推荐安装 CentOS 7.3 及以上版本 +- Linux 操作系统开放外网访问,用于下载 TiDB 及相关软件安装包 - - 复制[最小集群拓扑的 YAML](https://github.com/pingcap-incubator/tiup-cluster/blob/master/examples/minimal.yaml) 文件到中控机,创建 topo.yaml 文件。 +最小规模的 TiDB 集群拓扑 - - 通过 tidb 用户部署集群(如部署前未创建,部署命令会自动创建),默认使用 22 端口通过 ssh 登陆目标机器,在 tidb 用户 `/home/tidb` 目录下面创建部署目录 `/home/tidb/deploy` 和数据目录 `/home/tidb/data`。 +| 实例 | 个数 | IP | 配置 | +|:-- | :-- | :-- | :-- | +| TiKV | 3 | 10.0.1.1
10.0.1.1
10.0.1.1 | 避免端口和目录冲突 | +| TiDB | 1 | 10.0.1.1 | 默认端口
全局目录配置 | +| PD | 1 | 10.0.1.1 | | +| TiFlash | 1 | 10.0.1.1 | | +| Monitor | 1 | 10.0.1.1 | | - - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 +部署主机软件和环境要求 - - 所有节点服务均采用默认配置(包括:端口、目录、参数文件)。 +- 部署需要使用部署主机的 root 用户及密码 +- 部署主机关闭防火墙或者开放 TiDB 集群的节点间所需端口 +- 目前 TiUP 仅支持在 x86_64 (AMD64) 架构上部署 TiDB 集群(TiUP 将在 4.0 GA 时支持在 ARM 架构上部署) + - 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 + - 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系操作步骤: + +## 实施部署 + +1. 以下步骤使用 linux 系统的任一普通用户或 root 用户,以 root 用户为例 + +2. 下载并安装 TiUP + + +{{< copyable "shell-regular" >}} + +```shell +curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh +``` + +3. 安装 TiUP 的 cluster 组件 + +{{< copyable "shell-regular" >}} + +```shell +tiup cluster +``` + +4. 如果已经安装 TiUP cluster 的机器更新软件版本 + +{{< copyable "shell-regular" >}} + +```shell +tiup update cluster +``` - {{< copyable "shell-regular" >}} +5. 由于模拟多机部署,需要通过 `root` 用户调大 sshd 服务的连接数限制 + +- 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20 +- 重启 sshd 服务 + +{{< copyable "shell-regular" >}} - ```yaml - # The topology template is used deploy a minimal TiDB cluster, which suitable - # for scenarios with only three machinescontains. The minimal cluster contains - # - 3 PD nodes - # - 3 TiKV nodes - # - 1 TiDB nodes - # You can change the hosts according your environment - - global: - user: "tidb" - ssh_port: 22 - deploy_dir: "deploy" - data_dir: "data" - - server_configs: - pd: - replication.enable-placement-rules: true +```shell +service sshd restart +``` - pd_servers: - - host: 10.0.1.1 - - host: 10.0.1.2 - - host: 10.0.1.2 - - tikv_servers: - - host: 10.0.1.1 - - host: 10.0.1.2 - - host: 10.0.1.3 - - tidb_servers: - - host: 10.0.1.1 - - tiflash_servers: - - host: 10.0.1.2 +6. 创建并启动集群 - monitoring_servers: - - host: 10.0.1.3 - - grafana_servers: - - host: 10.0.1.3 - - alertmanager_servers: - - host: 10.0.1.3 - ``` - -4. 部署集群 +- 按下面的配置模板,编辑配置文件,命名为 topo.yaml ,其中: - - `` 设置集群名称,可以通过 `tiup cluster list` 命令来确认当前已经部署的集群信息。 - - `` 设置部署集群的 TiDB 版本,可以通过 `tiup list tidb --refresh` 命令来确认当前支持部署的 TiDB 版本情况。 - - `` 设置密钥登陆,如果使用密码登陆,可以去掉 `-i` 配置,`Entered` 可以直接进入密码交互窗口。 + - `user: "tidb"` 表示通过 tidb 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 - {{< copyable "shell-regular" >}} + - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 - ```bash - tiup cluster deploy ./topo.yaml --user root -i - ``` + - host 改为本部署主机的 IP -5. 启动集群 +{{< copyable "shell-regular" >}} - {{< 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 +``` + +7. 执行部署集群 + +{{< copyable "shell-regular" >}} + +```shell +tiup cluster deploy ./topo.yaml --user root +``` + +- 设置集群名称 +- 设置部署的 TiDB 集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 + +按照引导,输入”y” 及 root 密码,来完成部署 + +```log +Do you want to continue? [y/N]: y +Input SSH password: +``` + +8. 启动集群 + +{{< copyable "shell-regular" >}} + +```shell +tiup cluster start +``` + +9. 访问集群 + +- 访问 TiDB 数据库,密码为空 + + {{< copyable "shell-regular" >}} + + ```shell + mysql -h 10.0.1.1 -P 4000 -u root + ``` - ```bash - tiup cluster start - ``` +- 访问 TiDB 的 Grafana 监控 -6. 访问集群 + 访问集群 Grafana 监控页面:http://{grafana-ip}:3000 默认用户名和密码均为 admin。 -- 访问 TiDB 数据库 +- 访问 TiDB 的 Dashboard - {{< copyable "shell-regular" >}} + 访问集群 TiDB-Dashboard 监控页面:http://{pd-ip}:2379/dashboard 默认用户名 root 密码为空。 - ```bash - mysql -h 10.0.1.1 -P 4000 -u root - ``` +- 通过 `tiup cluster list` 命令来确认当前已经部署的集群列表 -- 访问 TiDB 的 Grafana 监控 + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster list + ``` - 访问集群 Grafana 监控页面: 默认用户名和密码均为 admin。 +- `tiup cluster display ` 来查看集群的拓扑结构和状态 -- 访问 TiDB 的 Dashboard + {{< copyable "shell-regular" >}} - 访问集群 TiDB-Dashboard 监控页面: 默认用户名 root 密码为空。 + ```shell + tiup cluster display + ``` From 3ec7b6cb301c12ac7dc7d2da3951ebfbaa6edae2 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 11:30:02 +0800 Subject: [PATCH 04/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 47e93ad55dde..65abd7af4619 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -256,7 +256,7 @@ tiup cluster deploy ./topo.yaml --user root ``` - 设置集群名称 -- 设置部署的 TiDB 集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 +- 参数 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 按照引导,输入”y” 及 root 密码,来完成部署 From 12ea907daa138b25ebee0f38eccccf6cf54a8406 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 11:30:10 +0800 Subject: [PATCH 05/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 65abd7af4619..3e60154e5797 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -255,7 +255,7 @@ grafana_servers: tiup cluster deploy ./topo.yaml --user root ``` -- 设置集群名称 +- 参数 表示设置集群名称 - 参数 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 按照引导,输入”y” 及 root 密码,来完成部署 From 41db2fb532540b2862d3be5ae6cbe71b46d7f5f5 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 11:30:59 +0800 Subject: [PATCH 06/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 3e60154e5797..32e7345e49bb 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -255,7 +255,7 @@ grafana_servers: tiup cluster deploy ./topo.yaml --user root ``` -- 参数 表示设置集群名称 +- 参数 `` 表示设置集群名称 - 参数 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 按照引导,输入”y” 及 root 密码,来完成部署 From 6734e403c1fb60a7c5d087dd438224bc9fe4feb4 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 11:31:31 +0800 Subject: [PATCH 07/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 32e7345e49bb..342af86dd556 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -256,7 +256,7 @@ tiup cluster deploy ./topo.yaml --user root ``` - 参数 `` 表示设置集群名称 -- 参数 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 +- 参数 `` 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 按照引导,输入”y” 及 root 密码,来完成部署 From a57fb8c5d75797a624508f7cc4afd6eec6c99bc2 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 11:32:48 +0800 Subject: [PATCH 08/28] Update deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 342af86dd556..7ae7f2204513 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -128,9 +128,9 @@ tiup clean --all |:-- | :-- | :-- | :-- | | TiKV | 3 | 10.0.1.1
10.0.1.1
10.0.1.1 | 避免端口和目录冲突 | | TiDB | 1 | 10.0.1.1 | 默认端口
全局目录配置 | -| PD | 1 | 10.0.1.1 | | -| TiFlash | 1 | 10.0.1.1 | | -| Monitor | 1 | 10.0.1.1 | | +| PD | 1 | 10.0.1.1 | 默认端口
全局目录配置 | +| TiFlash | 1 | 10.0.1.1 | 默认端口
全局目录配置 | +| Monitor | 1 | 10.0.1.1 | 默认端口
全局目录配置 | 部署主机软件和环境要求 From 51ed68f29041610466a3ede0e423c433ef29e634 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 16:29:41 +0800 Subject: [PATCH 09/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 7ae7f2204513..c321c2b434d2 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -1,5 +1,5 @@ --- -title: 使用 TiUP cluster 快速构建 TiDB 集群 +title: 如何快速体验 TiDB 集群 category: how-to --- From 58a1fa59f874661e79b2eaf27a6e0ea5ea822667 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 16:31:19 +0800 Subject: [PATCH 10/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index c321c2b434d2..fcd8e79f4b16 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -3,6 +3,8 @@ title: 如何快速体验 TiDB 集群 category: how-to --- +# 使用 TiUP cluster 快速构建 TiDB 集群 + 本文档介绍如何快速地体验 TiDB 分布式数据库。有以下 3 种体验方式供用户选择。 - 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 From b6dc73d44f7ec256ce988e1319bf0e73fc6a8f2c Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 16:42:29 +0800 Subject: [PATCH 11/28] Update deploy-tidb-from-tiup.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整格式和标题 --- how-to/get-started/deploy-tidb-from-tiup.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index fcd8e79f4b16..9578e361fd05 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -3,7 +3,7 @@ title: 如何快速体验 TiDB 集群 category: how-to --- -# 使用 TiUP cluster 快速构建 TiDB 集群 +# 如何快速体验 TiDB 集群 本文档介绍如何快速地体验 TiDB 分布式数据库。有以下 3 种体验方式供用户选择。 @@ -13,7 +13,7 @@ category: how-to > **警告:** 对于生产环境,不要使用本文档介绍的方式进行部署,而应使用 TiUP 部署 TiDB 集群。 -# 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 +## 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 - 适用场景:初步极速体验 TiDB 数据库的语法、兼容性等基本功能 - 耗时:即时体验 @@ -23,7 +23,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 试用请点击网址:[https://tour.pingcap.com](https://tour.pingcap.com),之后会在内存中构建 TiDB 数据库,预计消耗 10s 左右时间。 -# 第二种:使用 TiUP Playground 快速部署本地测试环境 +## 第二种:使用 TiUP Playground 快速部署本地测试环境 - 适用场景:利用本地 mac 或者单机 linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 tidb/tikv/pd/监控等基础组件的运行。 - 耗时:1 分钟 @@ -110,14 +110,14 @@ mysql --host 127.0.0.1 --port 4000 -u root tiup clean --all ``` -# 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 +## 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 - 适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产的部署步骤。 - 耗时:10 分钟 本文档介绍如何参照 TiUP 最小拓扑 的一个 YAML 文件部署 TiDB 集群。 -## 准备环境 +### 准备环境 准备一台部署主机,确保其软件满足需求: @@ -142,7 +142,7 @@ tiup clean --all - 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 - 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系操作步骤: -## 实施部署 +### 实施部署 1. 以下步骤使用 linux 系统的任一普通用户或 root 用户,以 root 用户为例 From c4d8c719ae8222f11820f8dfcf84440cf14b64de Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 16:53:49 +0800 Subject: [PATCH 12/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: kissmydb --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 9578e361fd05..b46bc0f2bde9 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -11,7 +11,7 @@ category: how-to - 第二种:使用 TiUP Playground 快速部署本地测试环境 - 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 -> **警告:** 对于生产环境,不要使用本文档介绍的方式进行部署,而应使用 TiUP 部署 TiDB 集群。 +> **警告:** 对于生产环境,不要使用本文档介绍的方式进行部署,而应使用 [TiUP 部署 TiDB 集群](https://pingcap.com/docs-cn/stable/how-to/deploy/orchestrated/tiup/)。 ## 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 From 88594219d7705547098947917e2f5b4db8eb7819 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 16:59:50 +0800 Subject: [PATCH 13/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index b46bc0f2bde9..cbeb11a9c067 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -59,7 +59,7 @@ tiup install playground {{< copyable "shell-regular" >}} ```shell -tiup update playground` +tiup update playground ``` 4. 在当前 session 启动集群 From 0ffcc5e8006e02679b25d3cf3fa5c5a5b6f3139a Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:06:43 +0800 Subject: [PATCH 14/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index cbeb11a9c067..2e390cbb6478 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -40,6 +40,8 @@ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh 2. 声明全局环境变量 +> **建议:** TiUP 安装完成会提示对应的 profile 文件的绝对路径,source 操作请根据实际位置进行操作。 + {{< copyable "shell-regular" >}} ```shell From 39edf72a79bac1b0066ee68710cda989f7e4c906 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:16:39 +0800 Subject: [PATCH 15/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 2e390cbb6478..d9248f52d364 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -100,7 +100,7 @@ To view the monitor: http://127.0.0.1:9090 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:9090 默认用户名和密码均为 admin。 +6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:3000 默认用户名和密码均为 admin。 7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 From 2900b38f350ed8dd8cac2d6bcd96925d8c444f55 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:25:37 +0800 Subject: [PATCH 16/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index d9248f52d364..b468cb503d79 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -100,7 +100,7 @@ To view the monitor: http://127.0.0.1:9090 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:3000 默认用户名和密码均为 admin。 +6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1: 9090 默认用户名和密码均为 admin。 7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 From a3840dfdc5c40e1325cfae74b36ff8304a3d4205 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:26:14 +0800 Subject: [PATCH 17/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index b468cb503d79..2e390cbb6478 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -100,7 +100,7 @@ To view the monitor: http://127.0.0.1:9090 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1: 9090 默认用户名和密码均为 admin。 +6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:9090 默认用户名和密码均为 admin。 7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 From 784fa3aee6a9127e11e26f5f24b76cca3fca4a72 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:59:57 +0800 Subject: [PATCH 18/28] Update how-to/get-started/deploy-tidb-from-tiup.md --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 2e390cbb6478..a6e3542bce11 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -100,7 +100,7 @@ To view the monitor: http://127.0.0.1:9090 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 访问 TiDB 的 Grafana 监控:http://127.0.0.1:9090 默认用户名和密码均为 admin。 +6. 访问 TiDB 的 Prometheus 管理界面:http://127.0.0.1:9090 7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 From 8a523b2145862ca479741ab46379245f9014f4bc Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 20:17:36 +0800 Subject: [PATCH 19/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index a6e3542bce11..62a1515bcddf 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -11,7 +11,9 @@ category: how-to - 第二种:使用 TiUP Playground 快速部署本地测试环境 - 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 -> **警告:** 对于生产环境,不要使用本文档介绍的方式进行部署,而应使用 [TiUP 部署 TiDB 集群](https://pingcap.com/docs-cn/stable/how-to/deploy/orchestrated/tiup/)。 +> **警告:** +> +> 对于生产环境,不要使用本文介绍的方式进行部署,而应使用 [TiUP 部署 TiDB 集群](/how-to/deploy/orchestrated/tiup.md)。 ## 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 From ae47008a9accc92d1fd396ec3695e18325844026 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 20:17:52 +0800 Subject: [PATCH 20/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 1 - 1 file changed, 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 62a1515bcddf..fe160cf5116c 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -24,7 +24,6 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 试用请点击网址:[https://tour.pingcap.com](https://tour.pingcap.com),之后会在内存中构建 TiDB 数据库,预计消耗 10s 左右时间。 - ## 第二种:使用 TiUP Playground 快速部署本地测试环境 - 适用场景:利用本地 mac 或者单机 linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 tidb/tikv/pd/监控等基础组件的运行。 From 4717c39229b44c2e349261b88af75f7190715437 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 20:18:15 +0800 Subject: [PATCH 21/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index fe160cf5116c..b8f583e7e53f 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -26,7 +26,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 ## 第二种:使用 TiUP Playground 快速部署本地测试环境 -- 适用场景:利用本地 mac 或者单机 linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 tidb/tikv/pd/监控等基础组件的运行。 +- 适用场景:利用本地 Mac 或者单机 Linux 环境快速部署 TiDB 集群。可以体验 TiDB 集群的基本架构,以及 TiDB、TiKV、PD、监控等基础组件的运行。 - 耗时:1 分钟 作为一个分布式系统,最基础的 TiDB 测试集群通常由 2 个 TiDB 组件、3 个 TiKV 组件和 3 个 PD 组件来构成。通过 TiUP Playground,可以快速搭建出上述的一套基础测试集群。 From 565ee8c41e29634c63d569ea057561266df69977 Mon Sep 17 00:00:00 2001 From: kissmydb Date: Wed, 15 Apr 2020 20:24:46 +0800 Subject: [PATCH 22/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index b8f583e7e53f..ea7a9f3e8355 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -41,7 +41,9 @@ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh 2. 声明全局环境变量 -> **建议:** TiUP 安装完成会提示对应的 profile 文件的绝对路径,source 操作请根据实际位置进行操作。 + > **建议:** + > + > TiUP 安装完成会提示对应的 profile 文件的绝对路径,source 操作请根据实际位置进行操作。 {{< copyable "shell-regular" >}} From 97f2b017aeaa0fadaf731a519253a38a5e1eff34 Mon Sep 17 00:00:00 2001 From: superlzs0476 Date: Wed, 15 Apr 2020 21:00:35 +0800 Subject: [PATCH 23/28] Add getstart for tiup --- how-to/get-started/deploy-tidb-from-tiup.md | 361 ++++++++++---------- 1 file changed, 180 insertions(+), 181 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index ea7a9f3e8355..febcdbf5e186 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -33,11 +33,11 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 1. 下载并安装 TiUP -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh -``` + ```shell + curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh + ``` 2. 声明全局环境变量 @@ -45,63 +45,63 @@ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh > > TiUP 安装完成会提示对应的 profile 文件的绝对路径,source 操作请根据实际位置进行操作。 -{{< copyable "shell-regular" >}} + {< copyable "shell-regular" >}} -```shell -source .bash_profile -``` + ```shell + source .bash_profile + ``` 3. 安装 Playground -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup install playground -``` + ```shell + tiup install playground + ``` -- 如果曾经安装过,请升级至最新版 + - 如果曾经安装过,请升级至最新版 -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup update playground -``` + ```shell + tiup update playground + ``` 4. 在当前 session 启动集群 -- 直接运行 tiup playground 会运行最新版本的 TiDB 集群,其中组件 tidb/tikv/pd 各 1 个。 + - 直接运行 tiup playground 会运行最新版本的 TiDB 集群,其中组件 tidb/tikv/pd 各 1 个。 -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup playground -``` + ```shell + tiup playground + ``` -- 也可以指定版本以及组件个数 + - 也可以指定版本以及组件个数 -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup playground v4.0.0-rc --db 2 --pd 3 --kv 3 --monitor -``` + ```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 -``` + 会在本地下载并启动一个 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" >}} + {{< copyable "shell-regular" >}} -```shell -mysql --host 127.0.0.1 --port 4000 -u root -``` + ```shell + mysql --host 127.0.0.1 --port 4000 -u root + ``` 6. 访问 TiDB 的 Prometheus 管理界面:http://127.0.0.1:9090 @@ -109,11 +109,11 @@ mysql --host 127.0.0.1 --port 4000 -u root 8. 测试完成,清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行 -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup clean --all -``` + ```shell + tiup clean --all + ``` ## 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 @@ -153,163 +153,162 @@ tiup clean --all 2. 下载并安装 TiUP + {{< copyable "shell-regular" >}} -{{< copyable "shell-regular" >}} - -```shell -curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh -``` + ```shell + curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh + ``` 3. 安装 TiUP 的 cluster 组件 -{{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} -```shell -tiup cluster -``` + ```shell + tiup cluster + ``` 4. 如果已经安装 TiUP cluster 的机器更新软件版本 -{{< copyable "shell-regular" >}} - -```shell -tiup update cluster -``` + {{< copyable "shell-regular" >}} + + ```shell + tiup update cluster + ``` 5. 由于模拟多机部署,需要通过 `root` 用户调大 sshd 服务的连接数限制 -- 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20 -- 重启 sshd 服务 + - 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20 + - 重启 sshd 服务 -{{< copyable "shell-regular" >}} - -```shell -service sshd restart -``` + {{< copyable "shell-regular" >}} + + ```shell + service sshd restart + ``` 6. 创建并启动集群 -- 按下面的配置模板,编辑配置文件,命名为 topo.yaml ,其中: - - - `user: "tidb"` 表示通过 tidb 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 - - - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 - - - host 改为本部署主机的 IP - -{{< 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 -``` - + - 按下面的配置模板,编辑配置文件,命名为 topo.yaml ,其中: + + - `user: "tidb"` 表示通过 tidb 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 + + - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 + + - host 改为本部署主机的 IP + + {{< 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 + ``` + 7. 执行部署集群 -{{< copyable "shell-regular" >}} - -```shell -tiup cluster deploy ./topo.yaml --user root -``` - -- 参数 `` 表示设置集群名称 -- 参数 `` 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 - -按照引导,输入”y” 及 root 密码,来完成部署 - -```log -Do you want to continue? [y/N]: y -Input SSH password: -``` + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster deploy ./topo.yaml --user root + ``` + + - 参数 `` 表示设置集群名称 + - 参数 `` 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 + + 按照引导,输入”y” 及 root 密码,来完成部署 + + ```log + Do you want to continue? [y/N]: y + Input SSH password: + ``` 8. 启动集群 -{{< copyable "shell-regular" >}} - -```shell -tiup cluster start -``` + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster start + ``` 9. 访问集群 -- 访问 TiDB 数据库,密码为空 - - {{< copyable "shell-regular" >}} - - ```shell - mysql -h 10.0.1.1 -P 4000 -u root - ``` - -- 访问 TiDB 的 Grafana 监控 - - 访问集群 Grafana 监控页面:http://{grafana-ip}:3000 默认用户名和密码均为 admin。 - -- 访问 TiDB 的 Dashboard - - 访问集群 TiDB-Dashboard 监控页面:http://{pd-ip}:2379/dashboard 默认用户名 root 密码为空。 - -- 通过 `tiup cluster list` 命令来确认当前已经部署的集群列表 - - {{< copyable "shell-regular" >}} - - ```shell - tiup cluster list - ``` - -- `tiup cluster display ` 来查看集群的拓扑结构和状态 - - {{< copyable "shell-regular" >}} - - ```shell - tiup cluster display - ``` + - 访问 TiDB 数据库,密码为空 + + {{< copyable "shell-regular" >}} + + ```shell + mysql -h 10.0.1.1 -P 4000 -u root + ``` + + - 访问 TiDB 的 Grafana 监控 + + 访问集群 Grafana 监控页面:http://{grafana-ip}:3000 默认用户名和密码均为 admin。 + + - 访问 TiDB 的 Dashboard + + 访问集群 TiDB-Dashboard 监控页面:http://{pd-ip}:2379/dashboard 默认用户名 root 密码为空。 + + - 通过 `tiup cluster list` 命令来确认当前已经部署的集群列表 + + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster list + ``` + + - `tiup cluster display ` 来查看集群的拓扑结构和状态 + + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster display + ``` \ No newline at end of file From f24d09f9b859c29f5d2916276e33530e0da1e454 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 21:07:54 +0800 Subject: [PATCH 24/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index febcdbf5e186..aca5600ab493 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -103,7 +103,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 访问 TiDB 的 Prometheus 管理界面:http://127.0.0.1:9090 +6. 通过 访问 TiDB 的 Prometheus 管理界面 7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 @@ -311,4 +311,4 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 ```shell tiup cluster display - ``` \ No newline at end of file + ``` From 9901d4b0908973cc19cb8af7e916e44f415e8ede Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 21:08:08 +0800 Subject: [PATCH 25/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index aca5600ab493..b1a52b226327 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -291,7 +291,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 - 访问 TiDB 的 Grafana 监控 - 访问集群 Grafana 监控页面:http://{grafana-ip}:3000 默认用户名和密码均为 admin。 + 通过 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。 - 访问 TiDB 的 Dashboard From 847eac976cbba12b2b9300bb216391671ad13340 Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 21:08:39 +0800 Subject: [PATCH 26/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index b1a52b226327..6b3c83659688 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -105,7 +105,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 6. 通过 访问 TiDB 的 Prometheus 管理界面 -7. 访问 TiDB 的 Dashboard 页面:http://127.0.0.1:2379/dashboard 默认用户名 root 密码为空。 +7. 通过 访问 TiDB 的 Dashboard 页面,默认用户名 root 密码为空。 8. 测试完成,清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行 From 7d819fba97aaf6f0530a7fb3fdfff76a75ea8cdc Mon Sep 17 00:00:00 2001 From: lzs <43946384+superlzs0476@users.noreply.github.com> Date: Wed, 15 Apr 2020 21:08:52 +0800 Subject: [PATCH 27/28] Update how-to/get-started/deploy-tidb-from-tiup.md Co-Authored-By: Keke Yi <40977455+yikeke@users.noreply.github.com> --- how-to/get-started/deploy-tidb-from-tiup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/deploy-tidb-from-tiup.md index 6b3c83659688..71430c9f9220 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/deploy-tidb-from-tiup.md @@ -295,7 +295,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 - 访问 TiDB 的 Dashboard - 访问集群 TiDB-Dashboard 监控页面:http://{pd-ip}:2379/dashboard 默认用户名 root 密码为空。 + 通过 访问集群 TiDB Dashboard 监控页面,默认用户名 root,密码为空。 - 通过 `tiup cluster list` 命令来确认当前已经部署的集群列表 From dab5306a4ad9233dcbc9ae7d61ee84d9cc0d6872 Mon Sep 17 00:00:00 2001 From: yikeke Date: Wed, 15 Apr 2020 21:52:38 +0800 Subject: [PATCH 28/28] Format/content edits; add to TOC; change filename --- TOC.md | 1 + ...-from-tiup.md => quick-start-with-tidb.md} | 192 +++++++++--------- 2 files changed, 98 insertions(+), 95 deletions(-) rename how-to/get-started/{deploy-tidb-from-tiup.md => quick-start-with-tidb.md} (50%) diff --git a/TOC.md b/TOC.md index 656cccd22db1..ac7645ad08c5 100644 --- a/TOC.md +++ b/TOC.md @@ -20,6 +20,7 @@ - [高可用](/key-features.md#高可用) + 操作指南 + 快速上手 + - [快速体验 TiDB 集群](/how-to/get-started/quick-start-with-tidb.md) - [使用 Docker Compose 部署 TiDB](/how-to/get-started/deploy-tidb-from-docker-compose.md) - [SQL 基本操作](/how-to/get-started/explore-sql.md) - [读取历史数据](/how-to/get-started/read-historical-data.md) diff --git a/how-to/get-started/deploy-tidb-from-tiup.md b/how-to/get-started/quick-start-with-tidb.md similarity index 50% rename from how-to/get-started/deploy-tidb-from-tiup.md rename to how-to/get-started/quick-start-with-tidb.md index 71430c9f9220..55075bcf226d 100644 --- a/how-to/get-started/deploy-tidb-from-tiup.md +++ b/how-to/get-started/quick-start-with-tidb.md @@ -5,33 +5,33 @@ category: how-to # 如何快速体验 TiDB 集群 -本文档介绍如何快速地体验 TiDB 分布式数据库。有以下 3 种体验方式供用户选择。 - -- 第一种:使用 TiDB-Wasm 一键体验 TiDB 数据库 -- 第二种:使用 TiUP Playground 快速部署本地测试环境 -- 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 +本文介绍如何快速体验 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 是运行在浏览器中的 TiDB 数据库,打开网页即可使用。TiDB-Wasm 可直接进行 SQL 执行、兼容性验证等基本操作。 -试用请点击网址:[https://tour.pingcap.com](https://tour.pingcap.com),之后会在内存中构建 TiDB 数据库,预计消耗 10s 左右时间。 +试用 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,可以快速搭建出上述的一套基础测试集群。 +作为一个分布式系统,最基础的 TiDB 测试集群通常由 2 个 TiDB 实例、3 个 TiKV 实例和 3 个 PD 实例来构成。通过 TiUP Playground,可以快速搭建出上述的一套基础测试集群。 -1. 下载并安装 TiUP +1. 下载并安装 TiUP。 {{< copyable "shell-regular" >}} @@ -39,11 +39,11 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh ``` -2. 声明全局环境变量 +2. 声明全局环境变量。 - > **建议:** + > **注意:** > - > TiUP 安装完成会提示对应的 profile 文件的绝对路径,source 操作请根据实际位置进行操作。 + > TiUP 安装完成会提示对应的 profile 文件的绝对路径,以下 source 操作需要根据实际位置进行操作。 {< copyable "shell-regular" >}} @@ -51,15 +51,15 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 source .bash_profile ``` -3. 安装 Playground +3. 安装 TiUP Playground。 {{< copyable "shell-regular" >}} ```shell tiup install playground - ``` + ``` - - 如果曾经安装过,请升级至最新版 + 如果曾经安装过 TiUP Playground,则执行以下命令升级至最新版: {{< copyable "shell-regular" >}} @@ -67,35 +67,35 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 tiup update playground ``` -4. 在当前 session 启动集群 +4. 在当前 session 执行以下命令启动集群。 - - 直接运行 tiup playground 会运行最新版本的 TiDB 集群,其中组件 tidb/tikv/pd 各 1 个。 + - 直接运行 `tiup playground` 命令会运行最新版本的 TiDB 集群,其中 TiDB、TiKV 和 PD 实例各 1 个: - {{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} - ```shell - tiup playground - ``` + ```shell + tiup playground + ``` - - 也可以指定版本以及组件个数 + - 也可以指定版本以及组件实例个数: - {{< copyable "shell-regular" >}} + {{< copyable "shell-regular" >}} - ```shell - tiup playground v4.0.0-rc --db 2 --pd 3 --kv 3 --monitor - ``` + ```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 - ``` + 上述命令会在本地下载并启动一个 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 数据库 +5. 新开启一个 session 以访问 TiDB 数据库。 {{< copyable "shell-regular" >}} @@ -103,11 +103,11 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 mysql --host 127.0.0.1 --port 4000 -u root ``` -6. 通过 访问 TiDB 的 Prometheus 管理界面 +6. 通过 访问 TiDB 的 Prometheus 管理界面。 -7. 通过 访问 TiDB 的 Dashboard 页面,默认用户名 root 密码为空。 +7. 通过 访问 TiDB 的 Dashboard 页面,默认用户名为 root,密码为空。 -8. 测试完成,清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行 +8. 测试完成后清理集群,绿色环保。通过 `ctrl-c` 停掉进程后,执行以下命令: {{< copyable "shell-regular" >}} @@ -115,21 +115,21 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 tiup clean --all ``` -## 第三种:使用 TiUP Cluster 模拟单机下的准生产测试环境 +## 第三种:使用 TiUP cluster 模拟单机下的准生产测试环境 -- 适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产的部署步骤。 +- 适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产的部署步骤。 - 耗时:10 分钟 -本文档介绍如何参照 TiUP 最小拓扑 的一个 YAML 文件部署 TiDB 集群。 +本节介绍如何参照 TiUP 最小拓扑的一个 YAML 文件部署 TiDB 集群。 ### 准备环境 准备一台部署主机,确保其软件满足需求: -- 推荐安装 CentOS 7.3 及以上版本 +- 推荐安装 CentOS 7.3 及以上版本 - Linux 操作系统开放外网访问,用于下载 TiDB 及相关软件安装包 -最小规模的 TiDB 集群拓扑 +最小规模的 TiDB 集群拓扑: | 实例 | 个数 | IP | 配置 | |:-- | :-- | :-- | :-- | @@ -139,19 +139,21 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 | TiFlash | 1 | 10.0.1.1 | 默认端口
全局目录配置 | | Monitor | 1 | 10.0.1.1 | 默认端口
全局目录配置 | -部署主机软件和环境要求 +部署主机软件和环境要求: - 部署需要使用部署主机的 root 用户及密码 -- 部署主机关闭防火墙或者开放 TiDB 集群的节点间所需端口 +- 部署主机[关闭防火墙](/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 操作系操作步骤: ### 实施部署 -1. 以下步骤使用 linux 系统的任一普通用户或 root 用户,以 root 用户为例 +> **注意:** +> +> 你可以使用 Linux 系统的任一普通用户或 root 用户登录主机,以下步骤以 root 用户为例。 -2. 下载并安装 TiUP +1. 下载并安装 TiUP: {{< copyable "shell-regular" >}} @@ -159,7 +161,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh ``` -3. 安装 TiUP 的 cluster 组件 +2. 安装 TiUP 的 cluster 组件: {{< copyable "shell-regular" >}} @@ -167,7 +169,7 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 tiup cluster ``` -4. 如果已经安装 TiUP cluster 的机器更新软件版本 +3. 如果机器已经安装 TiUP cluster,需要更新软件版本: {{< copyable "shell-regular" >}} @@ -175,26 +177,26 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 tiup update cluster ``` -5. 由于模拟多机部署,需要通过 `root` 用户调大 sshd 服务的连接数限制 +4. 由于模拟多机部署,需要通过 `root` 用户调大 sshd 服务的连接数限制: - - 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20 - - 重启 sshd 服务 + 1. 修改 /etc/ssh/sshd_config 将 `MaxSessions` 调至 20。 + 2. 重启 sshd 服务: - {{< copyable "shell-regular" >}} - - ```shell - service sshd restart - ``` + {{< copyable "shell-regular" >}} + + ```shell + service sshd restart + ``` -6. 创建并启动集群 +5. 创建并启动集群 - - 按下面的配置模板,编辑配置文件,命名为 topo.yaml ,其中: - - - `user: "tidb"` 表示通过 tidb 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 - - - 设置 PD 参数 `replication.enable-placement-rules` 参数来确保 TiFlash 正常运行。 - - - host 改为本部署主机的 IP + 按下面的配置模板,编辑配置文件,命名为 `topology.yaml`,其中: + + - `user: "tidb"` 表示通过 `tidb` 系统用户来做集群的内部管理(部署会自动创建),默认使用 22 端口通过 ssh 登陆目标机器 + - 设置 `replication.enable-placement-rules` 这个 PD 参数来确保 TiFlash 正常运行 + - host 改为本部署主机的 IP + + 配置模板如下: {{< copyable "shell-regular" >}} @@ -252,8 +254,8 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 grafana_servers: - host: 10.0.1.1 ``` - -7. 执行部署集群 + +6. 执行集群部署命令: {{< copyable "shell-regular" >}} @@ -262,16 +264,16 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 ``` - 参数 `` 表示设置集群名称 - - 参数 `` 表示设置集群版本,可以通过 tiup list tidb --refresh 命令来选择当前支持部署的 TiDB 版本。 - - 按照引导,输入”y” 及 root 密码,来完成部署 + - 参数 `` 表示设置集群版本,可以通过 `tiup list tidb --refresh` 命令来选择当前支持部署的 TiDB 版本 + + 按照引导,输入”y”及 root 密码,来完成部署: ```log Do you want to continue? [y/N]: y Input SSH password: ``` -8. 启动集群 +7. 启动集群: {{< copyable "shell-regular" >}} @@ -279,36 +281,36 @@ TiDB-Wasm 是运行在浏览器中的 TiDB 数据库,打开网页即可使用 tiup cluster start ``` -9. 访问集群 +8. 访问集群: - - 访问 TiDB 数据库,密码为空 + - 访问 TiDB 数据库,密码为空: - {{< copyable "shell-regular" >}} - - ```shell - mysql -h 10.0.1.1 -P 4000 -u root - ``` + {{< copyable "shell-regular" >}} + + ```shell + mysql -h 10.0.1.1 -P 4000 -u root + ``` - - 访问 TiDB 的 Grafana 监控 - - 通过 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。 + - 访问 TiDB 的 Grafana 监控: - - 访问 TiDB 的 Dashboard + 通过 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。 - 通过 访问集群 TiDB Dashboard 监控页面,默认用户名 root,密码为空。 + - 访问 TiDB 的 Dashboard: - - 通过 `tiup cluster list` 命令来确认当前已经部署的集群列表 + 通过 访问集群 TiDB Dashboard 监控页面,默认用户名为 root,密码为空。 - {{< copyable "shell-regular" >}} + - 执行以下命令确认当前已经部署的集群列表: - ```shell - tiup cluster list - ``` + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster list + ``` - - `tiup cluster display ` 来查看集群的拓扑结构和状态 + - 执行以下命令查看集群的拓扑结构和状态: - {{< copyable "shell-regular" >}} - - ```shell - tiup cluster display - ``` + {{< copyable "shell-regular" >}} + + ```shell + tiup cluster display + ```