Skip to content
99 changes: 58 additions & 41 deletions reference/tiflash/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TiFlash 支持多目录存储,所以无需使用 RAID。

## 针对 TiDB 的版本要求

目前 TiFlash 的测试是基于 TiDB 3.1 版本的相关组件(包括 TiDB、PD、TiKV、TiFlash)来进行的,TiDB 3.1 版本的下载方式参考以下安装部署步骤。
目前 TiFlash 的测试是基于 TiDB 4.0 版本的相关组件(包括 TiDB、PD、TiKV、TiFlash)来进行的,TiDB 4.0 版本的下载方式参考以下安装部署步骤。

## 安装部署 TiFlash

Expand All @@ -52,73 +52,90 @@ TiFlash 支持多目录存储,所以无需使用 RAID。

### 全新部署 TiFlash

目前对于全新部署 TiFlash 场景,推荐通过下载离线安装包来部署 TiFlash。步骤如下
TiUP Cluster 是适用于 TiDB 4.0 及以上版本的部署工具,目前推荐使用 TiUP Cluster 安装部署 TiFlash,部署流程如下

1. 下载对应版本的离线包,并解压:
1. 参考 [TiUP 部署文档](/how-to/deploy/orchestrated/tiup.md)安装 TiUP。

- 如果你使用的是 TiDB 4.0 内测版,执行以下命令:
2. 安装 TiUP cluster 组件

{{< copyable "shell-regular" >}}
{{< copyable "shell-regular" >}}

```shell
curl -o tidb-ansible-tiflash-4.0-v3-20200331.tar.gz https://download.pingcap.org/tidb-ansible-tiflash-4.0-v3-20200331.tar.gz &&
tar zxvf tidb-ansible-tiflash-4.0-v3-20200331.tar.gz
```
```shell
tiup cluster
```

- 如果你使用的是 TiDB 3.1 rc 版,执行以下命令:
3. 编写 topology 配置文件,保存为 `topology.yaml`。

{{< copyable "shell-regular" >}}
可以参考[全量的配置文件模版](https://github.com/pingcap-incubator/tiops/blob/master/topology.example.yaml)。

```shell
curl -o tidb-ansible-tiflash-3.1-rc.tar.gz https://download.pingcap.org/tidb-ansible-tiflash-3.1-rc.tar.gz &&
tar zxvf tidb-ansible-tiflash-3.1-rc.tar.gz
```
除了部署 TiDB 集群的配置,需要额外在 `tiflash_servers` 下配置 tiflash servers 所在的 ip(目前只支持 ip,不支持域名)。

2. 编辑 `inventory.ini` 配置文件,除了[部署 TiDB 集群的配置](/how-to/deploy/orchestrated/ansible.md#第-9-步编辑-inventoryini-文件分配机器资源),需要额外在 `[tiflash_servers]` 下配置 tiflash servers 所在的 ip (目前只支持 ip,不支持域名)。

如果希望自定义部署目录,需要配置 `data_dir` 参数,不需要则不加。如果希望多盘部署,则以逗号分隔各部署目录(注意每个 `data_dir` 目录的上级目录需要赋予 tidb 用户写权限),例如:
如果需要部署 TiFlash,请把 `pd` 部分的 `replication.enable-placement-rules` 配置设置为 `true`。

{{< copyable "" >}}

```ini
[tiflash_servers]
192.168.1.1 data_dir=/data1/tiflash/data,/data2/tiflash/data
```

3. 按照 TiDB Ansible 部署流程完成集群部署的[剩余步骤](/how-to/deploy/orchestrated/ansible.md#第-10-步调整-inventoryini-文件中的变量)。

4. 验证 TiFlash 已部署成功的方式:通过 [pd-ctl](/reference/tools/pd-control.md)(tidb-ansible 目录下的 `resources/bin` 包含对应的二进制文件)执行 `pd-ctl store http://your-pd-address` 命令,可以观测到所部署的 TiFlash 实例状态为“Up”。
server_configs:
pd:
replication.enable-placement-rules: true

### 在原有 TiDB 集群上新增 TiFlash 组件
pd_servers:
- host: 172.19.0.101
- host: 172.19.0.102
- host: 172.19.0.103

1. 首先确认当前 TiDB 的版本支持 TiFlash,否则需要先按照 [TiDB 升级操作指南](/how-to/upgrade/from-previous-version.md)升级 TiDB 集群至 3.1 rc 以上版本。
tidb_servers:
- host: 172.19.0.101

2. 在 pd-ctl(tidb-ansible 目录下的 `resources/bin` 包含对应的二进制文件)中输入 `config set enable-placement-rules true` 命令,以开启 PD 的 Placement Rules 功能。
tikv_servers:
- host: 172.19.0.101
- host: 172.19.0.102
- host: 172.19.0.103

3. 编辑 `inventory.ini` 配置文件,并在 `[tiflash_servers]` 下配置 tiflash servers 所在的 ip(目前只支持 ip,不支持域名)。
tiflash_servers:
- host: 172.19.0.103
```

如果希望自定义部署目录,需要配置 `data_dir` 参数,不需要则不加。如果希望多盘部署,则以逗号分隔各部署目录(注意每个 `data_dir` 目录的上级目录需要赋予 tidb 用户写权限),例如:
如果希望自定义部署目录,需要配置 data_dir 参数,不需要则不加。如果希望多盘部署,则以逗号分隔各部署目录,例如:

{{< copyable "" >}}

```ini
[tiflash_servers]
192.168.1.1 data_dir=/data1/tiflash/data,/data2/tiflash/data
tiflash_servers:
- host: 172.19.0.103
data_dir: /data1/tiflash/data,/data2/tiflash/data
```

4. 按照 TiUP 部署流程完成集群部署的剩余步骤,包括:

部署 TiDB 集群,其中 test 为集群名:

{{< copyable "shell-regular" >}}

```shell
tiup cluster deploy test v4.0.0-rc topology.yaml -i ~/.ssh/id_rsa
```

> **注意:**
>
> 即使 TiFlash 与 TiKV 同机部署,TiFlash 也会采用与 TiKV 不同的默认端口,默认 9000,无特殊需要可以不用指定,有需要也可在 inventory.ini 配置文件中新增一行 `tcp_port=xxx` 来指定。
启动 TiDB 集群:

{{< copyable "shell-regular" >}}

```shell
tiup cluster start test
```

4. 执行以下 ansible-playbook 命令部署 TiFlash:
5. 查看集群状态

{{< copyable "shell-regular" >}}

```shell
ansible-playbook local_prepare.yml &&
ansible-playbook -t tiflash deploy.yml &&
ansible-playbook -t tiflash start.yml &&
ansible-playbook rolling_update_monitor.yml
tiup cluster display test
```

5. 验证 TiFlash 已部署成功的方式:通过 [pd-ctl](/reference/tools/pd-control.md) 执行 `pd-ctl store http://your-pd-address` 命令,可以观测到所部署的 TiFlash 实例状态为“Up”。
### 在原有 TiDB 集群上新增 TiFlash 组件

1. 首先确认当前 TiDB 的版本支持 TiFlash,否则需要先升级 TiDB 集群至 4.0 rc 以上版本。

2. 在 pd-ctl(目前 pd-ctl 还没有接入 TiUP Cluster,需要从 [这里](https://download.pingcap.org/tidb-v4.0.0-rc-linux-amd64.tar.gz) 手动进行下载)中输入 `config set enable-placement-rules true` 命令,以开启 PD 的 Placement Rules 功能。

3. 参考 [扩容 TiFlash 节点](/reference/tiflash/scale.md#扩容-TiFlash-节点) 章节对 TiFlash 进行部署。
85 changes: 14 additions & 71 deletions reference/tiflash/scale.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,38 @@ category: reference

## 扩容 TiFlash 节点

以在节点 192.168.1.1 上部署 TiFlash 为例,扩容该 TiFlash 节点的步骤如下。
假如需要在 172.19.0.104 上新增 TiFlash 节点,步骤如下:

1. 编辑 `inventory.ini` 文件,添加该 TiFlash 节点信息(目前只支持 ip,不支持域名):
1. 编写 scale-out.yaml 文件,添加该 TiFlash 节点信息(目前只支持 ip,不支持域名):

{{< copyable "" >}}

```ini
[tiflash_servers]
192.168.1.1
tiflash_servers:
- host: 172.19.0.104
```

2. 编辑 `hosts.ini` 文件,添加节点信息:

{{< copyable "" >}}

```ini
[servers]
192.168.1.1

[all:vars]
username = tidb
ntp_server = pool.ntp.org
```

3. 初始化新增节点:

- 在中控机上配置部署机器 SSH 互信及 sudo 规则:

{{< copyable "shell-regular" >}}

```shell
ansible-playbook -i hosts.ini create_users.yml -l 192.168.1.1 -u root -k
```

- 在部署目标机器上安装 NTP 服务:

{{< copyable "shell-regular" >}}

```shell
ansible-playbook -i hosts.ini deploy_ntp.yml -u tidb -b
```

- 在部署目标机器上初始化节点:

{{< copyable "shell-regular" >}}

```shell
ansible-playbook bootstrap.yml -l 192.168.1.1
```

4. 部署新增节点:

{{< copyable "shell-regular" >}}

```shell
ansible-playbook deploy.yml -l 192.168.1.1
```

5. 启动新节点服务:
2. 运行扩容命令

{{< copyable "shell-regular" >}}

```shell
ansible-playbook start.yml -l 192.168.1.1
tiup cluster scale-out test scale-out.yaml
```

6. 更新 Prometheus 配置并重启:
3. 查看集群状态

{{< copyable "shell-regular" >}}

```shell
ansible-playbook rolling_update_monitor.yml --tags=prometheus
tiup cluster display test
```

7. 打开浏览器访问监控平台,监控整个集群和新增节点的状态。
4. 打开浏览器访问监控平台,监控整个集群和新增节点的状态。

## 缩容 TiFlash 节点

以停止 192.168.1.1 节点的服务为例,缩容该 TiFlash 节点的步骤如下。
以停止 172.19.0.104 节点的服务为例,缩容该 TiFlash 节点的步骤如下。

> **注意:**
>
Expand All @@ -102,25 +55,15 @@ category: reference
{{< copyable "shell-regular" >}}

```shell
ansible-playbook stop.yml -l 192.168.1.1
tiup cluster scale-in test --node 172.19.0.104:9000
```

如果该节点仍有其他服务,只希望停止 TiFlash 则请注明 TiFlash 服务:

{{< copyable "shell-regular" >}}

```shell
ansible-playbook stop.yml -t tiflash -l 192.168.1.1
```

4. 编辑 `inventory.ini` 和 `hosts.ini` 文件,移除节点信息。

5. 更新 Prometheus 配置并重启:
4. 查看集群状态

{{< copyable "shell-regular" >}}

```shell
ansible-playbook rolling_update_monitor.yml --tags=prometheus
tiup cluster display test
```

6. 打开浏览器访问监控平台,监控整个集群的状态。
5. 打开浏览器访问监控平台,监控整个集群的状态。
17 changes: 7 additions & 10 deletions reference/tiflash/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ category: reference

# 升级 TiFlash 节点

升级 TiFlash 节点的步骤如下:
升级前请保证集群处于启动状态,升级 TiFlash 节点的步骤如下:

1. 下载新版 TiFlash binary 到中控机,方式有如下两种:

- 下载最新版 TiDB Ansible 或者通过 `git pull` 命令更新 TiDB Ansible git repo,然后执行 `ansible-playbook local_prepare.yml` 命令。
- 或者手动下载 TiFlash binary 并覆盖到 `resource/bin/tiflash`。

2. 滚动升级 TiFlash:
1. 运行升级命令

{{< copyable "shell-regular" >}}

```shell
ansible-playbook rolling_update.yml --tags tiflash
tiup cluster upgrade test v4.0.0-rc
```

3. 滚动升级 TiDB 监控组件:
2. 查看集群状态

{{< copyable "shell-regular" >}}

```shell
ansible-playbook rolling_update_monitor.yml
tiup cluster display test
```

3. 打开浏览器访问监控平台,监控整个集群的状态