目的
部署测试目的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
#################################################
安装步骤如下:
- 下载并安装 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
- 启动集群 (指定各个组件的实例数量),保持会话窗口打开:
[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 componentplayground: /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
- 打开另一个终端,执行以下命令使用数据库客户端访问 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)
- 查看数据库版本,随机数和当前时间:
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)
-
退出数据库会话 (如有必要)
exit -
停止测试集群:
回到第一个终端,按下 ctrl + c 键停掉测试集群 (请勿连续按 ctrl + c,一次就够了, 耐心等待终端提示符的出现,比如 $ 或 %)
ctrl + c
- 再次启动集群
$ 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




