From 8309e49a89801400f408d0be209d7156a4c79f87 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Wed, 6 Jun 2018 17:53:59 +0800 Subject: [PATCH 1/2] tikv, readme: add "Install and Deploy TiKV Using Docker" --- README.md | 1 + tikv/deploy-tikv-using-docker.md | 158 +++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 tikv/deploy-tikv-using-docker.md diff --git a/README.md b/README.md index 5ebce7d84e204..5219f2605c985 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ + Install and Deploy TiKV - [Prerequisites](op-guide/recommendation.md) - [Install and Deploy TiKV Using Docker Compose](tikv/deploy-tikv-docker-compose.md) + - [Install and Deploy TiKV Using Docker](tikv/deploy-tikv-using-docker.md) - [Install and Deploy TiKV Using Binary Files](tikv/deploy-tikv-using-binary.md) + Client Drivers - [Go](tikv/go-client-api.md) diff --git a/tikv/deploy-tikv-using-docker.md b/tikv/deploy-tikv-using-docker.md new file mode 100644 index 0000000000000..0853b5574d09e --- /dev/null +++ b/tikv/deploy-tikv-using-docker.md @@ -0,0 +1,158 @@ +--- +title: Install and Deploy TiKV Using Docker +category: user guide +--- + +# Install and Deploy TiKV Using Docker + +This guide describes how to deploy a multi-node TiKV cluster using Docker. + +## Prerequisites + +Install Docker: + +``` +sudo yum install docker +``` + +For more details about prerequisites, see [Hardware and Software Requirements](../op-guide/recommendation.md). + +## Deploy the TiKV cluster on multiple nodes + +Assume that you have 6 machines with the following details: + +| Name | Host IP | Services | Data Path | +| --------- | ------------- | ---------- | --------- | +| Node1 | 192.168.1.101 | PD1 | /data | +| Node2 | 192.168.1.102 | PD2 | /data | +| Node3 | 192.168.1.103 | PD3 | /data | +| Node4 | 192.168.1.104 | TiKV1 | /data | +| Node5 | 192.168.1.105 | TiKV2 | /data | +| Node6 | 192.168.1.106 | TiKV3 | /data | + +If you want to test TiKV with a limited number of nodes, you can also use one PD instance to test the entire cluster. + +### Step 1: Pull the latest images of TiKV and PD from Docker Hub + +Start Docker and pull the latest images of TiKV and PD from [Docker Hub](https://hub.docker.com) using the following command: + +```bash +docker pull pingcap/tikv:latest +docker pull pingcap/pd:latest +``` + +### Step 2: Log in and start PD + +Log in to the three PD machines and start PD respectively: + +1. Start PD1 on Node1: + + ```bash + docker run -d --name pd1 \ + -p 2379:2379 \ + -p 2380:2380 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/pd:latest \ + --name="pd1" \ + --data-dir="/data/pd1" \ + --client-urls="http://0.0.0.0:2379" \ + --advertise-client-urls="http://192.168.1.101:2379" \ + --peer-urls="http://0.0.0.0:2380" \ + --advertise-peer-urls="http://192.168.1.101:2380" \ + --initial-cluster="pd1=http://192.168.1.101:2380,pd2=http://192.168.1.102:2380,pd3=http://192.168.1.103:2380" + ``` + +2. Start PD2 on Node2: + + ```bash + docker run -d --name pd2 \ + -p 2379:2379 \ + -p 2380:2380 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/pd:latest \ + --name="pd2" \ + --data-dir="/data/pd2" \ + --client-urls="http://0.0.0.0:2379" \ + --advertise-client-urls="http://192.168.1.102:2379" \ + --peer-urls="http://0.0.0.0:2380" \ + --advertise-peer-urls="http://192.168.1.102:2380" \ + --initial-cluster="pd1=http://192.168.1.101:2380,pd2=http://192.168.1.102:2380,pd3=http://192.168.1.103:2380" + ``` + +3. Start PD3 on Node3: + + ```bash + docker run -d --name pd3 \ + -p 2379:2379 \ + -p 2380:2380 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/pd:latest \ + --name="pd3" \ + --data-dir="/data/pd3" \ + --client-urls="http://0.0.0.0:2379" \ + --advertise-client-urls="http://192.168.1.103:2379" \ + --peer-urls="http://0.0.0.0:2380" \ + --advertise-peer-urls="http://192.168.1.103:2380" \ + --initial-cluster="pd1=http://192.168.1.101:2380,pd2=http://192.168.1.102:2380,pd3=http://192.168.1.103:2380" + ``` + +### Step 3: Log in and start TiKV + +Log in to the three TiKV machines and start TiKV respectively: + +1. Start TiKV1 on Node4: + + ```bash + docker run -d --name tikv1 \ + -p 20160:20160 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/tikv:latest \ + --addr="0.0.0.0:20160" \ + --advertise-addr="192.168.1.104:20160" \ + --data-dir="/data/tikv1" \ + --pd="192.168.1.101:2379,192.168.1.102:2379,192.168.1.103:2379" + ``` + +2. Start TiKV2 on Node5: + + ```bash + docker run -d --name tikv2 \ + -p 20160:20160 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/tikv:latest \ + --addr="0.0.0.0:20160" \ + --advertise-addr="192.168.1.105:20160" \ + --data-dir="/data/tikv2" \ + --pd="192.168.1.101:2379,192.168.1.102:2379,192.168.1.103:2379" + ``` + +3. Start TiKV3 on Node6: + + ```bash + docker run -d --name tikv3 \ + -p 20160:20160 \ + -v /etc/localtime:/etc/localtime:ro \ + -v /data:/data \ + pingcap/tikv:latest \ + --addr="0.0.0.0:20160" \ + --advertise-addr="192.168.1.106:20160" \ + --data-dir="/data/tikv3" \ + --pd="192.168.1.101:2379,192.168.1.102:2379,192.168.1.103:2379" + ``` + +You can check whether the TiKV cluster has been successfully deployed using the following command: + +``` +curl 192.168.1.101:2379/pd/api/v1/stores +``` + +If the state of all the TiKV instances is "Up", you have successfully deployed a TiKV cluster. + +## What's next? + +If you want to try the Go client, see [Try Two Types of APIs](go-client-api.md). \ No newline at end of file From 83ee26d3353036759d79b36006277bbb3564bf01 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Mon, 11 Jun 2018 13:16:26 +0800 Subject: [PATCH 2/2] tikv: update Docker description --- tikv/deploy-tikv-using-docker.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tikv/deploy-tikv-using-docker.md b/tikv/deploy-tikv-using-docker.md index 0853b5574d09e..32626ce64622f 100644 --- a/tikv/deploy-tikv-using-docker.md +++ b/tikv/deploy-tikv-using-docker.md @@ -9,11 +9,7 @@ This guide describes how to deploy a multi-node TiKV cluster using Docker. ## Prerequisites -Install Docker: - -``` -sudo yum install docker -``` +Make sure that Docker is installed on each machine. For more details about prerequisites, see [Hardware and Software Requirements](../op-guide/recommendation.md).