win11环境四条命令创建tidb练手环境

来自 @huanglao2002 的贡献:

环境要求

  1. win11个人电脑一台,可以是家庭版本或者专业版本。

  2. 内存最好是16GB、8GB也没问题。

  3. 电脑可以连接到互联网。

使用wsl安装ubuntu 20.04

wsl是适用于 Linux 的 Windows 子系统可让开发人员按原样运行 GNU/Linux 环境 - 包括大多数命令行工具、实用工具和应用程序 - 且不会产生传统虚拟机或双启动设置开销。

打开powershell,安装ubuntu 20.04

wsl.exe --install -d Ubuntu-20.04

该命令会自动相关系统环境,并下载ubuntu 20.04介质并安装好系统。按照系统提示重新启动系统,并设置ubuntu用户和密码。查看ubuntu版本

下载tiup工具

登录ubuntu虚拟机,下载tiup工具

jin@TABLET-PBTEB744:~$ 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 7087k  100 7087k    0     0  7661k      0 --:--:-- --:--:-- --:--:-- 7653k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /home/jin/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile:  /home/jin/.bashrc
/home/jin/.bashrc has been modified to add tiup to PATH
open a new terminal or source /home/jin/.bashrc to use it
Installed path: /home/jin/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================

jin@TABLET-PBTEB744:~$ source /home/$USER/.bashrc

tiup工具就安装好了。

安装tidb

使用tiup安装练手环境

jin@TABLET-PBTEB744:~$ tiup playground
tiup is checking updates for component playground ...
A new version of playground is available:
   The latest version:         v1.11.1
   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.11.1-linux-amd64.tar.gz 7.44 MiB / 7.44 MiB 100.00% 11.99 MiB/s
Starting component `playground`: /home/jin/.tiup/components/playground/v1.11.1/tiup-playground
Using the version v6.5.0 for version constraint "".

If you'd like to use a TiDB version other than v6.5.0, cancel and retry with the following arguments:
        Specify version manually:   tiup playground <version>
        Specify version range:      tiup playground ^5
        The nightly version:        tiup playground nightly

Playground Bootstrapping...
Start pd instance:v6.5.0
The component `pd` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/pd-v6.5.0-linux-amd64.tar.gz 45.20 MiB / 45.20 MiB 100.00% 9.84 MiB/s
Start tikv instance:v6.5.0
The component `tikv` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tikv-v6.5.0-linux-amd64.tar.gz 250.45 MiB / 250.45 MiB 100.00% 7.85 MiB/s
Start tidb instance:v6.5.0
The component `tidb` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tidb-v6.5.0-linux-amd64.tar.gz 63.14 MiB / 63.14 MiB 100.00% 9.50 MiB/s
Waiting for tidb instances ready
127.0.0.1:4000 ... Done
The component `prometheus` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/prometheus-v6.5.0-linux-amd64.tar.gz 92.26 MiB / 92.26 MiB 100.00% 9.67 MiB/s
download https://tiup-mirrors.pingcap.com/grafana-v6.5.0-linux-amd64.tar.gz 50.12 MiB / 50.12 MiB 100.00% 9.76 MiB/s
Start tiflash instance:v6.5.0
The component `tiflash` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tiflash-v6.5.0-linux-amd64.tar.gz 194.36 MiB / 194.36 MiB 100.00% 9.60 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 view the dashboard: http://127.0.0.1:2379/dashboard
PD client endpoints: [127.0.0.1:2379]
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

验证安装好的tidb练手环境

登录dashboard

登录mysql client

使用mysql client登录tidb,并查询tidb版本。

jin@TABLET-PBTEB744:~$ mysql --comments --host 127.0.0.1 --port 4000 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 441
Server version: 5.7.25-TiDB-v6.5.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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>
mysql>
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()

       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

总结

win11 powershell 执行 wsl.exe --install -d Ubuntu-20.04

ubuntu bash中执行

curl --proto ‘=https’ --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

source /home/$USER/.bashrc

tiup playground

小白首次发文,请大家多多关照。小白能在短时间上手,也得益于tiup的简单易用。希望今后能分享更过的文章。

1 个赞

来学习