0


猿创征文 | 国产数据库TiDB安装部署

前言

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

文章目录


1、部署方式选择

部署方式:部署方式https://pingcap.com/docs-cn/stable/overview/

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
通过查阅官方文档和网友踩坑经验,我们学习测试时就就直接使用官网推荐的Docker Compose方式快速构建TiDB集群即可(或者使用单机版)

2、TiDB-Local单机版

在Centos 6的版本中如果要部署,这个难度还是比较大的,而且会有很多未知的坑,根据官方的建议,是需要在Centos 7以上的版本中,否则glibc的版本问题会很快碰到。

我们安装一套Centos7,采用快速的单机部署的方式来尝鲜。

  1. 下载安装包

wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz

  1. 解压文件
tar -zxvf tidb-latest-linux-amd64.tar.gz 
cd tidb-latest-linux-amd64
  1. 启动
启动PD
./bin/pd-server --data-dir=pd --log-file=pd.log &
启动tikv
./bin/tikv-server --pd="127.0.0.1:2379"--data-dir=tikv --log-file=tikv.log &
启动tidb-server
./bin/tidb-server --store=tikv --path="127.0.0.1:2379"--log-file=tidb.log &
  1. 登录
mysql -h 127.0.0.1-P4000-u root
WelcometotheMySQLmonitor.  Commands end with; or \g.
YourMySQL connection id is 3Server version:5.7.25-TiDB-v4.0.0-beta-185-g065deca8f TiDBServer(ApacheLicense2.0),MySQL5.7 compatible

Copyright(c)2000,2020,Oracle and/or its affiliates. All rights reserved.

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

Type'help;' or '\h'forhelp. Type'\c'toclear the current input statement.
  1. 体验
mysql> \s
--------------
mysql  Ver14.14Distrib5.7.29,forLinux(x86_64) using  EditLine wrapper

Connection id:3Current database:Current user:           [email protected]
SSL:Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:;Server version:5.7.25-TiDB-v4.0.0-beta-185-g065deca8f TiDBServer(ApacheLicense2.0),MySQL5.7 compatible
Protocol version:10Connection:127.0.0.1 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8
Conn.  characterset:    utf8
TCP port:4000--------------

mysql> show databases;+--------------------+|Database|+--------------------+| INFORMATION_SCHEMA || INSPECTION_SCHEMA  || METRIC_SCHEMA      || PERFORMANCE_SCHEMA || mysql              || test               |+--------------------+6 rows in set (0.00 sec)

mysql> select tidb_version();+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|tidb_version()|+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|ReleaseVersion: v4.0.0-beta-185-g065deca8f
GitCommitHash:065deca8f00cd61b357ba0f1a61119d55111f758
GitBranch: master
UTC BuildTime:2020-02-2012:18:56GoVersion: go1.13RaceEnabled:falseTiKVMinVersion: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
CheckTableBeforeDrop:false|+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)

mysql> select version();+----------------------------------------+|version()|+----------------------------------------+|5.7.25-TiDB-v4.0.0-beta-185-g065deca8f |+----------------------------------------+1 row in set (0.00 sec)

mysql>  select user,host from mysql.user;+------+------+| user | host |+------+------+| root |%|+------+------+1 row in set (0.00 sec)

mysql>  exit

3、TiDB-Docker集群版

  1. 准备环境 确保你的机器上已安装: Docker(17.06.0 及以上版本) Docker Compose Git
  2. 快速部署 下载 tidb-docker-compose``````git clone https://github.com/pingcap/tidb-docker-compose.git
  3. 创建并启动集群
获取最新 Docker 镜像:
cd tidb-docker-compose && docker-compose pull && docker-compose up -d

**注意:
得先启动Docker

sudo systemctl start docker

再执行上面的docker-compose命令**

  1. 访问集群
mysql -h 127.0.0.1-P4000-u root

[root@node01 tidb-docker-compose]# mysql -h 127.0.0.1-P4000-u root
WelcometotheMySQLmonitor.  Commands end with; or \g.
YourMySQL connection id is 1Server version:5.7.25-TiDB-v4.0.0-beta-177-g5a00c80e4 TiDBServer(ApacheLicense2.0),MySQL5.7 compatible

Copyright(c)2000,2020,Oracle and/or its affiliates. All rights reserved.

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

Type'help;' or '\h'forhelp. Type'\c'toclear the current input statement.

mysql> show databases;+--------------------+|Database|+--------------------+| INFORMATION_SCHEMA || INSPECTION_SCHEMA  || METRIC_SCHEMA      || PERFORMANCE_SCHEMA || mysql              || test               |+--------------------+6 rows in set (0.00 sec)

mysql> exit
Bye[root@node01 tidb-docker-compose]# 
  1. 访问集群 Grafana 监控页面http://node01:3000/在这里插入图片描述默认用户名和密码均为 admin。
  2. 集群数据可视化http://node01:8010/

4、补充内容

(1)CentOS安装MySQL

  1. 下载并安装MySQL官方的 Yum Repository
wget -i -c 

http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

  1. yum安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
  1. 安装MySQL服务器
yum -y install mysql-community-server
  1. 启动MySQL
systemctl start  mysqld.service
  1. 查看MySQL运行状态
systemctl status mysqld.service
  1. 设置开机启动
systemctl enable mysqld
  1. 找出输入初始密码:grep "password" /var/log/mysqld.log
  2. 进入数据库:mysql -uroot -p
  3. 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@1234';

注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功

  1. 开启mysql的远程访问
grant all privileges on *.* to'root'@'%' identified by 'Root@1234' withgrant option;
flush privileges; 
exit

在这里插入图片描述

(2)CentOS安装Git

  1. 查看是否安装过git,若出现版本号,则代表已经安装了gitgit --version
  2. 使用yum安装gityum -y install git
标签: 数据库 tidb linux

本文转载自: https://blog.csdn.net/m0_73175948/article/details/127253997
版权归原作者 热爱编程的小点点 所有, 如有侵权,请联系我们删除。

“猿创征文 | 国产数据库TiDB安装部署”的评论:

还没有评论