最近开始关注国产数据库的发展,为了能从技术人员的角度来实际体验国产中目前最流行的TiDB数据库,从今天起,在官方公布的课程开始正面了解TiDB的设计理念。

看了2小时的入门课程介绍,总体来说,还是有不少的惊喜,首先从这个最简单的“TiDB 快速起步”课程中,大致了解了TiDB的前世今生,从基本架构中的基础组件:主要是PD、TiDB Server、TiKV、TiFlash等高度分层的设计理念,对MySQL的完备兼容性,以及TiDB自己的一些创新。

刚开始听概念时会觉得这种较为复杂的分层架构设计一定会对初学者产生困扰,因为很多DBA初学某一款数据库时,都是先被最基础的安装部署耗费了很多精力,到头来反而忽略对产品的核心功能特性的体验和理解。

这一点顾虑在课程最后得到了一个很好的解决方案,直接在自己的笔记本中,就可以快速部署本地测试集群,包括这些核心组件以及监控,整个过程只需要简单几条命令,连虚拟机都不需要。

所以任何使用者想自己快速搭建一套测试环境,完全都不需要啥运维基础,就可以在自己的电脑上快速部署一套完整的TiDB数据库集群系统用于学习测试。

下面就来实际体会下这个便捷性:

课程中还是讲的TiDB 5.0 版本,为了感受最新的 TiDB 6.1 版本,结合课程和官方手册在我的MBP上直接运行以下步骤来获得一套完整的TiDB数据库集群系统,体验 TiDB 集群的基本架构,以及 TiDB、TiKV、PD、监控等基础组件的运行:

TiDB 是一个分布式系统。最基础的 TiDB 测试集群通常由 2 个 TiDB 实例、3 个 TiKV 实例、3 个 PD 实例和可选的 TiFlash 实例构成。通过 TiUP Playground,可以快速搭建出上述的一套基础测试集群,步骤如下:

1. 安装TiUP工具

执行如下命令安装 TiUP 工具:

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

实际执行和输出结果:

jingyuzhao@jingyuzhao-mac ~ % curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload Upload Total Spent Left Speed
100 7277k 100 7277k 0 0 7138k 0 0:00:01 0:00:01 --:--:-- 7212k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /Users/jingyuzhao/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: zsh
Shell profile: /Users/jingyuzhao/.zshrc
/Users/jingyuzhao/.zshrc has been modified to add tiup to PATH
open a new terminal or source /Users/jingyuzhao/.zshrc to use it
Installed path: /Users/jingyuzhao/.tiup/bin/tiup
===============================================
Have a try: tiup playground
===============================================
jingyuzhao@jingyuzhao-mac ~ %

2. 设置环境变量

按如下步骤设置 TiUP 环境变量:

source ${your_shell_profile}

实际执行和输出结果:

jingyuzhao@jingyuzhao-mac ~ % source /Users/jingyuzhao/.zshrc
jingyuzhao@jingyuzhao-mac ~ % which tiup
/Users/jingyuzhao/.tiup/bin/tiup

3. 部署并启动集群

在当前 session 执行以下命令启动集群
如果直接执行 tiup playground 命令会运行最新版本的 TiDB 集群,其中 TiDB、TiKV、PD 和 TiFlash 实例各 1 个。
我们也可以指定 TiDB 版本以及各组件实例个数,命令类似于:

tiup playground v6.1.0 --db 2 --pd 3 --kv 3

实际执行和输出结果:

jingyuzhao@jingyuzhao-mac ~ % tiup playground v6.1.0 --db 2 --pd 3 --kv 3

tiup is checking updates for component playground ...
A new version of playground is available:
The latest version: v1.10.2
Local installed version:
Update current component: tiup update playground
Update all components: tiup update --all The component `playground` version is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/playground-v1.10.2-darwin-amd64.tar.gz 7.64 MiB / 7.64 MiB 100.00% 13.78 MiB/s
Starting component `playground`: /Users/jingyuzhao/.tiup/components/playground/v1.10.2/tiup-playground v6.1.0 --db 2 --pd 3 --kv 3
Playground Bootstrapping...
Start pd instance:v6.1.0
The component `pd` version v6.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/pd-v6.1.0-darwin-amd64.tar.gz 43.73 MiB / 43.73 MiB 100.00% 10.03 MiB/s
Start pd instance:v6.1.0
Start pd instance:v6.1.0
Start tikv instance:v6.1.0
The component `tikv` version v6.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tikv-v6.1.0-darwin-amd64.tar.gz 23.85 MiB / 23.85 MiB 100.00% 9.48 MiB/s
Start tikv instance:v6.1.0
Start tikv instance:v6.1.0
Start tidb instance:v6.1.0
The component `tidb` version v6.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tidb-v6.1.0-darwin-amd64.tar.gz 49.80 MiB / 49.80 MiB 100.00% 9.89 MiB/s
Start tidb instance:v6.1.0
Waiting for tidb instances ready
127.0.0.1:4000 ... Done
127.0.0.1:4001 ... Done
The component `prometheus` version v6.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/prometheus-v6.1.0-darwin-amd64.tar.gz 90.08 MiB / 90.08 MiB 100.00% 9.56 MiB/s
download https://tiup-mirrors.pingcap.com/grafana-v6.1.0-darwin-amd64.tar.gz 47.19 MiB / 47.19 MiB 100.00% 9.99 MiB/s
Start tiflash instance:v6.1.0
The component `tiflash` version v6.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tiflash-v6.1.0-darwin-amd64.tar.gz 88.24 MiB / 88.24 MiB 100.00% 9.59 MiB/s
Waiting for tiflash instances ready
127.0.0.1:3930 ... Done
CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --comments --host 127.0.0.1 --port 4001 -u root -p (no password)
To connect TiDB: mysql --comments --host 127.0.0.1 --port 4000 -u root -p (no password)
To view the dashboard: http://127.0.0.1:2379/dashboard
PD client endpoints: [127.0.0.1:2379 127.0.0.1:2382 127.0.0.1:2384]
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

这个过程居然不到1分钟,而且还包含了在线下载介质的时间..

然后这个窗口最小化即可。

4. 访问 TiDB 数据库

新开启一个 session 以访问 TiDB 数据库:
到这里就完成了本机的测试环境部署,新开一个窗口测试连接,可以使用TiUP client 连接 TiDB:

tiup client

实际执行和输出结果:

jingyuzhao@jingyuzhao-mac ~ % tiup client
tiup is checking updates for component client ...
Starting component `client`: /Users/jingyuzhao/.tiup/components/client/v1.10.2/tiup-client
Connected with driver mysql (5.7.25-TiDB-v6.1.0)
Type "help" for help. my:root@127.0.0.1:4000=>
my:root@127.0.0.1:4000=> show databases;
Database
--------------------
INFORMATION_SCHEMA
METRICS_SCHEMA
PERFORMANCE_SCHEMA
mysql
test
(5 rows) my:root@127.0.0.1:4000=>

也可使用 MySQL 客户端连接 TiDB:

mysql --host 127.0.0.1 --port 4000 -u root

我这里没装MySQL客户端,就不贴输出了,反正和上面类似一样的结果。

5. 访问TiDB 的管理界面

此外,这套环境还集成了常用图形化的管理、监控界面:

通过 http://127.0.0.1:9090 访问 TiDB 的 Prometheus 管理界面。

通过 http://127.0.0.1:2379/dashboard 访问 TiDB Dashboard 页面,默认用户名为 root,密码为空。

通过 http://127.0.0.1:3000 访问 TiDB 的 Grafana 界面,默认用户名和密码都为 admin。

6. 一键清理集群

测试完成之后,可以通过执行以下步骤来轻松的清理集群:

按下 Control+C 键停掉上述启用的 TiDB 服务。

实际执行和输出结果:

^CPlayground receive signal:  interrupt
Wait tiflash(18160) to quit...
Wait grafana(17978) to quit...
Wait prometheus(17728) to quit...
Wait ng-monitoring(17729) to quit...
Got signal interrupt (Component: playground ; PID: 17020)
Grafana quit
tiflash quit
Wait tidb(17291) to quit...
tikv quit
prometheus quit
tikv quit
tikv quit
ng-monitoring quit
pd quit
pd quit
tidb quit
Wait tidb(17292) to quit...
pd quit
Wait tikv(17205) to quit...
tidb quit
Wait tikv(17211) to quit...
Wait tikv(17212) to quit...
Wait pd(17115) to quit...
Wait pd(17116) to quit...
Wait pd(17117) to quit...
jingyuzhao@jingyuzhao-mac ~ %

等待服务退出操作完成后,执行以下命令:

tiup clean --all

实际执行和输出结果:

jingyuzhao@jingyuzhao-mac ~ % tiup clean --all
jingyuzhao@jingyuzhao-mac ~ %

7. 参考官方课程和文档

这里再提一点感受,无论是课程设计还是官方手册内容编排,这一块基本不需要自己二次整理什么逻辑,课程简单易懂,官方文档的条理也非常清晰,切切实实的感受到了用心在做事情,在国产数据库中的确可以说是一股清流。如果要问对TiDB的第一印象如何,那么我个人觉得还是相当不错的,也愿意去做进一步的学习了解。

国产数据库TiDB初体验:简单易用,快速上手的更多相关文章

  1. DataAccess通用数据库访问类,简单易用,功能强悍

    以下是我编写的DataAccess通用数据库访问类,简单易用,支持:内联式创建多个参数.支持多事务提交.支持参数复用.支持更换数据库类型,希望能帮到大家,若需支持查出来后转换成实体,可以自行扩展dat ...

  2. golang数据库操作初体验

    在golang中,提供了标准的数据库接口database/sql包,做过数据库开发的应该知道,不同的数据库有不同的数据库驱动.比如mysql等,我们可以去找 https://golang.org/s/ ...

  3. tidb初体验

    安装 docker-compose: https://github.com/pingcap/tidb-docker-compose pd tikv tidb各单个节点,单个副本,限制内存,cpu等,防 ...

  4. 分布式NoSQL数据库MongoDB初体验-v5.0.5

    概述 定义 MongoDB官网 https://www.mongodb.com/ 社区版最新版本5.0,其中5.2版本很快也要面世了 MongoDB GitHub源码 https://github.c ...

  5. Axure初体验:简单交互、通过按钮切换图片

    前言: 之前是一直用processon的UI原型设计,后来感觉只能完成静态页面的processon满足不了原型设计的需求,断网时候也不方便修改.展示.最终还是决定学习动态页面的制作,所选工具为原型设计 ...

  6. doxygen的简单使用(快速上手)

    在网上找了很久一个简单的doxygen教程,这个是最简单的,让你看完之后马上就能写doxygen格式的代码 doxygen是一种从源代码生成文档的工具,支持多种语言.当然,源代码中需按一定的格式写注释 ...

  7. spring-data详解之spring-data-jpa:简单三步快速上手spring-data-jpa开发

    前言: 基于spring framework 4.x或spring boot 1.x开发环境 务必注意以下版本问题:Spring framework4.x(Spring boot1.x)对应sprin ...

  8. Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验

    Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验 前几天分享的"[Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验][http://www ...

  9. Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验

    Net Core平台灵活简单的日志记录框架NLog初体验 前几天分享的"[Net Core集成Exceptionless分布式日志功能以及全局异常过滤][https://www.cnblog ...

  10. Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验

    Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...

随机推荐

  1. <vue 路由 7、导航守卫>

    导航守卫 一.     知识点 1.什么是导航守卫? (1)vue-router提供的导航守卫主要用来监听路由的进入和离开. (2)vue-router提供了beforeEach和afterEach的 ...

  2. java基础-构建工具mvn-day20

    目录 1. 初识mvn 2. 用maven创建工程 3. maven工程 之间的关系 4. 父子 mvn工程 5. mvn常见的插件 6. tomcat插件 1. 初识mvn mvn是一个项目构建工具 ...

  3. java基础数据类型-int类型-浮点型-数据类型的转换--day02

    目录 1. 变量的命名 2. 常量 3. 变量 4. 进制 4.1 进制转换 4.2 整型数据类型 5 浮点型 6. 字符串 7. 整形与字符型之间的转换 8 最常见的一个乱码问题 9. 布尔类型 1 ...

  4. ACP 知识点总结

    记录下学习ACP过程不断遇到的且需要记录的知识点: 在阿里云专有网络VPC创建之后,路由器也是随着VPC一起自动创建,所以不需要手动创建,这个时候需要继续创建交换机才能在交换机种创建其他云产品. 7层 ...

  5. 基于jquery开发的Windows 12网页版

    预览 https://win12.gitapp.cn 首页代码 <!DOCTYPE html> <html lang="en"> <head> ...

  6. 02-UPF-Power Domain

    How do we use power domain 使用UPF至少有一个power domain power domain可以进行嵌套 Defining Power Domain Example P ...

  7. [转帖]《Linux性能优化实战》笔记(五)—— 不可中断进程与僵尸进程

    一. 进程状态 1. 状态含义 从 ps或者 top 命令的输出中,可以看到处于不同状态的进程 R:Running 或 Runnable,表示进程在 CPU 的就绪队列中,正在运行或者正在等待运行 D ...

  8. [转帖]云平台部署CNA、VRM手动安装方法

    云平台部署CNA.VRM手动安装方法 分享人:郭道川 00443725 日期:2018.11.06     Ⅰ. 项目介绍 该项目主要为XX煤矿智能煤炭项目云平台部署交付,该项目所采用的服务器为RH2 ...

  9. [转帖]金仓数据库KingbaseES V8R6 中unlogged表

    KingbaseESV8R6有一种表称为unlogged,在该表新建的索引也属于unlogged.和普通表的区别是,对该表进行DML操作时候不将该表的变更记录变更写入到wal文件中.在数据库异常关机或 ...

  10. [转帖]比 Python 快 35000 倍!LLVM&Swift 之父宣布全新编程语言 Mojo:编程被颠覆了

    https://www.infoq.cn/article/GFfVLVpkIGOcKYB85Opb "Mojo 可能是近几十年来最大的编程语言进步." 近日,由 LLVM 和 Sw ...