tidb数据库的安装与部署_KOS操作系统

1 概述

浪潮信息KOS是浪潮信息基于Linux Kernel、OpenAnolis等开源技术自主研发的一款服务器操作系统,支持x86、ARM等主流架构处理器,性能和稳定性居于行业领先地位,具备成熟的 CentOS 迁移和替换能力,可满足云计算、大数据、分布式存储、人工智能、边缘计算等应用场景需求。详细介绍见官网链接https://www.ieisystem.com/kos/product-kos-xq.thtml?id=12126

TiDB 是 PingCAP 公司自主设计、研发的开源分布式关系型数据库,是一款同时支持在线事务处理与在线分析处理 (Hybrid Transactional and Analytical Processing, HTAP) 的融合型分布式数据库产品,具备水平扩容或者缩容、金融级高可用、实时 HTAP、云原生的分布式数据库、兼容 MySQL 5.7 协议和 MySQL 生态等重要特性。

2 安装环境

操作系统版本:KOS 5.8 (4.18.0-372.41.1.kos5.x86_64)

测试架构:x86_64,8核4G虚拟机

软件版本:TiDB v7.2.0

3 安装TiDB

3.1下载并安装 TiDB

执行以下命令,TiDB会下载安装脚本并运行。

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

更新shell设置使命令生效。

source /root/.bash_profile

3.2 部署本地测试集群

直接执行 tiup playground 命令会运行最新版本的 TiDB 集群,其中 TiDB、TiKV、PD 和 TiFlash 实例各 1 个。

[root@localhost ~]# tiup playground

tiup is checking updates for component playground ...

A new version of playground is available:

The latest version: v1.12.5

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.12.5-linux-amd64.tar.gz 8.07 MiB / 8.07 MiB 100.00% 1.18 MiB/s

Starting component `playground`: /root/.tiup/components/playground/v1.12.5/tiup-playground

Using the version v7.2.0 for version constraint "".

If you'd like to use a TiDB version other than v7.2.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

Start pd instance:v7.2.0

The component `pd` version v7.2.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/pd-v7.2.0-linux-amd64.tar.gz 50.50 MiB / 50.50 MiB 100.00% 1.14 MiB/s

Start tikv instance:v7.2.0

The component `tikv` version v7.2.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tikv-v7.2.0-linux-amd64.tar.gz 284.91 MiB / 284.91 MiB 100.00% 1.13 MiB/s

Start tidb instance:v7.2.0

The component `tidb` version v7.2.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tidb-v7.2.0-linux-amd64.tar.gz 74.33 MiB / 74.33 MiB 100.00% 1.09 MiB/s

Waiting for tidb instances ready

127.0.0.1:4000 ... Done

The component `prometheus` version v7.2.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/prometheus-v7.2.0-linux-amd64.tar.gz 94.24 MiB / 94.24 MiB 100.00% 957.25 KiB/s

download https://tiup-mirrors.pingcap.com/grafana-v7.2.0-linux-amd64.tar.gz 50.15 MiB / 50.15 MiB 100.00% 1.13 MiB/s

Start tiflash instance:v7.2.0

The component `tiflash` version v7.2.0 is not installed; downloading from repository.

download https://tiup-mirrors.pingcap.com/tiflash-v7.2.0-linux-amd64.tar.gz 235.16 MiB / 235.16 MiB 100.00% 1.13 MiB/s

Waiting for tiflash instances ready

127.0.0.1:3930 ... Done

TiDB Playground Cluster is started, enjoy!

Connect TiDB: mysql --comments --host 127.0.0.1 --port 4000 -u root

TiDB Dashboard: http://127.0.0.1:2379/dashboard

Grafana: http://127.0.0.1:3000

3.3 TiDB管理服务

通过 http://127.0.0.1:2379/dashboard 访问 TiDB Dashboard 页面,默认用户名为 root,密码为空。

通过 http://127.0.0.1:3000 访问 TiDB 的 Grafana 界面,默认用户名和密码都为 admin。

4 测试TiDB

4.1 使用 MySQL 客户端连接 TiDB

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

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

Your MySQL connection id is 37

Server version: 5.7.25-TiDB-v7.2.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 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.

4.2 展示数据库

MySQL [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| INFORMATION_SCHEMA |

| METRICS_SCHEMA |

| PERFORMANCE_SCHEMA |

| mysql |

| test |

+--------------------+

5 rows in set (0.001 sec)

4.3 创建表并插入数据

MySQL [(none)]> create table test.hola(bonj text);

Query OK, 0 rows affected (0.094 sec)

MySQL [(none)]> insert into test.hola(bonj) values("Mundo");

Query OK, 1 row affected (0.006 sec)

MySQL [(none)]> insert into test.hola(bonj) values("Lundo");

Query OK, 1 row affected (0.002 sec)

MySQL [(none)]> select * from test.hola;

+-------+

| bonj |

+-------+

| Mundo |

| Lundo |

+-------+

2 rows in set (0.001 sec)

4.4 更新数据

MySQL [(none)]> update test.hola set bonj='Xundo' where bonj='Mundo';

Query OK, 1 row affected (0.003 sec)

Rows matched: 1 Changed: 1 Warnings: 0

MySQL [(none)]> select * from test.hola;

+-------+

| bonj |

+-------+

| Xundo |

| Lundo |

+-------+

2 rows in set (0.001 sec)

4.5 删除数据

MySQL [(none)]> delete from test.hola where bonj='Xundo';

Query OK, 1 row affected (0.002 sec)

MySQL [(none)]> select * from test.hola;

+-------+

| bonj |

+-------+

| Lundo |

+-------+

1 row in set (0.001 sec)

MySQL [(none)]> exit

Bye

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值