课程笔记 tiup playground 部署本地集群

课程链接

TiDB 快速起步

课程大纲

  • 数据库、大数据与 TiDB 的发展简史

    • 01: 数据库、大数据发展历史与趋势

    • 02: 分布式关系数据库的发展

    • 03: TiDB 产品与开源社区演进

  • TiDB 整体概述

    • 04: 我们到底需要一个什么样的数据库

    • 05: 如何构建一个分布式存储系统

    • 06: 如何构建一个分布式 SQL 引擎

  • 新一代 HTAP 数据库选型

    • 07: 基于分布式架构的 HTAP 数据库

    • 08: TiDB 关键技术创新

    • 09: TiDB 典型应用场景及用户案例

  • TiDB 初体验

    • 10: TiDB 初体验

实践笔记


[ysym@localhost ~]$ 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 6968k  100 6968k    0     0  2696k      0  0:00:02  0:00:02 --:--:-- 2695k

WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json

You can revoke this by remove /home/ysym/.tiup/bin/7b8e153f2e2d0928.root.json

Successfully set mirror to https://tiup-mirrors.pingcap.com

Detected shell: bash

Shell profile:  /home/ysym/.bash_profile

/home/ysym/.bash_profile has been modified to add tiup to PATH

open a new terminal or source /home/ysym/.bash_profile to use it

Installed path: /home/ysym/.tiup/bin/tiup

===============================================

Have a try:     tiup playground

===============================================

[ysym@localhost ~]$ source /home/ysym/.bash_profile

[ysym@localhost ~]$ tiup playground v5.0.0 --db 2 --pd 3 --kv 3 --monitor

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-linux-amd64.tar.gz 7.31 MiB / 7.31 MiB 100.00% 3.88 MiB/s

Starting component `playground`: /home/ysym/.tiup/components/playground/v1.10.2/tiup-playground v5.0.0 --db 2 --pd 3 --kv 3 --monitor

Flag --monitor has been deprecated, Please use --without-monitor to control whether to disable monitor.

Playground Bootstrapping...

Start pd instance:v5.0.0

The component `pd` version v5.0.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/pd-v5.0.0-linux-amd64.tar.gz 41.09 MiB / 41.09 MiB 100.00% 1.97 MiB/s        

Start pd instance:v5.0.0

Start pd instance:v5.0.0

Start tikv instance:v5.0.0

The component `tikv` version v5.0.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tikv-v5.0.0-linux-amd64.tar.gz 161.21 MiB / 161.21 MiB 100.00% 3.82 MiB/s    

Start tikv instance:v5.0.0

Start tikv instance:v5.0.0

Start tidb instance:v5.0.0

The component `tidb` version v5.0.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tidb-v5.0.0-linux-amd64.tar.gz 45.73 MiB / 45.73 MiB 100.00% 2.36 MiB/s      

Start tidb instance:v5.0.0

Waiting for tidb instances ready

127.0.0.1:4000 ... Done

127.0.0.1:4001 ... Done

The component `prometheus` version v5.0.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/prometheus-v5.0.0-linux-amd64.tar.gz 39.84 MiB / 39.84 MiB 100.00% 3.84 MiB/s

download https://tiup-mirrors.pingcap.com/grafana-v5.0.0-linux-amd64.tar.gz 54.28 MiB / 54.28 MiB 100.00% 4.45 MiB/s  

Start tiflash instance:v5.0.0

The component `tiflash` version v5.0.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tiflash-v5.0.0-linux-amd64.tar.gz 407.93 MiB / 407.93 MiB 100.00% 3.85 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 4000 -u root -p (no password)

To connect TiDB: mysql --comments --host 127.0.0.1 --port 4001 -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

使用tiup client连接


[ysym@localhost ~]$ tiup client

tiup is checking updates for component client ...

Starting component `client`: /home/ysym/.tiup/components/client/v1.10.2/tiup-client

Connected with driver mysql (5.7.25-TiDB-v5.0.0)

Type "help" for help.

my:root@127.0.0.1:4000=> \q

[ysym@localhost ~]$

使用mysql客户端连接


[ysym@localhost ~]$ sudo -s

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

[sudo] password for ysym:

[root@localhost ysym]# yum install mysql

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

 * base: mirrors.huaweicloud.com

 * extras: mirrors.neusoft.edu.cn

 * updates: mirrors.163.com

Resolving Dependencies

--> Running transaction check

---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed

--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-5.5.68-1.el7.x86_64

--> Running transaction check

---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be updated

---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be an update

--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================

 Package                  Arch               Version                       Repository        Size

==================================================================================================

Installing:

 mariadb                  x86_64             1:5.5.68-1.el7                base             8.8 M

Updating for dependencies:

 mariadb-libs             x86_64             1:5.5.68-1.el7                base             760 k

Transaction Summary

==================================================================================================

Install  1 Package

Upgrade             ( 1 Dependent package)

Total size: 9.5 M

Total download size: 8.8 M

Is this ok [y/d/N]: y

Downloading packages:

warning: /var/cache/yum/x86_64/7/base/packages/mariadb-5.5.68-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY

Public key for mariadb-5.5.68-1.el7.x86_64.rpm is not installed

mariadb-5.5.68-1.el7.x86_64.rpm                                            | 8.8 MB  00:00:07    

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Importing GPG key 0xF4A80EB5:

 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"

 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5

 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)

 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Is this ok [y/N]: y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Updating   : 1:mariadb-libs-5.5.68-1.el7.x86_64                                             1/3

  Installing : 1:mariadb-5.5.68-1.el7.x86_64                                                  2/3

  Cleanup    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                           3/3

  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                             1/3

  Verifying  : 1:mariadb-5.5.68-1.el7.x86_64                                                  2/3

  Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                           3/3

Installed:

  mariadb.x86_64 1:5.5.68-1.el7                                                                  

Dependency Updated:

  mariadb-libs.x86_64 1:5.5.68-1.el7                                                              

Complete!

[root@localhost ysym]# mysql --host 127.0.0.1 --port 4000 -u root

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MySQL connection id is 11

Server version: 5.7.25-TiDB-v5.0.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> \q

Bye

[root@localhost ysym]#

监控界面

清理集群


[ysym@localhost ~]$ tiup clean --all

Kill instance of `playground`, pid: 23232

Clean instance of `playground`, directory: /home/ysym/.tiup/data/T9HjVyF

[ysym@localhost ~]$