国产数据库TiDB初体验:简单易用,快速上手
最近开始关注国产数据库的发展,为了能从技术人员的角度来实际体验国产中目前最流行的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初体验:简单易用,快速上手的更多相关文章
- DataAccess通用数据库访问类,简单易用,功能强悍
以下是我编写的DataAccess通用数据库访问类,简单易用,支持:内联式创建多个参数.支持多事务提交.支持参数复用.支持更换数据库类型,希望能帮到大家,若需支持查出来后转换成实体,可以自行扩展dat ...
- golang数据库操作初体验
在golang中,提供了标准的数据库接口database/sql包,做过数据库开发的应该知道,不同的数据库有不同的数据库驱动.比如mysql等,我们可以去找 https://golang.org/s/ ...
- tidb初体验
安装 docker-compose: https://github.com/pingcap/tidb-docker-compose pd tikv tidb各单个节点,单个副本,限制内存,cpu等,防 ...
- 分布式NoSQL数据库MongoDB初体验-v5.0.5
概述 定义 MongoDB官网 https://www.mongodb.com/ 社区版最新版本5.0,其中5.2版本很快也要面世了 MongoDB GitHub源码 https://github.c ...
- Axure初体验:简单交互、通过按钮切换图片
前言: 之前是一直用processon的UI原型设计,后来感觉只能完成静态页面的processon满足不了原型设计的需求,断网时候也不方便修改.展示.最终还是决定学习动态页面的制作,所选工具为原型设计 ...
- doxygen的简单使用(快速上手)
在网上找了很久一个简单的doxygen教程,这个是最简单的,让你看完之后马上就能写doxygen格式的代码 doxygen是一种从源代码生成文档的工具,支持多种语言.当然,源代码中需按一定的格式写注释 ...
- spring-data详解之spring-data-jpa:简单三步快速上手spring-data-jpa开发
前言: 基于spring framework 4.x或spring boot 1.x开发环境 务必注意以下版本问题:Spring framework4.x(Spring boot1.x)对应sprin ...
- Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验
Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验 前几天分享的"[Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验][http://www ...
- Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验
Net Core平台灵活简单的日志记录框架NLog初体验 前几天分享的"[Net Core集成Exceptionless分布式日志功能以及全局异常过滤][https://www.cnblog ...
- Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验
Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...
随机推荐
- 开源项目《Elight.MVC-ASP.NET》的研究学习
一 观看效果 将源码下载来后,发现不能直接运行,读了一下md文件,发现还要做自己一些改动. 由于我本机是sqlserver, 所以我改了下 appsetting.json 里要使用的数据库,然后 ...
- Liunx常用操作(七)-文件上传下载方法
如下介绍了几个比较方便的liunx软件的文件维护方法 一.SZ,RZ liunx服务器上安装 通过apt来安装z.sz:安装后直接上传下载文件 apt-get install lrzsz 用法: # ...
- Jensen 不等式证明
Jensen 不等式定义 若 \(f(x)\) 为区间 \(I\) 上的下凸函数,则对于任意 \(x_{i} \in I\) 和满足 \(\displaystyle\sum_{i=1}^{n} \la ...
- 基于java+springboot的租房网站、房屋出租管理系统
该系统是基于java+springboot+vue开发的租房管理系统.是给师弟开发的课程作业.学习过程中,遇到问题可以留言咨询. 演示地址 前台地址: http://zf.gitapp.cn 后台地址 ...
- SV task and function
内容 system verilog过程语句:自增和自减操作符 逻辑比较操作符 逻辑值为1bit inside语句 变量类型转换 强制类型转换:$cast() 变量位宽转换 变量符号位转换 for循环语 ...
- Nginx的日志处理
Nginx的日志处理 背景 之前一直被各种咨询nginx的使用问题. 大部分都是性能, 加模块, 以及一些tcp端口等的问题. 其实这些都还好, 还有一个比较麻烦的问题时日志相关的. nginx的日志 ...
- [转帖]命令行参数--与-D的区别
https://juejin.cn/post/7238420276228341815 Spring Boot 学习笔记 我们要想了解这两者之间的差异,首先来看一个案例: bash 复制代码 # ...
- [转帖]INTEL MLC(Memory Latency Checker)介绍
https://zhuanlan.zhihu.com/p/359823092 在定位机器性能问题的时候,有时会觉得机器莫名其妙地跑的慢,怎么也看不出来问题.CPU频率也正常,程序热点也没问题,可就是慢 ...
- [转帖]AMD第四代宵龙 9174F 亮眼
https://www.amd.com/zh-hans/processors/epyc-9004-series#%E8%A7%84%E6%A0%BC 型号规格 型号 CPU 核心数量 线程数量 最 ...
- Redis极简教程
简介 Redis 是用C语言开发完全开源免费的,遵守BSD协议的,一个高性能的,key-value型的,NOSQL数据库. 特点 可以将内存中的数据持久化到硬盘中,重启的时候可以从硬盘中再次加载 拥有 ...