从马车到电动车,TiDB 部署工具变形记

2020-06-12 00:00:00 集群 命令 部署 信息 组件

作者:Heng Long

打造产品的信念渗透在每一个 TiDB 开发者的血液中,衡量产品的有多个维度:易用性、稳定性、性能、安全性、开放性、拓展性等等。在部署易用性方面,TiDB 开发者们经过诸多探索和尝试,经过了命令行时代、Ansible 时代,终于在 TiDB 4.0 发布了新一代具有里程碑意义的解决方案——TiUP。

TiUP 的意义不仅仅在于提供了里程碑式的解决方案,更是对 TiDB 开源社区活力的有力证明。TiUP 从 3 月立项进入 PingCAP Incubator 进行孵化,从零开发到终发布 TiUP 1.0 GA 仅仅只花了两个月。两个月内 40+ 位 Contributor 新增了 690+ 次提交,终沉淀接近 40k 行代码。

本文会描述整个演进过程,并介绍 TiUP 设计过程中的一些理念和实现细节。

以史为鉴

TiUP 的诞生并非一蹴而就,而是有一个演变过程。简要描述这个演变过程,有助于大家更加深入理解 TiUP 的设计和取舍。

纯命令行

在没有 TiDB Ansible 的时代,要运行一个 TiDB 集群只能通过命令行的方式。TiDB 集群包含 TiDB/TiKV/PD 三个核心组件, 和 Promethues/Grafana/Node Exporter 监控组件。手动构建一个集群运行需要的所有命令行参数和配置文件比较复杂的。比如,我们想要搭建一个集群,其中启动三个 PD 的命令行参数就有下面这么复杂(可以忽略命令行,仅演示复杂性):

$ bin/pd-server --name=pd-0
--data-dir=data/Rt1J27k/pd-0/data
--peer-urls=http://127.0.0.1:2380
--advertise-peer-urls=http://127.0.0.1:2380 --client-urls=http://127.0.0.1:2379 --advertise-client-urls=http://127.0.0.1:2379 --log-file=data/Rt1J27k/pd-0/pd.log --initial-cluster=pd-0=http://127.0.0.1:2380,pd-1=http://127.0.0.1:2381,pd-2=http://127.0.0.1:2383

$ bin/pd-server --name=pd-1
--data-dir=data/Rt1J27k/pd-1/data
--peer-urls=http://127.0.0.1:2381 --advertise-peer-urls=http://127.0.0.1:2381 --client-urls=http://127.0.0.1:2382 --advertise-client-urls=http://127.0.0.1:2382 --log-file=data/Rt1J27k/pd-1/pd.log --initial-cluster=pd-0=http://127.0.0.1:2380,pd-1=http://127.0.0.1:2381,pd-2=http://127.0.0.1:2383

$ bin/pd-server --name=pd-2
--data-dir=data/Rt1J27k/pd-2/data
--peer-urls=http://127.0.0.1:2383 --advertise-peer-urls=http://127.0.0.1:2383 --client-urls=http://127.0.0.1:2384 --advertise-client-urls=http://127.0.0.1:2384 --log-file=data/Rt1J27k/pd-2/pd.log --initial-cluster=pd-0=http://127.0.0.1:2380,pd-1=http://127.0.0.1:2381,pd-2=http://127.0.0.1:2383

相关文章