TiDb

主宰稳场 提交于 2019-12-04 23:31:58

docker compose测试环境部署

官方文档:https://pingcap.com/docs-cn/stable/how-to/get-started/deploy-tidb-from-docker-compose/

要求:
Docker(17.06.0 及以上版本)
Docker Compose
Git

#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

#centos默认装1.13的docker,卸载原来的docker13
yum -y remove docker*
rm -rf /var/lib/docker/

#安装最新的docker,使用阿里云
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates #查询新的docker版本
yum install docker-ce #不指定默认拉取最新的docker
systemctl start docker

docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:25:41 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:24:18 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

# 安装docker-compose 推荐使用pip3安装
yum -y install epel-release
yum -y install python3-pip
pip3 install docker-compose

# 克隆tidb
git clone https://github.com/pingcap/tidb-docker-compose.git
# 拉取镜像,启动容器,启动tidb集群
cd tidb-docker-compose && docker-compose pull && docker-compose up -d

docker ps
[root@tidb ~]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                               NAMES
4d53e60e0db9        pingcap/tispark:latest       "/opt/spark/sbin/sta…"   42 minutes ago      Up 42 minutes       0.0.0.0:38081->38081/tcp                            tidb-docker-compose_tispark-slave0_1
d930089fc09a        pingcap/tispark:latest       "/opt/spark/sbin/sta…"   42 minutes ago      Up 42 minutes       0.0.0.0:7077->7077/tcp, 0.0.0.0:8080->8080/tcp      tidb-docker-compose_tispark-master_1
2a8767b06cea        pingcap/tidb:latest          "/tidb-server --stor…"   42 minutes ago      Up 42 minutes       0.0.0.0:4000->4000/tcp, 0.0.0.0:10080->10080/tcp    tidb-docker-compose_tidb_1
d0ce7d9c064c        pingcap/tikv:latest          "/tikv-server --addr…"   42 minutes ago      Up 42 minutes       20160/tcp                                           tidb-docker-compose_tikv1_1
0dda036cd5ec        pingcap/tikv:latest          "/tikv-server --addr…"   42 minutes ago      Up 42 minutes       20160/tcp                                           tidb-docker-compose_tikv0_1
28636750301b        pingcap/tikv:latest          "/tikv-server --addr…"   42 minutes ago      Up 42 minutes       20160/tcp                                           tidb-docker-compose_tikv2_1
52d03f700e12        pingcap/tidb-vision:latest   "/bin/sh -c 'sed -i …"   42 minutes ago      Up 42 minutes       80/tcp, 443/tcp, 2015/tcp, 0.0.0.0:8010->8010/tcp   tidb-docker-compose_tidb-vision_1
70289d6934f1        prom/prometheus:v2.2.1       "/bin/prometheus --l…"   42 minutes ago      Up 42 minutes       0.0.0.0:9090->9090/tcp                              tidb-docker-compose_prometheus_1
07c8e05ea67c        grafana/grafana:6.0.1        "/run.sh"                42 minutes ago      Up 42 minutes       0.0.0.0:3000->3000/tcp                              tidb-docker-compose_grafana_1
78470c2e818b        pingcap/pd:latest            "/pd-server --name=p…"   42 minutes ago      Up 42 minutes       2380/tcp, 0.0.0.0:32770->2379/tcp                   tidb-docker-compose_pd0_1
abab7400fbfa        prom/pushgateway:v0.3.1      "/bin/pushgateway --…"   42 minutes ago      Up 42 minutes       9091/tcp                                            tidb-docker-compose_pushgateway_1
48e9c9ebb24d        pingcap/pd:latest            "/pd-server --name=p…"   42 minutes ago      Up 42 minutes       2380/tcp, 0.0.0.0:32768->2379/tcp                   tidb-docker-compose_pd2_1
ccca0c2c6af6        pingcap/pd:latest            "/pd-server --name=p…"   42 minutes ago      Up 42 minutes       2380/tcp, 0.0.0.0:32769->2379/tcp  


# 可以用mysql进行连接
yum -y install wget
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
rpm -ivh mysql57-community-release-el7-7.noarch.rpm
yum -y install mysql-community-server
systemctl start mysql


#连接tidb,只需要指定端口,不需要密码
mysql -h 127.0.0.1 -P 4000 -u root
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!