拉取镜像
docker pull pingcap/pd
docker pull pingcap/tikv
docker pull pingcap/tidb

安装pd:

  1. docker run -d --name pd1 \
  2. -p 2379:2379 \
  3. -p 2380:2380 \
  4. -v /etc/localtime:/etc/localtime:ro \
  5. -v /data:/data \
  6. pingcap/pd:latest \
  7. --name="pd1" \
  8. --data-dir="/data/pd1" \
  9. --client-urls="http://0.0.0.0:2379" \
  10. --advertise-client-urls="http://192.168.199.130:2379" \
  11. --peer-urls="http://0.0.0.0:2380" \
  12. --advertise-peer-urls="http://192.168.199.130:2380" \
  13. --initial-cluster="pd1=http://192.168.199.130:2380"

安装tikv

  1. docker run -d --name tikv1 \
  2. -p 20160:20160 \
  3. --ulimit nofile=1000000:1000000 \
  4. -v /etc/localtime:/etc/localtime:ro \
  5. -v /data:/data \
  6. pingcap/tikv:latest \
  7. --addr="0.0.0.0:20160" \
  8. --advertise-addr="192.168.199.130:20160" \
  9. --data-dir="/data/tikv1" \
  10. --pd="192.168.199.130:2379"

安装tidb

  1. docker run -d --name tidb \
  2. -p 4000:4000 \
  3. -p 10080:10080 \
  4. -v /etc/localtime:/etc/localtime:ro \
  5. pingcap/tidb:latest \
  6. --store=tikv \
  7. --path="192.168.199.130:2379"

测试连接

密码空
image.png

tidb修改root密码

  1. # mysql库
  2. set password for 'root'@'%' = '123456'