基于docker-compose搭建tiDB集群

1. 安装docker

CentOS7 安装docker

2. 安装docker-compose

Windows、Macos平台安装Docker时会自动安装Docker-compose,Linux不会

1. 用daocloud下载docker-compose

sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

2. 给文件添加可执行权限

sudo chmod +x /usr/local/bin/docker-compose

3. 测试安装结果

$ docker-compose --version
 
docker-compose version 1.16.1, build 1719ceb

3. 安装git

sudo yum install -y git

4. 下载 tidb-docker-compose

git clone https://github.com/pingcap/tidb-docker-compose.git

5. 进入该目录执行命令

cd tidb-docker-compose/

6. 获取最新的 docker 镜像文件

docker-compose pull 

Pulling pd0 … done
Pulling pd1 … done
Pulling pd2 … done
Pulling tikv0 … done
Pulling tikv1 … done
Pulling tikv2 … done
Pulling tidb … done
Pulling tispark-master … done
Pulling tispark-slave0 … done
Pulling tidb-vision … done
Pulling pushgateway … done
Pulling prometheus … done
Pulling grafana … done
Pulling dashboard-installer … done

7. 创建并启动集群

docker-compose up -d

8. 访问 tidb:密码为空

mysql -h 127.0.0.1 -P 4000 -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.25-TiDB-v5.0.1 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2021, 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.

9. 修改密码

ALTER USER 'root'@'%' identified by '新密码';

10. 访问grafana

http://ip地址:3000
基于docker-compose搭建tiDB集群_第1张图片

11. 访问集群可视化

http://ip地址:8010
基于docker-compose搭建tiDB集群_第2张图片

12. 若TiDB启动失败,则先执行

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

你可能感兴趣的:(软件安装,优质博客,云原生,docker,tidb,linux)