t01_docker安装TiDB

 Docker环境安装TiDB,在官方说明的基础上补充了几个细节,安装记录如下

个人环境-vbox上安装centos7.4系统

CPU:12核24线程,分配给虚拟机12线程

MEM: 48G,分配给虚拟机24G

注意事项

如果原系统上安装有grafana/prometheus时,这些程序不能使用默认端口,会与将要安装的TIDB镜像中带的冲突

docker安装

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
ll /etc/yum.repos.d/

添加必要的依赖
yum install -y yum-utils device-mapper-persistent-data lvm2

更新并安装 Docker-CE
yum makecache fast
yum -y install docker-ce

开启Docker服务
systemctl start docker

 

Install Docker Compose

curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

docker-compose --version

安装TIDB

mkdir -p /data/tidb
cd /data/tidb
git clone https://github.com/pingcap/tidb-docker-compose.git

创建并启动集群
cd tidb-docker-compose
docker-compose build

screen后台拉取并启动
docker-compose pull # Get the latest Docker images
docker-compose up -d

访问集群
mysql -h 127.0.0.1 -P 4000 -u root

mysql -h 192.168.1.200 -P 4000 -u root
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| INFORMATION_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql |
| test |
+--------------------+
4 rows in set (0.01 sec)

 

访问集群 Grafana 监控页面:http://localhost:3000 默认用户名和密码均为 admin。
http://192.168.1.200:3000

 t01_docker安装TiDB_第1张图片

 

 

集群数据可视化:http://localhost:8010
http://192.168.1.200:8010

t01_docker安装TiDB_第2张图片

 

docker镜像

[root@cent tidb-docker-compose]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
pingcap/pd            latest              2d8b2f485ab4        26 hours ago        79.4MB
pingcap/tikv          latest              49526bebec18        26 hours ago        318MB
pingcap/tidb          latest              416adb24e6ff        26 hours ago        77.9MB
pingcap/tispark       latest              0cac838c0912        6 days ago          863MB
grafana/grafana       6.0.1               ffd9c905f698        8 weeks ago         241MB
pingcap/tidb-vision   latest              e9b25d9f7bdb        12 months ago       47.6MB
prom/prometheus       v2.2.1              cc866859f8df        13 months ago       113MB
prom/pushgateway      v0.3.1              434efa6ed9db        2 years ago         13.3MB

 

正在运行的镜像

[root@cent tidb-docker-compose]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                               NAMES
a5c82131af6c        pingcap/tispark:latest       "/opt/spark/sbin/sta…"   30 minutes ago      Up 30 minutes       0.0.0.0:38081->38081/tcp                            tidb-docker-compose_tispark-slave0_1
bbfd61473363        pingcap/tidb:latest          "/tidb-server --stor…"   30 minutes ago      Up 30 minutes       0.0.0.0:4000->4000/tcp, 0.0.0.0:10080->10080/tcp    tidb-docker-compose_tidb_1
30d16f0c1dbf        pingcap/tispark:latest       "/opt/spark/sbin/sta…"   30 minutes ago      Up 30 minutes       0.0.0.0:7077->7077/tcp, 0.0.0.0:8080->8080/tcp      tidb-docker-compose_tispark-master_1
c733e9b1da4e        pingcap/tikv:latest          "/tikv-server --addr…"   30 minutes ago      Up 30 minutes       20160/tcp                                           tidb-docker-compose_tikv1_1
8b64af789276        pingcap/tikv:latest          "/tikv-server --addr…"   30 minutes ago      Up 30 minutes       20160/tcp                                           tidb-docker-compose_tikv0_1
36966fad91c8        pingcap/tikv:latest          "/tikv-server --addr…"   30 minutes ago      Up 30 minutes       20160/tcp                                           tidb-docker-compose_tikv2_1
f018ac181867        prom/prometheus:v2.2.1       "/bin/prometheus --l…"   30 minutes ago      Up 30 minutes       0.0.0.0:9090->9090/tcp                              tidb-docker-compose_prometheus_1
8f919ceed2ab        pingcap/pd:latest            "/pd-server --name=p…"   30 minutes ago      Up 30 minutes       2380/tcp, 0.0.0.0:32770->2379/tcp                   tidb-docker-compose_pd0_1
1132787175ab        pingcap/tidb-vision:latest   "/bin/sh -c 'sed -i …"   30 minutes ago      Up 30 minutes       80/tcp, 443/tcp, 2015/tcp, 0.0.0.0:8010->8010/tcp   tidb-docker-compose_tidb-vision_1
687fc4e0172e        pingcap/pd:latest            "/pd-server --name=p…"   30 minutes ago      Up 30 minutes       2380/tcp, 0.0.0.0:32768->2379/tcp                   tidb-docker-compose_pd1_1
4e55b08d591d        pingcap/pd:latest            "/pd-server --name=p…"   30 minutes ago      Up 30 minutes       2380/tcp, 0.0.0.0:32769->2379/tcp                   tidb-docker-compose_pd2_1
362fa1a4c30b        prom/pushgateway:v0.3.1      "/bin/pushgateway --…"   30 minutes ago      Up 30 minutes       9091/tcp                                            tidb-docker-compose_pushgateway_1
508747a153bd        grafana/grafana:6.0.1        "/run.sh"                30 minutes ago      Up 30 minutes       0.0.0.0:3000->3000/tcp                              tidb-docker-compose_grafana_1
[root@cent tidb-docker-compose]# 

 

关闭正在运行的镜像

docker stop a5c82131af6c
docker stop bbfd61473363
docker stop 30d16f0c1dbf
docker stop c733e9b1da4e
docker stop 8b64af789276
docker stop 36966fad91c8
docker stop f018ac181867
docker stop 8f919ceed2ab
docker stop 1132787175ab
docker stop 687fc4e0172e
docker stop 4e55b08d591d
docker stop 362fa1a4c30b
docker stop 508747a153bd

 

关闭docker

systemctl stop docker

 

重启虚拟机之后

启动docker

systemctl start docker

 

启动镜像

docker start a5c82131af6c
docker start bbfd61473363
docker start 30d16f0c1dbf
docker start c733e9b1da4e
docker start 8b64af789276
docker start 36966fad91c8
docker start f018ac181867
docker start 8f919ceed2ab
docker start 1132787175ab
docker start 687fc4e0172e
docker start 4e55b08d591d
docker start 362fa1a4c30b
docker start 508747a153bd

 

转载于:https://www.cnblogs.com/perfei/p/10804736.html

你可能感兴趣的:(t01_docker安装TiDB)