docker部署TiDB集群
程序员文章站
2022-07-13 09:08:07
...
下载镜像
[[email protected] tidb]# ls
dashboard.tar pd.tar tidb.tar tikv.tar tispark.tar
镜像添加即可
根据官方文档开始搭建
https://pingcap.com/docs-cn/op-guide/docker-deployment/
两种方式
1 compose 与分布式 搭建原理是相通的
但分布式在硬件不支持的情况下可以选择再一台物理机上搭建 需要注意要为tidb创建一个专属的网络 否则一台主机的pd tikv节点无法通信
创建专属网络
[root@foundation15 Desktop]# docker network create tidbnet
70a1b9f42ec42297a37cde9eb64f5379a80b0636c6170987e83004d6e786c708
[root@foundation15 Desktop]# brctl show
bridge name bridge id STP enabled interfaces
br-70a1b9f42ec4 8000.024291b2025a no
br0 8000.0021cc5ee725 no enp0s25
vnet0
vnet1
vnet2
docker0 8000.024234777297 no vethfa90023
virbr0 8000.525400d7037a yes virbr0-nic
virbr1 8000.5254005b6694 yes virbr1-nic
#######################################################################
搭建 pd
[[email protected] data]# docker run -d --name pd3 -v `pwd`/data:/data --network tidbnet pingcap/pd --name="pd3" --data-dir="/data/pd3" --client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://pd3:2379 --peer-urls=http://0.0.0.0:2380 --advertise-peer-urls=http://pd3:2380 --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380
修改创建三个即可
########################################################################
搭建tikv
docker run -d --name tikv3 --network tidbnet --ulimit nofile=1000000:1000000 -v `pwd`/data:/data pingcap/tikv --advertise-addr="tikv3:20160" --data-dir="/data/tikv3" --pd="pd3:2379,pd1:2379,pd2:2379"
修改搭建三个即可
############################################################################
启动tidb
[root@foundation15 tidb]# docker run -d --name tidb -p 4000:4000 -p 10080:10080 --network tidbnet pingcap/tidb --store=tikv --path=pd3:2379,pd1:2379,pd2:2379
查看启动是否正常
76f65ffd365d7dcaaed236be320b7f4b1d135f0b06f370abb7a091db74f691ba
[root@foundation15 tidb]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76f65ffd365d pingcap/tidb "/tidb-server --stor…" 2 seconds ago Up 2 seconds 0.0.0.0:4000->4000/tcp, 0.0.0.0:10080->10080/tcp tidb
02669d10d893 pingcap/tikv "/tikv-server --adve…" 2 minutes ago Up 2 minutes 20160/tcp tikv3
aaa04eff060f pingcap/tikv "/tikv-server --adve…" 3 minutes ago Up 3 minutes 20160/tcp tikv2
8e9b73b33fa3 pingcap/tikv "/tikv-server --adve…" 3 minutes ago Up 3 minutes 20160/tcp tikv1
2f565d2dcb36 pingcap/pd "/pd-server --name=p…" 13 minutes ago Up 13 minutes 2379-2380/tcp pd3
b78e837a634e pingcap/pd "/pd-server --name=p…" 13 minutes ago Up 13 minutes 2379-2380/tcp pd2
d89137c00656 pingcap/pd "/pd-server --name=p…" 14 minutes ago Up 14 minutes 2379-2380/tcp pd1
dda9f7f81a45 registry:2 "/entrypoint.sh /etc…" 25 hours ago Up 39 minutes 0.0.0.0:443->443/tcp, 5000/tcp
成功