From ac67686d1eccc80966704369798ae9790d481e88 Mon Sep 17 00:00:00 2001 From: siddontang Date: Tue, 26 Jul 2016 22:52:02 +0800 Subject: [PATCH 01/11] op-guide: add clustering. --- op-guide/clustering.md | 250 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 op-guide/clustering.md diff --git a/op-guide/clustering.md b/op-guide/clustering.md new file mode 100644 index 0000000000000..cf48dd3131378 --- /dev/null +++ b/op-guide/clustering.md @@ -0,0 +1,250 @@ +# Clustering + +## Overview + +A TiDB cluster contains PD, TiKV, TiDB. The start-up sequence is PD -> TiKV -> TiDB. + +## A standalone cluster + +1. Start PD. + ```bash + pd-server --cluster-id=1 \ + --host=127.0.0.1 \ + --data-dir=pd + ``` +2. Start TiKV. + ```bash + tikv-server -I 1 \ + -S raftkv \ + --addr 127.0.0.1:20160 \ + --pd 127.0.0.1:2379 \ + -S tikv + ``` + +3. Start TiDB. + ```bash + tidb-server --store=tikv \ + --path="127.0.0.1:2379/pd?cluster=1" + -P 5001 + ``` + +4. Use the official `mysql` client to connect to TiDB and enjoy it. + + ```sh + mysql -h 127.0.0.1 -P 5001 -u root -D test + ``` + +## A 3-nodes multi-machine cluster + +Assume we have three machines with the following details: + +|Name|Address| +|----|-------| +|node1|192.168.199.113| +|node2|192.168.199.114| +|node3|192.168.199.115| + +In every node, we will run one PD and one TiKV. We will run one TiDB in node1. + +1. Start PDs. + + ```bash + pd-server --host=192.168.199.113 \ + --cluster-id=1 \ + --name=pd1 \ + --data-dir=pd1 \ + --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" + + pd-server --host=192.168.199.114 \ + --cluster-id=1 \ + --name=pd2 \ + --data-dir=pd2 \ + --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" + + pd-server --host=192.168.199.115 \ + --cluster-id=1 \ + --name=pd3 \ + --data-dir=pd3 \ + --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" + ``` + +2. Start TiKVs. + + ```bash + tikv-server -S raftkv \ + -I 1 \ + --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ + -A 192.168.199.113:20160 \ + -s tikv1 + + tikv-server -S raftkv \ + -I 1 \ + --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ + -A 192.168.199.114:20160 \ + -s tikv2 + + tikv-server -S raftkv \ + -I 1 \ + --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ + -A 192.168.199.115:20160 \ + -s tikv3 + ``` + +3. Start TiDB. + + ```bash + tidb-server --store=tikv \ + --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379/pd?cluster=1" \ + -P 5001 + ``` + +4. Use the official `mysql` client to connect to TiDB and enjoy it. + + ```sh + mysql -h 192.168.199.113 -P 5001 -u root -D test + ``` + +## A local cluster with `docker-compose` + +A simple `docker-compose.yml`: + +```bash +version: '2' + +services: + pd1: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd1 + - --name=pd1 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + pd2: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd2 + - --name=pd2 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + pd3: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd3 + - --name=pd3 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + tikv1: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv1:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tikv2: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv2:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tikv3: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv3:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tidb: + image: pingcap/tidb + ports: + - "4000" + + command: + - --store=tikv + - --path=pd1:2379,pd2:2379,pd3:2379/pd?cluster=1 + - -L=warn + + depends_on: + - "tikv1" + - "tikv2" + - "tikv3" + + privileged: true +``` + ++ Use `docker-compose up -d` to create and start the cluster. ++ Use `docker-compose port tidb 4000` to print the TiDB host port. For example, if the output is `0.0.0.0:32966`, the TiDB host port is `32966`. ++ Use `mysql -h 127.0.0.1 -P 32966 -u root -D test` to connect to TiDB and enjoy it. ++ Use `docker-compose down` to stop and remove the cluster. \ No newline at end of file From 0740fb1eb8cad578a0783e0a0b56fdce622d8b41 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 09:04:36 +0800 Subject: [PATCH 02/11] op-guide: Address comment. --- op-guide/clustering.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index cf48dd3131378..a3f3ab49e9d93 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -94,14 +94,13 @@ In every node, we will run one PD and one TiKV. We will run one TiDB in node1. ```bash tidb-server --store=tikv \ - --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379/pd?cluster=1" \ - -P 5001 + --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379/pd?cluster=1" ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. ```sh - mysql -h 192.168.199.113 -P 5001 -u root -D test + mysql -h 192.168.199.113 -P 4000 -u root -D test ``` ## A local cluster with `docker-compose` From 7fb770c475150028bb7863d9b9d8a8b1132679a5 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 13:44:53 +0800 Subject: [PATCH 03/11] op-guide: Address comment. --- op-guide/clustering.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index a3f3ab49e9d93..0851849ac614b 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -2,7 +2,7 @@ ## Overview -A TiDB cluster contains PD, TiKV, TiDB. The start-up sequence is PD -> TiKV -> TiDB. +A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> TiKV -> TiDB. ## A standalone cluster @@ -34,19 +34,19 @@ A TiDB cluster contains PD, TiKV, TiDB. The start-up sequence is PD -> TiKV -> T mysql -h 127.0.0.1 -P 5001 -u root -D test ``` -## A 3-nodes multi-machine cluster +## A 3-node multi-machine cluster Assume we have three machines with the following details: -|Name|Address| +|Name|Host IP| |----|-------| |node1|192.168.199.113| |node2|192.168.199.114| |node3|192.168.199.115| -In every node, we will run one PD and one TiKV. We will run one TiDB in node1. +We run PD and TiKV on every node and TiDB on node1 only. -1. Start PDs. +1. Start PD on every node. ```bash pd-server --host=192.168.199.113 \ @@ -68,7 +68,7 @@ In every node, we will run one PD and one TiKV. We will run one TiDB in node1. --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" ``` -2. Start TiKVs. +2. Start TiKV on every node. ```bash tikv-server -S raftkv \ @@ -90,7 +90,7 @@ In every node, we will run one PD and one TiKV. We will run one TiDB in node1. -s tikv3 ``` -3. Start TiDB. +3. Start TiDB on node1. ```bash tidb-server --store=tikv \ @@ -107,6 +107,7 @@ In every node, we will run one PD and one TiKV. We will run one TiDB in node1. A simple `docker-compose.yml`: + ```bash version: '2' From 009c3e25f89a8c73677f560226470545ff266f4e Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 14:36:14 +0800 Subject: [PATCH 04/11] op-guide: move to docker doc. --- op-guide/clustering.md | 147 +---------------------------------------- op-guide/docker.md | 147 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 146 deletions(-) create mode 100644 op-guide/docker.md diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 0851849ac614b..6d48fd519538a 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -102,149 +102,4 @@ We run PD and TiKV on every node and TiDB on node1 only. ```sh mysql -h 192.168.199.113 -P 4000 -u root -D test ``` - -## A local cluster with `docker-compose` - -A simple `docker-compose.yml`: - - -```bash -version: '2' - -services: - pd1: - image: pingcap/pd - ports: - - "1234" - - "9090" - - "2379" - - "2380" - - command: - - --cluster-id=1 - - --host=pd1 - - --name=pd1 - - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - - privileged: true - - pd2: - image: pingcap/pd - ports: - - "1234" - - "9090" - - "2379" - - "2380" - - command: - - --cluster-id=1 - - --host=pd2 - - --name=pd2 - - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - - privileged: true - - pd3: - image: pingcap/pd - ports: - - "1234" - - "9090" - - "2379" - - "2380" - - command: - - --cluster-id=1 - - --host=pd3 - - --name=pd3 - - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - - privileged: true - - tikv1: - image: pingcap/tikv - ports: - - "20160" - - command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv1:20160 - - --cluster-id=1 - - --dsn=raftkv - - --store=/var/tikv - - --pd=pd1:2379,pd2:2379,pd3:2379 - - depends_on: - - "pd1" - - "pd2" - - "pd3" - - entrypoint: /tikv-server - - privileged: true - - tikv2: - image: pingcap/tikv - ports: - - "20160" - - command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv2:20160 - - --cluster-id=1 - - --dsn=raftkv - - --store=/var/tikv - - --pd=pd1:2379,pd2:2379,pd3:2379 - - depends_on: - - "pd1" - - "pd2" - - "pd3" - - entrypoint: /tikv-server - - privileged: true - - tikv3: - image: pingcap/tikv - ports: - - "20160" - - command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv3:20160 - - --cluster-id=1 - - --dsn=raftkv - - --store=/var/tikv - - --pd=pd1:2379,pd2:2379,pd3:2379 - - depends_on: - - "pd1" - - "pd2" - - "pd3" - - entrypoint: /tikv-server - - privileged: true - - tidb: - image: pingcap/tidb - ports: - - "4000" - - command: - - --store=tikv - - --path=pd1:2379,pd2:2379,pd3:2379/pd?cluster=1 - - -L=warn - - depends_on: - - "tikv1" - - "tikv2" - - "tikv3" - - privileged: true -``` - -+ Use `docker-compose up -d` to create and start the cluster. -+ Use `docker-compose port tidb 4000` to print the TiDB host port. For example, if the output is `0.0.0.0:32966`, the TiDB host port is `32966`. -+ Use `mysql -h 127.0.0.1 -P 32966 -u root -D test` to connect to TiDB and enjoy it. -+ Use `docker-compose down` to stop and remove the cluster. \ No newline at end of file + \ No newline at end of file diff --git a/op-guide/docker.md b/op-guide/docker.md new file mode 100644 index 0000000000000..d8d00344374a5 --- /dev/null +++ b/op-guide/docker.md @@ -0,0 +1,147 @@ +# Docker + +## Run with `docker-compose` + +A simple `docker-compose.yml`: + + +```bash +version: '2' + +services: + pd1: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd1 + - --name=pd1 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + pd2: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd2 + - --name=pd2 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + pd3: + image: pingcap/pd + ports: + - "1234" + - "9090" + - "2379" + - "2380" + + command: + - --cluster-id=1 + - --host=pd3 + - --name=pd3 + - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 + + privileged: true + + tikv1: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv1:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tikv2: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv2:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tikv3: + image: pingcap/tikv + ports: + - "20160" + + command: + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv3:20160 + - --cluster-id=1 + - --dsn=raftkv + - --store=/var/tikv + - --pd=pd1:2379,pd2:2379,pd3:2379 + + depends_on: + - "pd1" + - "pd2" + - "pd3" + + entrypoint: /tikv-server + + privileged: true + + tidb: + image: pingcap/tidb + ports: + - "4000" + + command: + - --store=tikv + - --path=pd1:2379,pd2:2379,pd3:2379/pd?cluster=1 + - -L=warn + + depends_on: + - "tikv1" + - "tikv2" + - "tikv3" + + privileged: true +``` + ++ Use `docker-compose up -d` to create and start the cluster. ++ Use `docker-compose port tidb 4000` to print the TiDB host port. For example, if the output is `0.0.0.0:32966`, the TiDB host port is `32966`. ++ Use `mysql -h 127.0.0.1 -P 32966 -u root -D test` to connect to TiDB and enjoy it. ++ Use `docker-compose down` to stop and remove the cluster. \ No newline at end of file From d77a0dc5c4f635ebfae3794c531f0c826fd0fc85 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 14:41:24 +0800 Subject: [PATCH 05/11] op-guide: Address comment. --- op-guide/clustering.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 6d48fd519538a..10ed51373be58 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -25,13 +25,12 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash tidb-server --store=tikv \ --path="127.0.0.1:2379/pd?cluster=1" - -P 5001 ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. ```sh - mysql -h 127.0.0.1 -P 5001 -u root -D test + mysql -h 127.0.0.1 -P 4000 -u root -D test ``` ## A 3-node multi-machine cluster @@ -102,4 +101,3 @@ We run PD and TiKV on every node and TiDB on node1 only. ```sh mysql -h 192.168.199.113 -P 4000 -u root -D test ``` - \ No newline at end of file From 85d1276b1ccdfe50bdf9ac5b9a5c993e5b716de8 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 14:42:49 +0800 Subject: [PATCH 06/11] op-guide: Address comment. --- op-guide/clustering.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 10ed51373be58..5b5bdc624ab93 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -7,12 +7,15 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ## A standalone cluster 1. Start PD. + ```bash pd-server --cluster-id=1 \ --host=127.0.0.1 \ --data-dir=pd ``` + 2. Start TiKV. + ```bash tikv-server -I 1 \ -S raftkv \ @@ -22,6 +25,7 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ``` 3. Start TiDB. + ```bash tidb-server --store=tikv \ --path="127.0.0.1:2379/pd?cluster=1" From d861f7052777aee16ce9b03ed445c560caa22dc7 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 14:55:46 +0800 Subject: [PATCH 07/11] op-guide: Address comment. --- op-guide/clustering.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 5b5bdc624ab93..0eebd29600a81 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -77,19 +77,19 @@ We run PD and TiKV on every node and TiDB on node1 only. tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - -A 192.168.199.113:20160 \ + --addr 192.168.199.113:20160 \ -s tikv1 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - -A 192.168.199.114:20160 \ + --addr 192.168.199.114:20160 \ -s tikv2 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - -A 192.168.199.115:20160 \ + --addr 192.168.199.115:20160 \ -s tikv3 ``` From 20f81adf6dbe25538a1114a7286d4f2eee902301 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 27 Jul 2016 16:36:02 +0800 Subject: [PATCH 08/11] op-guide: update TiKV --- op-guide/clustering.md | 8 ++++---- op-guide/docker.md | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 0eebd29600a81..d3dc2c924be4c 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -19,7 +19,7 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash tikv-server -I 1 \ -S raftkv \ - --addr 127.0.0.1:20160 \ + --host=127.0.0.1 \ --pd 127.0.0.1:2379 \ -S tikv ``` @@ -77,19 +77,19 @@ We run PD and TiKV on every node and TiDB on node1 only. tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --addr 192.168.199.113:20160 \ + --host 192.168.199.113 \ -s tikv1 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --addr 192.168.199.114:20160 \ + --host 192.168.199.114 \ -s tikv2 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --addr 192.168.199.115:20160 \ + --host 192.168.199.115 \ -s tikv3 ``` diff --git a/op-guide/docker.md b/op-guide/docker.md index d8d00344374a5..5b47a4c1572e8 100644 --- a/op-guide/docker.md +++ b/op-guide/docker.md @@ -63,8 +63,7 @@ services: - "20160" command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv1:20160 + - --host=tikv1 - --cluster-id=1 - --dsn=raftkv - --store=/var/tikv @@ -85,8 +84,7 @@ services: - "20160" command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv2:20160 + - --host=tikv2 - --cluster-id=1 - --dsn=raftkv - --store=/var/tikv @@ -107,8 +105,7 @@ services: - "20160" command: - - --addr=0.0.0.0:20160 - - --advertise-addr=tikv3:20160 + - --host=tikv3 - --cluster-id=1 - --dsn=raftkv - --store=/var/tikv From 8e24c598f9502c3d0c971db244f1dd52164b282c Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 28 Jul 2016 16:25:58 +0800 Subject: [PATCH 09/11] op-guide: update flags. --- op-guide/clustering.md | 30 +++++++++++++++++------------- op-guide/docker.md | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index d3dc2c924be4c..6b88b4763795c 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -10,7 +10,6 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash pd-server --cluster-id=1 \ - --host=127.0.0.1 \ --data-dir=pd ``` @@ -19,7 +18,6 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash tikv-server -I 1 \ -S raftkv \ - --host=127.0.0.1 \ --pd 127.0.0.1:2379 \ -S tikv ``` @@ -28,7 +26,7 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash tidb-server --store=tikv \ - --path="127.0.0.1:2379/pd?cluster=1" + --path="127.0.0.1:2379?cluster=1" ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. @@ -52,22 +50,28 @@ We run PD and TiKV on every node and TiDB on node1 only. 1. Start PD on every node. ```bash - pd-server --host=192.168.199.113 \ - --cluster-id=1 \ + pd-server --cluster-id=1 \ --name=pd1 \ --data-dir=pd1 \ + --addr="192.168.199.113:1234" \ + --client-urls="http://192.168.199.113:2379" \ + --peer-urls="http://192.168.199.113:2380" \ --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" - pd-server --host=192.168.199.114 \ - --cluster-id=1 \ + pd-server --cluster-id=1 \ --name=pd2 \ --data-dir=pd2 \ + --addr="192.168.199.114:1234" \ + --client-urls="http://192.168.199.114:2379" \ + --peer-urls="http://192.168.199.114:2380" \ --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" - pd-server --host=192.168.199.115 \ - --cluster-id=1 \ + pd-server --cluster-id=1 \ --name=pd3 \ --data-dir=pd3 \ + --addr="192.168.199.115:1234" \ + --client-urls="http://192.168.199.115:2379" \ + --peer-urls="http://192.168.199.115:2380" \ --initial-cluster="pd1=http://192.168.199.113:2380,pd2=http://192.168.199.114:2380,pd3=http://192.168.199.115:2380" ``` @@ -77,19 +81,19 @@ We run PD and TiKV on every node and TiDB on node1 only. tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --host 192.168.199.113 \ + --addr 192.168.199.113:20160 \ -s tikv1 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --host 192.168.199.114 \ + --addr 192.168.199.113:20160 \ -s tikv2 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --host 192.168.199.115 \ + --addr 192.168.199.113:20160 \ -s tikv3 ``` @@ -97,7 +101,7 @@ We run PD and TiKV on every node and TiDB on node1 only. ```bash tidb-server --store=tikv \ - --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379/pd?cluster=1" + --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379?cluster=1" ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. diff --git a/op-guide/docker.md b/op-guide/docker.md index 5b47a4c1572e8..e036755f9bcf1 100644 --- a/op-guide/docker.md +++ b/op-guide/docker.md @@ -19,10 +19,15 @@ services: command: - --cluster-id=1 - - --host=pd1 - --name=pd1 + - --client-urls=http://0.0.0.0:2379 + - --peer-urls=http://0.0.0.0:2380 + - --advertise-client-urls=http://pd1:2379 + - --advertise-peer-urls=http://pd1:2380 - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - + - --addr=0.0.0.0:1234 + - --advertise-addr=pd1:1234 + privileged: true pd2: @@ -35,10 +40,15 @@ services: command: - --cluster-id=1 - - --host=pd2 - --name=pd2 + - --client-urls=http://0.0.0.0:2379 + - --peer-urls=http://0.0.0.0:2380 + - --advertise-client-urls=http://pd2:2379 + - --advertise-peer-urls=http://pd2:2380 - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - + - --addr=0.0.0.0:1234 + - --advertise-addr=pd2:1234 + privileged: true pd3: @@ -51,10 +61,15 @@ services: command: - --cluster-id=1 - - --host=pd3 - --name=pd3 + - --client-urls=http://0.0.0.0:2379 + - --peer-urls=http://0.0.0.0:2380 + - --advertise-client-urls=http://pd3:2379 + - --advertise-peer-urls=http://pd3:2380 - --initial-cluster=pd1=http://pd1:2380,pd2=http://pd2:2380,pd3=http://pd3:2380 - + - --addr=0.0.0.0:1234 + - --advertise-addr=pd3:1234 + privileged: true tikv1: @@ -63,8 +78,9 @@ services: - "20160" command: - - --host=tikv1 - --cluster-id=1 + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv1:20160 - --dsn=raftkv - --store=/var/tikv - --pd=pd1:2379,pd2:2379,pd3:2379 @@ -84,8 +100,9 @@ services: - "20160" command: - - --host=tikv2 - --cluster-id=1 + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv2:20160 - --dsn=raftkv - --store=/var/tikv - --pd=pd1:2379,pd2:2379,pd3:2379 @@ -105,8 +122,9 @@ services: - "20160" command: - - --host=tikv3 - --cluster-id=1 + - --addr=0.0.0.0:20160 + - --advertise-addr=tikv3:20160 - --dsn=raftkv - --store=/var/tikv - --pd=pd1:2379,pd2:2379,pd3:2379 @@ -127,7 +145,7 @@ services: command: - --store=tikv - - --path=pd1:2379,pd2:2379,pd3:2379/pd?cluster=1 + - --path=pd1:2379,pd2:2379,pd3:2379?cluster=1 - -L=warn depends_on: From ba7c637a6d5727248ce7f5e1c5e7c33be918d402 Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 28 Jul 2016 17:29:20 +0800 Subject: [PATCH 10/11] *: update build and clustering. --- op-guide/clustering.md | 12 ++++++------ scripts/build.sh | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/op-guide/clustering.md b/op-guide/clustering.md index 6b88b4763795c..401f5bc64b835 100644 --- a/op-guide/clustering.md +++ b/op-guide/clustering.md @@ -10,7 +10,7 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> ```bash pd-server --cluster-id=1 \ - --data-dir=pd + --data-dir=pd ``` 2. Start TiKV. @@ -19,14 +19,14 @@ A complete TiDB project contains PD, TiKV, TiDB. The start-up sequence is PD -> tikv-server -I 1 \ -S raftkv \ --pd 127.0.0.1:2379 \ - -S tikv + -s tikv ``` 3. Start TiDB. ```bash tidb-server --store=tikv \ - --path="127.0.0.1:2379?cluster=1" + --path="127.0.0.1:2379?cluster=1" ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. @@ -87,13 +87,13 @@ We run PD and TiKV on every node and TiDB on node1 only. tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --addr 192.168.199.113:20160 \ + --addr 192.168.199.114:20160 \ -s tikv2 tikv-server -S raftkv \ -I 1 \ --pd 192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379 \ - --addr 192.168.199.113:20160 \ + --addr 192.168.199.115:20160 \ -s tikv3 ``` @@ -101,7 +101,7 @@ We run PD and TiKV on every node and TiDB on node1 only. ```bash tidb-server --store=tikv \ - --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379?cluster=1" + --path="192.168.199.113:2379,192.168.199.114:2379,192.168.199.115:2379?cluster=1" ``` 4. Use the official `mysql` client to connect to TiDB and enjoy it. diff --git a/scripts/build.sh b/scripts/build.sh index cb07fb74edcb6..7e441660581ec 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,7 +3,7 @@ set -e # Use current path for building and installing TiDB. -TIDB_PATH=`PWD` +TIDB_PATH=`pwd` echo "building TiDB components in $TIDB_PATH" # All the binaries are installed in the `bin` directory. @@ -25,7 +25,7 @@ rustc -V # GOPATH should be set correctly. export GOPATH=$TIDB_PATH/deps/go -build TiDB +# build TiDB echo "building TiDB..." rm -rf $GOPATH/src/github.com/pingcap/tidb git clone --depth=1 https://github.com/pingcap/tidb.git $GOPATH/src/github.com/pingcap/tidb From a4a4680496c0a6848197f8a795c59235a3965375 Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 29 Jul 2016 10:07:38 +0800 Subject: [PATCH 11/11] op-guide: Address comment. --- op-guide/docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op-guide/docker.md b/op-guide/docker.md index e036755f9bcf1..e6f76a54957d7 100644 --- a/op-guide/docker.md +++ b/op-guide/docker.md @@ -157,6 +157,6 @@ services: ``` + Use `docker-compose up -d` to create and start the cluster. -+ Use `docker-compose port tidb 4000` to print the TiDB host port. For example, if the output is `0.0.0.0:32966`, the TiDB host port is `32966`. ++ Use `docker-compose port tidb 4000` to print the TiDB public port. For example, if the output is `0.0.0.0:32966`, the TiDB public port is `32966`. + Use `mysql -h 127.0.0.1 -P 32966 -u root -D test` to connect to TiDB and enjoy it. + Use `docker-compose down` to stop and remove the cluster. \ No newline at end of file