最近开始关注国产数据库的发展,为了能从技术人员的角度来实际体验国产中目前最流行的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. 区分开发环境和生产环境webpack

  2. cookie和token验证区别

  3. vue监听滚动到底部加载更多

    https://blog.csdn.net/qq_39762109/article/details/89354305 此方法有个bug

  4. Python数据可视化-地图可视化

    Python数据可视化-地图可视化 一.基础地图使用 基础地图演示 二.疫情地图-国内疫情地图 具体代码如下 """ 演示全国疫情可视化地图开发 "" ...

  5. BTC-实现

    BTC-实现 Transaction-based ledger(比特币是基于交易的账本模式) Account-based ledger(以太坊是基于账户的账本模式) UTXO Unspent Tran ...

  6. JS - 递归实现无限分类

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. JS - 兼容到 IE 8

    使用 jQuery可以有效的兼容IE 浏览器 , 但jQuery从2.0开始不兼容IE8,最低支持IE9,所以需要引入更低的jQuery版本来兼容 <script type="text ...

  8. MySQL-多表查询练习

    首先创建练习所需要的数据表 储备:建表操作: CREATE TABLE `t_dept` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `deptName` VARC ...

  9. [转帖]使用S3F3在Linux实例上挂载Bucket

    https://docs.jdcloud.com/cn/object-storage-service/s3fs S3F3是基于FUSE的文件系统,允许Linux 挂载Bucket在本地文件系统,S3f ...

  10. Jumper Server 堡垒机搭建过程

    Jumper Server 堡垒机搭建过程 背景说明 公司组织考核, 要对一套系统进行安全设置.有一个项目是使用堡垒机进行登录 堡垒机有多种用途,可以实现日志审计和安全设置等. 买商业设备的话太困难了 ...