打造优秀产品的信念渗透在每一个 TiDB 开发者的血液中,衡量产品的优秀有多个维度:易用性、稳定性、性能、安全性、开放性、拓展性等等。在部署易用性方面,TiDB 开发者们经过诸多探索和尝试,经过了命令行时代、Ansible 时代,终于在 TiDB 4.0 发布了新一代具有里程碑意义的解决方案——TiUP。
TiUP 的意义不仅仅在于提供了里程碑式的解决方案,更是对 TiDB 开源社区活力的有力证明。TiUP 从 3 月立项进入 PingCAP Incubator 进行孵化,从零开发到最终发布 TiUP 1.0 GA 仅仅只花了两个月。两个月内 40+ 位 Contributor 新增了 690+ 次提交,最终沉淀接近 40k 行代码。
本文会描述整个演进过程,并介绍 TiUP 设计过程中的一些理念和实现细节。
以史为鉴
纯命令行
$ 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
注:以 $ 开头的表示在命令行执行的命令
TiDB Ansible
$ vim hosts.ini$ ansible-playbook -i hosts.ini create_users.yml -u root -k$ vim inventory.ini$ ansible-playbook local_prepare.yml$ ansible-playbook bootstrap.yml$ ansible-playbook deploy.yml$ ansible-playbook start.yml
TiUP
$ tiup cluster deploy <cluster-name> <version> <topology.yaml> [flags] # 部署集群$ tiup cluster start prod-cluster# 启动集群
$ tiup cluster scale-in prod-cluster -N 172.16.5.140:20160 # 缩容节点$ tiup cluster scale-out tidb-test scale.yaml # 扩容节点$ tiup cluster upgrade tidb-test v4.0.0-rc# 升级集群
深入 TiUP
$ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
TiUP 理念
1. 简单易用
tiup install <component> | |
tiup uninstall <component> | |
tiup update | |
tiup list | |
tiup status | |
tiup clean |
2. 可扩展
$ tiup playground # 运行最新稳定版 TiDB 集群$ tiup playground v3.0.15 # 运行版本为 v3.0.15 TiDB 集群$ tiup playground --kv 3 # 启动三个 TiKV 节点$ tiup playground --monitor # 启动 Prometheus 监控$ ...
$ tiup bench tpcc # 进行 TPC-C 性能基准测试$ tiup bench tpch prepare$ tiup bench tpch run # 进行 TPC-H 性能基准测试
3. 开放
tiup mirror publish能够将本地组件通过一个命令发布到 TiUP 的镜像仓库。
$ tiup mirror publish -hPublish a component to the repositoryUsage: tiup mirror publish <comp-name> <version> <tarball> <entry> [flags]Flags: --arch string the target system architecture (default "amd64") --desc string description of the component --endpoint string endpoint of the server (default "https://tiup-mirrors.pingcap.com/") -h, --help help for publish -k, --key string private key path --os string the target operation system (default "linux")Global Flags: --repo string Path to the repository --skip-version-check Skip the strict version check, by default a version must be a valid SemVer string
4. 安全
${version}.${name}.json的文件名保存。
(sha256/sha512)。
root.json,后续信息校验会保证 root.json 中至少有三个签名是正确的。
index/snashot/timestamp的不可篡改性由
root.json中的对应的密钥信息保证。
index.json中对应的 Owner 密钥保证(社区通过 tiup mirror publish 发布的组件,只有作者拥有私钥)。
希望上面的介绍能让大家对 TiUP 的演进和理念有初步的认识,同时 TiUP 在 Github 开源并且随着 TiDB 4.0 GA 版本一起发布,对于 TiUP 有兴趣的小伙伴可以阅读源码,有任何问题都可以通过 Issue 提问或直接在 Slack 的 #sig-tiup 中提问:
TiUP 源码地址:
https://github.com/pingcap/tiup
加入 TiUP 专项兴趣小组 Slack Chanel #sig-tiup:
https://join.slack.com/share/zt-exzk2vc5-72UhEIRqu7Uj_5N5JYb8TQ
(复制到浏览器打开)
附:TiUP 贡献者名单

最后修改时间:2020-06-13 09:41:57
文章转载自PingCAP,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




