暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

练手篇 | 麒麟操作系统中如何安装单机版的TiDB分布式数据库

原创 杨磊 2022-11-20
851

目的
部署测试目的TiDB 集群,用于平时练手使用。

既然都是国产数据库了,那操作系统也需要使用麒麟 kylin V10 SP2

操作系统环境:

[root@192 ~]# nkvers
############## Kylin Linux Version #################
Release:
Kylin Linux Advanced Server release V10 (Sword)

Kernel:
4.19.90-24.4.v2101.ky10.x86_64

Build:
Kylin Linux Advanced Server
release V10 (SP2) /(Sword)-x86_64-Build09/20210524
#################################################

安装步骤如下:

  1. 下载并安装 TiUP 工具:
    打开终端
    Linux: 进入 Terminal
    执行以下命令,下载并安装 TiUP 工具。注意 $ 为终端提示符, 常见的也有可能是 %:
[root@192 ~]# 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 7085k  100 7085k    0     0  1311k      0  0:00:05  0:00:05 --:--:-- 1317k
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile:  /root/.bash_profile
Installed path: /root/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================

[root@192 ~]# export PATH=~/.tiup/bin:$PATH

  1. 启动集群 (指定各个组件的实例数量),保持会话窗口打开:
    [root@192 ~]# tiup playground v6.0.0 --tag classroom --db 3 --pd 3 --kv 3 --tiflash 1
    tiup is checking updates for component playground …
    Starting component playground: /root/.tiup/components/playground/v1.11.0/tiup-playground v6.0.0 --tag classroom --db 3 --pd 3 --kv 3 --tiflash 1
    Playground Bootstrapping…
    Start pd instance:v6.0.0
    Start pd instance:v6.0.0
    Start pd instance:v6.0.0
    Start tikv instance:v6.0.0
    Start tikv instance:v6.0.0
    Start tikv instance:v6.0.0
    Start tidb instance:v6.0.0
    Start tidb instance:v6.0.0
    Start tidb instance:v6.0.0

。。。

check detail log from: /root/.tiup/data/classroom/tikv-2/tikv.log
Waiting for tiflash instances ready
127.0.0.1:3930 … Error
CLUSTER START SUCCESSFULLY, Enjoy it -
To connect TiDB: mysql --comments --host 127.0.0.1 --port 4002 -u root -p (no password)
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

  1. 打开另一个终端,执行以下命令使用数据库客户端访问 TiDB 数据库,出现 "mysql> "提示符:
    [root@mysqlSlave ~]# mysql -h 127.0.0.1 -P 4000 -uroot
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 407
    Server version: 5.7.25-TiDB-v6.0.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright © 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| INFORMATION_SCHEMA |
| METRICS_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql |
| test |
±-------------------+
5 rows in set (0.00 sec)

  1. 查看数据库版本,随机数和当前时间:

mysql> select connection_id(), version(), rand(), now();
±----------------±-------------------±-------------------±--------------------+
| connection_id() | version() | rand() | now() |
±----------------±-------------------±-------------------±--------------------+
| 407 | 5.7.25-TiDB-v6.0.0 | 0.3019098567794169 | 2022-11-20 22:29:01 |
±----------------±-------------------±-------------------±--------------------+
1 row in set (0.00 sec)

  1. 退出数据库会话 (如有必要)
    exit

  2. 停止测试集群:
    回到第一个终端,按下 ctrl + c 键停掉测试集群 (请勿连续按 ctrl + c,一次就够了, 耐心等待终端提示符的出现,比如 $ 或 %)

ctrl + c

  1. 再次启动集群
    $ tiup playground --tag classroom --db 2 --pd 3 --kv 3 --tiflash 1

[root@192 ~]# tiup playground --tag classroom --db 2 --pd 3 --kv 3 --tiflash 1
tiup is checking updates for component playground …
Starting component playground: /root/.tiup/components/playground/v1.11.0/tiup-playground v6.0.0 --tag classroom --db 3 --pd 3 --kv 3 --tiflash 1
Playground Bootstrapping…
Start pd instance:v6.0.0
Start pd instance:v6.0.0
Start pd instance:v6.0.0
Start tikv instance:v6.0.0
Start tikv instance:v6.0.0
Start tikv instance:v6.0.0
Start tidb instance:v6.0.0
Start tidb instance:v6.0.0
Start tidb instance:v6.0.0
Waiting for tidb instances ready
127.0.0.1:4000 … ⠹
127.0.0.1:4001 … ⠹
127.0.0.1:4002 … ⠹

参考链接
https://learn.pingcap.com/learner/player/630005;id=630005;source=DETAIL;classroomId=960002;courseDetailId=600003;learnerAttemptId=1668919952822

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论