From a449dff523dd8d8db9c203f9bbeaecf4bb8809dd Mon Sep 17 00:00:00 2001 From: lilin90 Date: Mon, 21 May 2018 17:00:22 +0800 Subject: [PATCH 01/12] *: add TiKV Quick Start Guide --- README.md | 2 + media/tikv_stack.png | Bin 0 -> 22315 bytes tikv/tikv-quick-start-guide.md | 512 +++++++++++++++++++++++++++++++++ 3 files changed, 514 insertions(+) create mode 100644 media/tikv_stack.png create mode 100644 tikv/tikv-quick-start-guide.md diff --git a/README.md b/README.md index 891c545e15e5f..6537b05ad91c9 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,8 @@ - [PD Control](tools/pd-control.md) - [TiKV Control](tools/tikv-control.md) - [TiDB Controller](tools/tidb-controller.md) ++ TiKV + - [TiKV Quick Start Guide](tikv/tikv-quick-start-guide.md) + TiSpark - [Quick Start Guide](tispark/tispark-quick-start-guide.md) - [User Guide](tispark/tispark-user-guide.md) diff --git a/media/tikv_stack.png b/media/tikv_stack.png new file mode 100644 index 0000000000000000000000000000000000000000..4f8b1b6d4d45ee79fa01102c0b80c09d10059c47 GIT binary patch literal 22315 zcmbTd2UJsC(?5!$6qOF5R1xVl(xi)2AvEbVf>J`25_(gRrhq(BLJ25HLhnUF6QxOq z&>^5=XrV~xHTU52zTbEM>#lY0S~rUoPEO95J!kgJ?B8$pB+fujlj<7FH4+jMs>fPt zPe@2EV@OCYK`F?9Gq$>)+DJ%D36IrOj00vi5L9pzlj#GR{*0~Lx1L5_(#)oXadZxy zK2-lUEIuL*G6Y_rZ7=O7r`q8A!a?^W9)0_IN)cN1hmL9i{5Y^593=Vu57ql?*EvUe z0vO+;_k+)~>Y}BxLLHa-Wt|4+mruhcVGy6ebGhLCmPtz@Y%917p#|vi|LgUT($Lnn z3SC_s#2sySE4p*K_n+^aBgIa-&w9I9vi_+q5@-^2s4=Rq^t6~haK*3XlopqVl_Tr- zVF$-%#>TCAxX|O>zz203zf!Os`&rOLiD@=}-(Hr_V+N9+u5}`riM5^I#BY47d|+i^ z;Z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mS*z;}X59rG3R{qHzG+dr}oPyzxFBl9*Z9}M9iJn%;BqHKlyH{GuFVvS_p^sGrIH01$tYUM((=8zD-9}$7?bV3@9nh& zxQbLlOG?|z*KnA(yzJRM-g+b8mexpnAgTJE)Oo2OA)39IF||3w&R``JpEqf&te@Y8 zq|Im|w};NO&}M8RdOcGb&=npQ93#&)Ll?ycizXTZw3}QU!aq40KIV2|@Fc)%|0uKI z3q%?^&xIt#y6gQKe}_{0G9d7BSpM>RMUNhZW;Z=kdS?A%j^AU->OHuzZ>H~Dw^9x@ z!3M3jN%X)VB@fZCm`UmSpu0KEvr3;mY%k>>vSRN?kud9%}xDz64pfDN96RL zZC4_SjRhwsbl!!K#L7sIJ&_VGsoJ;whH}~$y2#9(6Yo1I(0htC8SS}XG-t!S1gspp zJ7)LczxKBOaVzap(9q@r45`p}CW%iKgrcPk-Zkuy^*;&%6PT>t6=t0VLB4!4Y~JzA z`UO0ltcz*&EsbfFJh&$PqcRXOi8GFq`rInXkZpw+Fc7j50Mh?YrQp8zX2nc%5(|(F z9y5T_g#%9bA&IBx{SE8$={>>e(`V_o8mWB<=RwJmg79Em=+@Qoyy=>K>*X^)jr(72 g9Q;51*}aj$j(>xlnBeJ)WWMs4xeeyA>6zGn0S3sAB>(^b literal 0 HcmV?d00001 diff --git a/tikv/tikv-quick-start-guide.md b/tikv/tikv-quick-start-guide.md new file mode 100644 index 0000000000000..fade2c5a11e0d --- /dev/null +++ b/tikv/tikv-quick-start-guide.md @@ -0,0 +1,512 @@ +--- +title: TiKV Quick Start Guide +category: quick start +--- + +# TiKV Quick Start Guide + +TiKV (The pronunciation is: /'taɪkeɪvi:/ tai-K-V, etymology: titanium) is a distributed Key-Value database which is based on the design of Google Spanner and HBase, but it is much simpler without dependency on any distributed file system. + +As the storage layer of TiDB, TiKV can work separately and does not depend on the SQL layer of TiDB. TiKV provides two APIs for developers: the Raw Key-Value API and the Transactional Key-Value API. + +This guide describes how to quickly deploy a TiKV cluster on a single machine and how to use the TiKV cluster through APIs written in Go. + +The TiKV server software stack is as follows: + +![The TiKV software stack](../media/tikv_stack.png) + +## Prepare + +TiKV can be deployed in the Intel architecture server and major virtualization environments, and it supports most of the major hardware networks and Linux operating systems. + +Currently, TiKV provides two APIs: the Raw Key-Value API and the Transactional Key-Value API. This guide uses the APIs written in Go. To write the API, you need to install Go: + +- Make sure ​Go​ (version 1.8+) is installed. +- Ensure your `$GOPATH` is set. (For example, `export GOPATH=$HOME/go`) + +## Deploy the TiKV cluster + +TiKV provides the official binary installation package that supports Linux. + +- To quickly understand and try TiKV, see [Deploy the TiKV cluster on a single machine](#deploy-the-tikv-cluster-on-a-single-machine). +- To try TiKV out and explore the features, see [Deploy the TiKV cluster on multiple nodes for test](#deploy-the-tikv-cluster-on-multiple-nodes-for-test). + +### Deploy the TiKV cluster on a single machine + +This section describes how to deploy 1 PD instance and 3 TiKV instances on a single machine installed with the Linux system. + +> **Note:** +> +> - For the production environment, it is recommended to use multiple nodes cluster deployment. Before you begin, see [Software and Hardware Requirements](op-guide/recommendation.md). +> - Before starting the process, make sure the result of `ulimit -n` is large enough. It is recommended to set the value to `unlimited` or larger than 1000000. + +To deploy a TiKV cluster on a single machine for test, take the following steps: + +1. Download the official binary package. + + ``` + # Download the package. + wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz + wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 + + # Check the file integrity. If the result is OK, the file is correct. + sha256sum -c tidb-latest-linux-amd64.sha256 + + # Extract the package. + tar -xzf tidb-latest-linux-amd64.tar.gz + cd tidb-latest-linux-amd64 + ``` + +2. Start PD. + + ``` + ./bin/pd-server --name=pd1 \ + --data-dir=pd1 \ + --client-urls="http://127.0.0.1:2379" \ + --peer-urls="http://127.0.0.1:2380" \ + --initial-cluster="pd1=http://127.0.0.1:2380" \ + --log-file=pd1.log + ``` + +3. Start TiKV. + + To start the 3 TiKV instances, open a new terminal tab or window, come to the `tidb-latest-linux-amd64` directory, and start the instances using the following command: + + ``` + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20160" \ + --data-dir=tikv1 \ + --log-file=tikv1.log + + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20161" \ + --data-dir=tikv2 \ + --log-file=tikv2.log + + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20162" \ + --data-dir=tikv3 \ + --log-file=tikv3.log + ``` + +You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: + +``` +./bin/pd-ctl store -d -u http://127.0.0.1:2379 +``` + +To access the data in TiKV, you can [try TiKV using the Raw Key-Value API and Transactional Key-Value API](#try-tikv-using-the-raw-key-value-api-and-transactional-key-value-api). + +### Deploy the TiKV cluster on multiple nodes for test + +This section describes how to deploy TiKV on multiple nodes. If you want to test TiKV with a limited number of nodes, you can use one PD instance to test the entire cluster. + +Assume that you have four nodes, you can deploy 1 PD instance and 3 TiKV instances. For details, see the following table: + +| Name | Host IP | Services | +| :-- | :-- | :------------------- | +| Node1 | 192.168.199.113 | PD1 | +| Node2 | 192.168.199.114 | TiKV1 | +| Node3 | 192.168.199.115 | TiKV2 | +| Node4 | 192.168.199.116 | TiKV3 | + +To deploy a TiKV cluster with multiple nodes for test, take the following steps: + +1. To deploy a TiKV cluster with multiple nodes for test, take the following steps: + + ``` + # Download the package. + wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz + wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 + + # Check the file integrity. If the result is OK, the file is correct. + sha256sum -c tidb-latest-linux-amd64.sha256 + + # Extract the package. + tar -xzf tidb-latest-linux-amd64.tar.gz + cd tidb-latest-linux-amd64 + ``` + +2. Start PD on Node1. + + ``` + ./bin/pd-server --name=pd1 \ + --data-dir=pd1 \ + --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" \ + --log-file=pd1.log + ``` + +3. Log in and start TiKV on other nodes: Node2, Node3 and Node4. + + Node2: + + ``` + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.114:20160" \ + --data-dir=tikv1 \ + --log-file=tikv1.log + ``` + + Node3: + + ``` + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.115:20160" \ + --data-dir=tikv2 \ + --log-file=tikv2.log + ``` + + Node4: + + ``` + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.116:20160" \ + --data-dir=tikv3 \ + --log-file=tikv3.log + ``` + +You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: + +``` +./pd-ctl store -d -u http://192.168.199.113:2379 +``` + +The result displays the store count and detailed information regarding each store. + +## Try TiKV using the Raw Key-Value API and Transactional Key-Value API + +This section introduces two types of APIs and guides you through how to use the two APIs in TiKV using two examples. The usage examples are based on the [deployment of TiKV on multiple nodes](#deploy-the-tikv-cluster-on-multiple-nodes-for-test) in the above section. You can also quickly try the two APIs on a single machine. + +### Two types of APIs + +To apply to different scenarios, TiKV provides two types of APIs for developers: + +- The Raw Key-Value API + + If your application scenario does not need distributed transactions or MVCC (Multi-Version Concurrency Control) and only need to guarantee the atomicity towards one key, you can use the Raw Key-Value API. + +- The Transactional Key-Value API + + If your application scenario requires distributed ACID transactions and the atomicity of multiple keys within a transaction, you can use the Transactional Key-Value API. + +Compared to the Transactional Key-Value API, the Raw Key-Value API is more performant with lower latency and easier to use. + +### Use the Raw Key-Value API + +To use the Raw Key-Value API in applications developed by golang, take the following steps: + +1. Install the necessary packages. + + ``` + go get -v -u github.com/pingcap/tidb/config + go get -v -u github.com/pingcap/tidb/store/tikv + ``` + +2. Import the dependency packages. + + ``` + import ( + "fmt" + "github.com/pingcap/tidb/config" + "github.com/pingcap/tidb/store/tikv" + ) + ``` + +3. Create a Raw Key-Value client. + + ``` + cli, err := tikv.NewRawKVClient([]string{"192.168.199.113:2379"}, config.Security{}) + ``` + + Description of two parameters in the above command: + + - `string`: a list of PD servers’ addresses + - `config.Security`: used for establishing TLS connections, usually left empty when you do not need TLS + +4. Call the Raw Key-Value client methods to access the data on TiKV. The Raw Key-Value API contains the following methods, and you can also find them at [GoDoc](https://godoc.org/github.com/pingcap/tidb/store/tikv#RawKVClient). + + ``` + type RawKVClient struct + func (c *RawKVClient) Close() error + func (c *RawKVClient) ClusterID() uint64 + func (c *RawKVClient) Delete(key []byte) error + func (c *RawKVClient) Get(key []byte) ([]byte, error) + func (c *RawKVClient) Put(key, value []byte) error + func (c *RawKVClient) Scan(startKey []byte, limit int) (keys [][]byte, values [][]byte, err error) + ``` + +#### Usage example of the Raw Key-Value API + +``` +package main + +import ( + "fmt" + + "github.com/pingcap/tidb/config" + "github.com/pingcap/tidb/store/tikv" +) + +func main() { + cli, err := tikv.NewRawKVClient([]string{"192.168.199.113:2379"}, config.Security{}) + if err != nil { + panic(err) + } + defer cli.Close() + + fmt.Printf("cluster ID: %d\n", cli.ClusterID()) + + key := []byte("Company") + val := []byte("PingCAP") + + // put key into tikv + err = cli.Put(key, val) + if err != nil { + panic(err) + } + fmt.Printf("Successfully put %s:%s to tikv\n", key, val) + + // get key from tikv + val, err = cli.Get(key) + if err != nil { + panic(err) + } + fmt.Printf("found val: %s for key: %s\n", val, key) + + // delete key from tikv + err = cli.Delete(key) + if err != nil { + panic(err) + } + fmt.Printf("key: %s deleted\n", key) + + // get key again from tikv + val, err = cli.Get(key) + if err != nil { + panic(err) + } + fmt.Printf("found val: %s for key: %s\n", val, key) +} +``` + +The result is like: + +``` +INFO[0000] [pd] create pd client with endpoints [192.168.199.113:2379] +INFO[0000] [pd] leader switches to: http://127.0.0.1:2379, previous: +INFO[0000] [pd] init cluster id 6554145799874853483 +cluster ID: 6554145799874853483 +Successfully put Company:PingCAP to tikv +found val: PingCAP for key: Company +key: Company deleted +found val: for key: Company +``` + +RawKVClient is a client of the TiKV server and only supports the GET/PUT/DELETE/SCAN commands. The RawKVClient can be safely and concurrently accessed by multiple goroutines, as long as it is not closed. Therefore, for one process, one client is enough generally. + +### Use the Transactional Key-Value API + +The Transactional Key-Value API is complicated than the Raw Key-Value API. Some transaction related concepts are listed as follows. For more details, see the [KV package](https://github.com/pingcap/tidb/tree/master/kv). + +- Storage + + Like the RawKVClient, a Storage is an abstract TiKV cluster. + +- Snapshot + + A Snapshot is the state of a Storage at a particular point of time, which provides some readonly methods. The multiple times read from a same Snapshot is guaranteed consistent. + +- Transaction + + Like the Transaction in SQL, a Transaction symbolizes a series of read and write operations performed within the Storage. Internally, a Transaction consists of a Snapshot for reads, and a MemBuffer for all writes. The default isolation level of a Transaction is Snapshot Isolation. + +To use the Transactional Key-Value API in applications developed by golang, take the following steps: + +1. Install the necessary packages. + + ``` + go get -v -u github.com/pingcap/tidb/kv + go get -v -u github.com/pingcap/tidb/store/tikv + ``` + +2. Import the dependency packages. + + ``` + import ( + "github.com/pingcap/tidb/kv" + "github.com/pingcap/tidb/store/tikv" + "fmt" + ) + ``` + +3. Create Storage using a URL scheme. + + ``` + driver := tikv.Driver{} + storage, err := driver.Open("tikv://192.168.199.113:2379") + ``` + +4. (Optional) Modify the Storage using a Transaction. + + The lifecycle of a Transaction is: _begin → {get, set, delete, scan} → {commit, rollback}_. + + Here is an example to increase a key-value by 1: + + ``` + func increase(storage kv.Storage, key []byte) error { + txn, err := storage.Begin() + if err != nil { + return err + } + defer txn.Rollback() + var oldValue int + val, err := txn.Get(key) + if err != nil { + if !kv.ErrNotExist.Equal(err) { + return err + } + } else { + oldValue, err = strconv.ParseInt(string(val), 10, 32) + if err != nil { + return err + } + } + err = txn.Set(key, []byte(strconv.Itoa(oldValue+1))) + if err != nil { + return err + } + err = txn.Commit(context.Background()) + return err + } + ``` + + > **Note:** If a key does not exist, `Get` returns a `kv.ErrNotExist` error. + +5. Call the Transactional Key-Value API's methods to access the data on TiKV. The Transactional Key-Value API contains the following methods: + + ``` + Begin() -> Txn + Txn.Get(key []byte) -> (value []byte) + Txn.Set(key []byte, value []byte) + Txn.Seek(begin []byte) -> Iterator + Txn.Delete(key []byte) + Txn.Commit() + ``` + +#### Usage example of the Transactional Key-Value API + +``` +package main + +import ( + "context" + "fmt" + "strconv" + + "github.com/pingcap/tidb/kv" + "github.com/pingcap/tidb/store/tikv" +) + +// if key not found, set value to zero +// else increase the value +func increase(storage kv.Storage, key []byte) error { + txn, err := storage.Begin() + if err != nil { + return err + } + defer txn.Rollback() + var oldValue int + val, err := txn.Get(key) + if err != nil { + if !kv.ErrNotExist.Equal(err) { + return err + } + } else { + oldValue, err = strconv.Atoi(string(val)) + if err != nil { + return err + } + } + + err = txn.Set(key, []byte(strconv.Itoa(oldValue+1))) + if err != nil { + return err + } + err = txn.Commit(context.Background()) + return nil +} + +// lookup value for key +func lookup(storage kv.Storage, key []byte) (int, error) { + var value int + txn, err := storage.Begin() + if err != nil { + return value, err + } + defer txn.Rollback() + val, err := txn.Get(key) + if err != nil { + return value, err + } + value, err = strconv.Atoi(string(val)) + if err != nil { + return value, err + } + return value, nil +} + +func main() { + driver := tikv.Driver{} + storage, err := driver.Open("tikv://192.168.199.113:2379") + if err != nil { + panic(err) + } + defer storage.Close() + + key := []byte("Account") + // lookup account + account, err := lookup(storage, key) + if err != nil { + fmt.Printf("failed to lookup key %s: %v\n", key, err) + } else { + fmt.Printf("Account is %d\n", account) + } + + // increase account + err = increase(storage, key) + if err != nil { + panic(err) + } + + // lookup account again + account, err = lookup(storage, key) + if err != nil { + fmt.Printf("failed to lookup key %s: %v\n", key, err) + } else { + fmt.Printf("Account increased to %d\n", account) + } +} +``` + +The result is like: + +``` +INFO[0000] [pd] create pd client with endpoints [192.168.199.113:2379] +INFO[0000] [pd] leader switches to: http://127.0.0.1:2379, previous: +INFO[0000] [pd] init cluster id 6554145799874853483 +INFO[0000] [kv] Rollback txn 400197262324006914 +failed to lookup key Account: [kv:2]Error: key not exist +INFO[0000] [kv] Rollback txn 400197262324006917 +Account increased to 1 + +# run the program again +INFO[0000] [pd] create pd client with endpoints [192.168.199.113:2379] +INFO[0000] [pd] leader switches to: http://127.0.0.1:2379, previous: +INFO[0000] [pd] init cluster id 6554145799874853483 +INFO[0000] [kv] Rollback txn 400198364324954114 +Account is 1 +INFO[0000] [kv] Rollback txn 400198364324954117 +Account increased to 2 +``` \ No newline at end of file From 88582f2f50d6b9da5114b6847cd25c6d25879ba8 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Mon, 21 May 2018 19:09:22 +0800 Subject: [PATCH 02/12] tikv: update code display effect --- tikv/tikv-quick-start-guide.md | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tikv/tikv-quick-start-guide.md b/tikv/tikv-quick-start-guide.md index fade2c5a11e0d..431c66b60ba93 100644 --- a/tikv/tikv-quick-start-guide.md +++ b/tikv/tikv-quick-start-guide.md @@ -44,7 +44,7 @@ To deploy a TiKV cluster on a single machine for test, take the following steps: 1. Download the official binary package. - ``` + ```bash # Download the package. wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 @@ -59,7 +59,7 @@ To deploy a TiKV cluster on a single machine for test, take the following steps: 2. Start PD. - ``` + ```bash ./bin/pd-server --name=pd1 \ --data-dir=pd1 \ --client-urls="http://127.0.0.1:2379" \ @@ -72,7 +72,7 @@ To deploy a TiKV cluster on a single machine for test, take the following steps: To start the 3 TiKV instances, open a new terminal tab or window, come to the `tidb-latest-linux-amd64` directory, and start the instances using the following command: - ``` + ```bash ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ --addr="127.0.0.1:20160" \ --data-dir=tikv1 \ @@ -114,7 +114,7 @@ To deploy a TiKV cluster with multiple nodes for test, take the following steps: 1. To deploy a TiKV cluster with multiple nodes for test, take the following steps: - ``` + ```bash # Download the package. wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 @@ -129,7 +129,7 @@ To deploy a TiKV cluster with multiple nodes for test, take the following steps: 2. Start PD on Node1. - ``` + ```bash ./bin/pd-server --name=pd1 \ --data-dir=pd1 \ --client-urls="http://192.168.199.113:2379" \ @@ -142,7 +142,7 @@ To deploy a TiKV cluster with multiple nodes for test, take the following steps: Node2: - ``` + ```bash ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ --addr="192.168.199.114:20160" \ --data-dir=tikv1 \ @@ -151,7 +151,7 @@ To deploy a TiKV cluster with multiple nodes for test, take the following steps: Node3: - ``` + ```bash ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ --addr="192.168.199.115:20160" \ --data-dir=tikv2 \ @@ -160,7 +160,7 @@ To deploy a TiKV cluster with multiple nodes for test, take the following steps: Node4: - ``` + ```bash ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ --addr="192.168.199.116:20160" \ --data-dir=tikv3 \ @@ -199,14 +199,14 @@ To use the Raw Key-Value API in applications developed by golang, take the follo 1. Install the necessary packages. - ``` + ```bash go get -v -u github.com/pingcap/tidb/config go get -v -u github.com/pingcap/tidb/store/tikv ``` 2. Import the dependency packages. - ``` + ```bash import ( "fmt" "github.com/pingcap/tidb/config" @@ -216,7 +216,7 @@ To use the Raw Key-Value API in applications developed by golang, take the follo 3. Create a Raw Key-Value client. - ``` + ```bash cli, err := tikv.NewRawKVClient([]string{"192.168.199.113:2379"}, config.Security{}) ``` @@ -227,7 +227,7 @@ To use the Raw Key-Value API in applications developed by golang, take the follo 4. Call the Raw Key-Value client methods to access the data on TiKV. The Raw Key-Value API contains the following methods, and you can also find them at [GoDoc](https://godoc.org/github.com/pingcap/tidb/store/tikv#RawKVClient). - ``` + ```bash type RawKVClient struct func (c *RawKVClient) Close() error func (c *RawKVClient) ClusterID() uint64 @@ -239,7 +239,7 @@ To use the Raw Key-Value API in applications developed by golang, take the follo #### Usage example of the Raw Key-Value API -``` +```bash package main import ( @@ -293,7 +293,7 @@ func main() { The result is like: -``` +```bash INFO[0000] [pd] create pd client with endpoints [192.168.199.113:2379] INFO[0000] [pd] leader switches to: http://127.0.0.1:2379, previous: INFO[0000] [pd] init cluster id 6554145799874853483 @@ -326,14 +326,14 @@ To use the Transactional Key-Value API in applications developed by golang, take 1. Install the necessary packages. - ``` + ```bash go get -v -u github.com/pingcap/tidb/kv go get -v -u github.com/pingcap/tidb/store/tikv ``` 2. Import the dependency packages. - ``` + ```bash import ( "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/tikv" @@ -343,7 +343,7 @@ To use the Transactional Key-Value API in applications developed by golang, take 3. Create Storage using a URL scheme. - ``` + ```bash driver := tikv.Driver{} storage, err := driver.Open("tikv://192.168.199.113:2379") ``` @@ -354,7 +354,7 @@ To use the Transactional Key-Value API in applications developed by golang, take Here is an example to increase a key-value by 1: - ``` + ```bash func increase(storage kv.Storage, key []byte) error { txn, err := storage.Begin() if err != nil { @@ -386,7 +386,7 @@ To use the Transactional Key-Value API in applications developed by golang, take 5. Call the Transactional Key-Value API's methods to access the data on TiKV. The Transactional Key-Value API contains the following methods: - ``` + ```bash Begin() -> Txn Txn.Get(key []byte) -> (value []byte) Txn.Set(key []byte, value []byte) @@ -397,7 +397,7 @@ To use the Transactional Key-Value API in applications developed by golang, take #### Usage example of the Transactional Key-Value API -``` +```bash package main import ( @@ -492,7 +492,7 @@ func main() { The result is like: -``` +```bash INFO[0000] [pd] create pd client with endpoints [192.168.199.113:2379] INFO[0000] [pd] leader switches to: http://127.0.0.1:2379, previous: INFO[0000] [pd] init cluster id 6554145799874853483 From 057f6a8ca6cee88d3bf550b5f80214bf00813e03 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Tue, 22 May 2018 11:10:25 +0800 Subject: [PATCH 03/12] tikv: update the ParseInt code --- tikv/tikv-quick-start-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tikv/tikv-quick-start-guide.md b/tikv/tikv-quick-start-guide.md index 431c66b60ba93..f74d43b356449 100644 --- a/tikv/tikv-quick-start-guide.md +++ b/tikv/tikv-quick-start-guide.md @@ -368,7 +368,7 @@ To use the Transactional Key-Value API in applications developed by golang, take return err } } else { - oldValue, err = strconv.ParseInt(string(val), 10, 32) + oldValue, err = strconv.Atoi(string(val)) if err != nil { return err } @@ -509,4 +509,4 @@ INFO[0000] [kv] Rollback txn 400198364324954114 Account is 1 INFO[0000] [kv] Rollback txn 400198364324954117 Account increased to 2 -``` \ No newline at end of file +``` From e514dec00ef386f4bc0a2812707285b603c775b8 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Wed, 23 May 2018 16:11:12 +0800 Subject: [PATCH 04/12] tikv: fix a step typo --- tikv/tikv-quick-start-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tikv/tikv-quick-start-guide.md b/tikv/tikv-quick-start-guide.md index f74d43b356449..55708fd50f373 100644 --- a/tikv/tikv-quick-start-guide.md +++ b/tikv/tikv-quick-start-guide.md @@ -112,7 +112,7 @@ Assume that you have four nodes, you can deploy 1 PD instance and 3 TiKV instanc To deploy a TiKV cluster with multiple nodes for test, take the following steps: -1. To deploy a TiKV cluster with multiple nodes for test, take the following steps: +1. Download the official binary package on each node. ```bash # Download the package. From d28838501ab62f255459bf8a8d49ac7af3644e37 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Mon, 28 May 2018 16:45:49 +0800 Subject: [PATCH 05/12] tikv: update wording --- tikv/tikv-quick-start-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tikv/tikv-quick-start-guide.md b/tikv/tikv-quick-start-guide.md index 55708fd50f373..99d1e578a15e9 100644 --- a/tikv/tikv-quick-start-guide.md +++ b/tikv/tikv-quick-start-guide.md @@ -177,7 +177,7 @@ The result displays the store count and detailed information regarding each stor ## Try TiKV using the Raw Key-Value API and Transactional Key-Value API -This section introduces two types of APIs and guides you through how to use the two APIs in TiKV using two examples. The usage examples are based on the [deployment of TiKV on multiple nodes](#deploy-the-tikv-cluster-on-multiple-nodes-for-test) in the above section. You can also quickly try the two APIs on a single machine. +This section introduces two types of APIs and guides you through how to use the two APIs in TiKV using two examples. The usage examples are based on the [deployment of TiKV on multiple nodes](#deploy-the-tikv-cluster-on-multiple-nodes-for-test) in the above section. You can also quickly try the two types of APIs on a single machine. ### Two types of APIs From 32d3fd888d50ecabd87562490d5b3a4a45fd2976 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Mon, 28 May 2018 20:13:31 +0800 Subject: [PATCH 06/12] tikv, readme: reorganize TiKV documents --- README.md | 8 +- .../go-client-api.md} | 204 +----------------- tikv/get-started/install-tikv-using-binary.md | 146 +++++++++++++ tikv/get-started/tikv-overview.md | 59 +++++ 4 files changed, 222 insertions(+), 195 deletions(-) rename tikv/{tikv-quick-start-guide.md => get-started/go-client-api.md} (51%) create mode 100644 tikv/get-started/install-tikv-using-binary.md create mode 100644 tikv/get-started/tikv-overview.md diff --git a/README.md b/README.md index 6537b05ad91c9..e35391acda281 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,13 @@ - [TiKV Control](tools/tikv-control.md) - [TiDB Controller](tools/tidb-controller.md) + TiKV - - [TiKV Quick Start Guide](tikv/tikv-quick-start-guide.md) + + Get Started + - [Overview](tikv/get-started/tikv-overview.md) + + Install TiKV + - [Prerequisites](op-guide/recommendation.md) + - [Install TiKV Using Binary Files](tikv/get-started/install-tikv-using-binary.md) + + Client Drivers + - [Go](tikv/get-started/go-client-api.md) + TiSpark - [Quick Start Guide](tispark/tispark-quick-start-guide.md) - [User Guide](tispark/tispark-user-guide.md) diff --git a/tikv/tikv-quick-start-guide.md b/tikv/get-started/go-client-api.md similarity index 51% rename from tikv/tikv-quick-start-guide.md rename to tikv/get-started/go-client-api.md index 99d1e578a15e9..242d839217649 100644 --- a/tikv/tikv-quick-start-guide.md +++ b/tikv/get-started/go-client-api.md @@ -1,199 +1,15 @@ --- -title: TiKV Quick Start Guide -category: quick start +title: Try Two Types of APIs +category: user guide --- -# TiKV Quick Start Guide +# Try Two Types of APIs -TiKV (The pronunciation is: /'taɪkeɪvi:/ tai-K-V, etymology: titanium) is a distributed Key-Value database which is based on the design of Google Spanner and HBase, but it is much simpler without dependency on any distributed file system. +To apply to different scenarios, TiKV provides [two types of APIs](tikv-overview.md#two-types-of-apis) for developers: the Raw Key-Value API and the Transactional Key-Value API. This document guides you through how to use the two APIs in TiKV using two examples. -As the storage layer of TiDB, TiKV can work separately and does not depend on the SQL layer of TiDB. TiKV provides two APIs for developers: the Raw Key-Value API and the Transactional Key-Value API. +The usage examples are based on the [deployment of TiKV on multiple nodes for test](install-tikv.md#deploy-the-tikv-cluster-on-multiple-nodes-for-test). You can also quickly try the two types of APIs on a single machine. -This guide describes how to quickly deploy a TiKV cluster on a single machine and how to use the TiKV cluster through APIs written in Go. - -The TiKV server software stack is as follows: - -![The TiKV software stack](../media/tikv_stack.png) - -## Prepare - -TiKV can be deployed in the Intel architecture server and major virtualization environments, and it supports most of the major hardware networks and Linux operating systems. - -Currently, TiKV provides two APIs: the Raw Key-Value API and the Transactional Key-Value API. This guide uses the APIs written in Go. To write the API, you need to install Go: - -- Make sure ​Go​ (version 1.8+) is installed. -- Ensure your `$GOPATH` is set. (For example, `export GOPATH=$HOME/go`) - -## Deploy the TiKV cluster - -TiKV provides the official binary installation package that supports Linux. - -- To quickly understand and try TiKV, see [Deploy the TiKV cluster on a single machine](#deploy-the-tikv-cluster-on-a-single-machine). -- To try TiKV out and explore the features, see [Deploy the TiKV cluster on multiple nodes for test](#deploy-the-tikv-cluster-on-multiple-nodes-for-test). - -### Deploy the TiKV cluster on a single machine - -This section describes how to deploy 1 PD instance and 3 TiKV instances on a single machine installed with the Linux system. - -> **Note:** -> -> - For the production environment, it is recommended to use multiple nodes cluster deployment. Before you begin, see [Software and Hardware Requirements](op-guide/recommendation.md). -> - Before starting the process, make sure the result of `ulimit -n` is large enough. It is recommended to set the value to `unlimited` or larger than 1000000. - -To deploy a TiKV cluster on a single machine for test, take the following steps: - -1. Download the official binary package. - - ```bash - # Download the package. - wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz - wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 - - # Check the file integrity. If the result is OK, the file is correct. - sha256sum -c tidb-latest-linux-amd64.sha256 - - # Extract the package. - tar -xzf tidb-latest-linux-amd64.tar.gz - cd tidb-latest-linux-amd64 - ``` - -2. Start PD. - - ```bash - ./bin/pd-server --name=pd1 \ - --data-dir=pd1 \ - --client-urls="http://127.0.0.1:2379" \ - --peer-urls="http://127.0.0.1:2380" \ - --initial-cluster="pd1=http://127.0.0.1:2380" \ - --log-file=pd1.log - ``` - -3. Start TiKV. - - To start the 3 TiKV instances, open a new terminal tab or window, come to the `tidb-latest-linux-amd64` directory, and start the instances using the following command: - - ```bash - ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ - --addr="127.0.0.1:20160" \ - --data-dir=tikv1 \ - --log-file=tikv1.log - - ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ - --addr="127.0.0.1:20161" \ - --data-dir=tikv2 \ - --log-file=tikv2.log - - ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ - --addr="127.0.0.1:20162" \ - --data-dir=tikv3 \ - --log-file=tikv3.log - ``` - -You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: - -``` -./bin/pd-ctl store -d -u http://127.0.0.1:2379 -``` - -To access the data in TiKV, you can [try TiKV using the Raw Key-Value API and Transactional Key-Value API](#try-tikv-using-the-raw-key-value-api-and-transactional-key-value-api). - -### Deploy the TiKV cluster on multiple nodes for test - -This section describes how to deploy TiKV on multiple nodes. If you want to test TiKV with a limited number of nodes, you can use one PD instance to test the entire cluster. - -Assume that you have four nodes, you can deploy 1 PD instance and 3 TiKV instances. For details, see the following table: - -| Name | Host IP | Services | -| :-- | :-- | :------------------- | -| Node1 | 192.168.199.113 | PD1 | -| Node2 | 192.168.199.114 | TiKV1 | -| Node3 | 192.168.199.115 | TiKV2 | -| Node4 | 192.168.199.116 | TiKV3 | - -To deploy a TiKV cluster with multiple nodes for test, take the following steps: - -1. Download the official binary package on each node. - - ```bash - # Download the package. - wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz - wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 - - # Check the file integrity. If the result is OK, the file is correct. - sha256sum -c tidb-latest-linux-amd64.sha256 - - # Extract the package. - tar -xzf tidb-latest-linux-amd64.tar.gz - cd tidb-latest-linux-amd64 - ``` - -2. Start PD on Node1. - - ```bash - ./bin/pd-server --name=pd1 \ - --data-dir=pd1 \ - --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" \ - --log-file=pd1.log - ``` - -3. Log in and start TiKV on other nodes: Node2, Node3 and Node4. - - Node2: - - ```bash - ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ - --addr="192.168.199.114:20160" \ - --data-dir=tikv1 \ - --log-file=tikv1.log - ``` - - Node3: - - ```bash - ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ - --addr="192.168.199.115:20160" \ - --data-dir=tikv2 \ - --log-file=tikv2.log - ``` - - Node4: - - ```bash - ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ - --addr="192.168.199.116:20160" \ - --data-dir=tikv3 \ - --log-file=tikv3.log - ``` - -You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: - -``` -./pd-ctl store -d -u http://192.168.199.113:2379 -``` - -The result displays the store count and detailed information regarding each store. - -## Try TiKV using the Raw Key-Value API and Transactional Key-Value API - -This section introduces two types of APIs and guides you through how to use the two APIs in TiKV using two examples. The usage examples are based on the [deployment of TiKV on multiple nodes](#deploy-the-tikv-cluster-on-multiple-nodes-for-test) in the above section. You can also quickly try the two types of APIs on a single machine. - -### Two types of APIs - -To apply to different scenarios, TiKV provides two types of APIs for developers: - -- The Raw Key-Value API - - If your application scenario does not need distributed transactions or MVCC (Multi-Version Concurrency Control) and only need to guarantee the atomicity towards one key, you can use the Raw Key-Value API. - -- The Transactional Key-Value API - - If your application scenario requires distributed ACID transactions and the atomicity of multiple keys within a transaction, you can use the Transactional Key-Value API. - -Compared to the Transactional Key-Value API, the Raw Key-Value API is more performant with lower latency and easier to use. - -### Use the Raw Key-Value API +## Try the Raw Key-Value API To use the Raw Key-Value API in applications developed by golang, take the following steps: @@ -237,7 +53,7 @@ To use the Raw Key-Value API in applications developed by golang, take the follo func (c *RawKVClient) Scan(startKey []byte, limit int) (keys [][]byte, values [][]byte, err error) ``` -#### Usage example of the Raw Key-Value API +### Usage example of the Raw Key-Value API ```bash package main @@ -306,7 +122,7 @@ found val: for key: Company RawKVClient is a client of the TiKV server and only supports the GET/PUT/DELETE/SCAN commands. The RawKVClient can be safely and concurrently accessed by multiple goroutines, as long as it is not closed. Therefore, for one process, one client is enough generally. -### Use the Transactional Key-Value API +## Try the Transactional Key-Value API The Transactional Key-Value API is complicated than the Raw Key-Value API. Some transaction related concepts are listed as follows. For more details, see the [KV package](https://github.com/pingcap/tidb/tree/master/kv). @@ -395,7 +211,7 @@ To use the Transactional Key-Value API in applications developed by golang, take Txn.Commit() ``` -#### Usage example of the Transactional Key-Value API +### Usage example of the Transactional Key-Value API ```bash package main @@ -509,4 +325,4 @@ INFO[0000] [kv] Rollback txn 400198364324954114 Account is 1 INFO[0000] [kv] Rollback txn 400198364324954117 Account increased to 2 -``` +``` \ No newline at end of file diff --git a/tikv/get-started/install-tikv-using-binary.md b/tikv/get-started/install-tikv-using-binary.md new file mode 100644 index 0000000000000..ad6f1ec57e78c --- /dev/null +++ b/tikv/get-started/install-tikv-using-binary.md @@ -0,0 +1,146 @@ +--- +title: Install TiKV Using Binary Files +category: overview +--- + +# Install TiKV Using Binary Files + +This guide describes how to deploy a TiKV cluster using binary files. + +- To quickly understand and try TiKV, see [Deploy the TiKV cluster on a single machine](#deploy-the-tikv-cluster-on-a-single-machine). +- To try TiKV out and explore the features, see [Deploy the TiKV cluster on multiple nodes for test](#deploy-the-tikv-cluster-on-multiple-nodes-for-test). + +## Deploy the TiKV cluster on a single machine + +This section describes how to deploy TiKV on a single machine installed with the Linux system. Take the following steps: + +1. Download the official binary package. + + ```bash + # Download the package. + wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz + wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 + + # Check the file integrity. If the result is OK, the file is correct. + sha256sum -c tidb-latest-linux-amd64.sha256 + + # Extract the package. + tar -xzf tidb-latest-linux-amd64.tar.gz + cd tidb-latest-linux-amd64 + ``` + +2. Start PD. + + ```bash + ./bin/pd-server --name=pd1 \ + --data-dir=pd1 \ + --client-urls="http://127.0.0.1:2379" \ + --peer-urls="http://127.0.0.1:2380" \ + --initial-cluster="pd1=http://127.0.0.1:2380" \ + --log-file=pd1.log + ``` + +3. Start TiKV. + + To start the 3 TiKV instances, open a new terminal tab or window, come to the `tidb-latest-linux-amd64` directory, and start the instances using the following command: + + ```bash + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20160" \ + --data-dir=tikv1 \ + --log-file=tikv1.log + + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20161" \ + --data-dir=tikv2 \ + --log-file=tikv2.log + + ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \ + --addr="127.0.0.1:20162" \ + --data-dir=tikv3 \ + --log-file=tikv3.log + ``` + +You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: + +``` +./bin/pd-ctl store -d -u http://127.0.0.1:2379 +``` + +## Deploy the TiKV cluster on multiple nodes for test + +This section describes how to deploy TiKV on multiple nodes. If you want to test TiKV with a limited number of nodes, you can use one PD instance to test the entire cluster. + +Assume that you have four nodes, you can deploy 1 PD instance and 3 TiKV instances. For details, see the following table: + +| Name | Host IP | Services | +| :-- | :-- | :------------------- | +| Node1 | 192.168.199.113 | PD1 | +| Node2 | 192.168.199.114 | TiKV1 | +| Node3 | 192.168.199.115 | TiKV2 | +| Node4 | 192.168.199.116 | TiKV3 | + +To deploy a TiKV cluster with multiple nodes for test, take the following steps: + +1. Download the official binary package on each node. + + ```bash + # Download the package. + wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz + wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 + + # Check the file integrity. If the result is OK, the file is correct. + sha256sum -c tidb-latest-linux-amd64.sha256 + + # Extract the package. + tar -xzf tidb-latest-linux-amd64.tar.gz + cd tidb-latest-linux-amd64 + ``` + +2. Start PD on Node1. + + ```bash + ./bin/pd-server --name=pd1 \ + --data-dir=pd1 \ + --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" \ + --log-file=pd1.log + ``` + +3. Log in and start TiKV on other nodes: Node2, Node3 and Node4. + + Node2: + + ```bash + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.114:20160" \ + --data-dir=tikv1 \ + --log-file=tikv1.log + ``` + + Node3: + + ```bash + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.115:20160" \ + --data-dir=tikv2 \ + --log-file=tikv2.log + ``` + + Node4: + + ```bash + ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \ + --addr="192.168.199.116:20160" \ + --data-dir=tikv3 \ + --log-file=tikv3.log + ``` + +You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool to verify whether PD and TiKV are successfully deployed: + +``` +./pd-ctl store -d -u http://192.168.199.113:2379 +``` + +The result displays the store count and detailed information regarding each store. \ No newline at end of file diff --git a/tikv/get-started/tikv-overview.md b/tikv/get-started/tikv-overview.md new file mode 100644 index 0000000000000..a50fd0162643d --- /dev/null +++ b/tikv/get-started/tikv-overview.md @@ -0,0 +1,59 @@ +--- +title: Overview of TiKV +category: overview +--- + +# Overview of TiKV + +TiKV (The pronunciation is: /'taɪkeɪvi:/ tai-K-V, etymology: titanium) is a distributed Key-Value database which is based on the design of Google Spanner and HBase, but it is much simpler without dependency on any distributed file system. + +As the storage layer of TiDB, TiKV can work separately and does not depend on the SQL layer of TiDB. To apply to different scenarios, TiKV provides [two types of APIs](#two-types-of-apis) for developers: the Raw Key-Value API and the Transactional Key-Value API. + +The key features of TiKV are as follows: + +- **Geo-Replication** + + TiKV uses [Raft](http://raft.github.io/) and the [Placement Driver](https://github.com/pingcap/pd/) to support Geo-Replication. + +- **Horizontal scalability** + + With Placement Driver and carefully designed Raft groups, TiKV excels in horizontal scalability and can easily scale to 100+ TBs of data. + +- **Consistent distributed transactions** + + Similar to Google's Spanner, TiKV supports externally-consistent distributed transactions. + +- **Coprocessor support** + + Similar to HBase, TiKV implements a Coprocessor framework to support distributed computing. + +- **Cooperates with [TiDB](https://github.com/pingcap/tidb)** + + Thanks to the internal optimization, TiKV and TiDB can work together to be a compelling database solution with high horizontal scalability, externally-consistent transactions, and support for RDMBS and NoSQL design patterns. + +## Architecture + +The TiKV server software stack is as follows: + +![The TiKV software stack](../../media/tikv_stack.png) + +- **Placement Driver:** Placement Driver (PD) is the cluster manager of TiKV. PD periodically checks replication constraints to balance load and data automatically. +- **Store:** There is a RocksDB within each Store and it stores data into local disk. +- **Region:** Region is the basic unit of Key-Value data movement. Each Region is replicated to multiple Nodes. These multiple replicas form a Raft group. +- **Node:** A physical node in the cluster. Within each node, there are one or more Stores. Within each Store, there are many Regions. + +When a node starts, the metadata of the Node, Store and Region are recorded into PD. The status of each Region and Store is reported to PD regularly. + +## Two types of APIs + +TiKV provides two types of APIs for developers: + +- The Raw Key-Value API + + If your application scenario does not need distributed transactions or MVCC (Multi-Version Concurrency Control) and only need to guarantee the atomicity towards one key, you can use the Raw Key-Value API. + +- The Transactional Key-Value API + + If your application scenario requires distributed ACID transactions and the atomicity of multiple keys within a transaction, you can use the Transactional Key-Value API. + +Compared to the Transactional Key-Value API, the Raw Key-Value API is more performant with lower latency and easier to use. \ No newline at end of file From 41125a817e9ac722ce61eedee1c3fc08af4c9753 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Tue, 29 May 2018 11:13:08 +0800 Subject: [PATCH 07/12] tikv, readme: reorganize the structure and update content based on comments --- README.md | 17 +++++----- tikv/{get-started => }/go-client-api.md | 33 ------------------- .../install-tikv-using-binary.md | 0 tikv/{get-started => }/tikv-overview.md | 0 4 files changed, 8 insertions(+), 42 deletions(-) rename tikv/{get-started => }/go-client-api.md (90%) rename tikv/{get-started => }/install-tikv-using-binary.md (100%) rename tikv/{get-started => }/tikv-overview.md (100%) diff --git a/README.md b/README.md index e35391acda281..a5270781dc471 100644 --- a/README.md +++ b/README.md @@ -111,15 +111,14 @@ - [PD Control](tools/pd-control.md) - [TiKV Control](tools/tikv-control.md) - [TiDB Controller](tools/tidb-controller.md) -+ TiKV - + Get Started - - [Overview](tikv/get-started/tikv-overview.md) - + Install TiKV - - [Prerequisites](op-guide/recommendation.md) - - [Install TiKV Using Binary Files](tikv/get-started/install-tikv-using-binary.md) - + Client Drivers - - [Go](tikv/get-started/go-client-api.md) -+ TiSpark ++ TiKV Documentation + - [Overview](tikv/tikv-overview.md) + + Install TiKV + - [Prerequisites](op-guide/recommendation.md) + - [Install TiKV Using Binary Files](tikv/install-tikv-using-binary.md) + + Client Drivers + - [Go](tikv/go-client-api.md) ++ TiSpark Documentation - [Quick Start Guide](tispark/tispark-quick-start-guide.md) - [User Guide](tispark/tispark-user-guide.md) - [Frequently Asked Questions (FAQ)](FAQ.md) diff --git a/tikv/get-started/go-client-api.md b/tikv/go-client-api.md similarity index 90% rename from tikv/get-started/go-client-api.md rename to tikv/go-client-api.md index 242d839217649..431801e6f51d0 100644 --- a/tikv/get-started/go-client-api.md +++ b/tikv/go-client-api.md @@ -16,7 +16,6 @@ To use the Raw Key-Value API in applications developed by golang, take the follo 1. Install the necessary packages. ```bash - go get -v -u github.com/pingcap/tidb/config go get -v -u github.com/pingcap/tidb/store/tikv ``` @@ -168,38 +167,6 @@ To use the Transactional Key-Value API in applications developed by golang, take The lifecycle of a Transaction is: _begin → {get, set, delete, scan} → {commit, rollback}_. - Here is an example to increase a key-value by 1: - - ```bash - func increase(storage kv.Storage, key []byte) error { - txn, err := storage.Begin() - if err != nil { - return err - } - defer txn.Rollback() - var oldValue int - val, err := txn.Get(key) - if err != nil { - if !kv.ErrNotExist.Equal(err) { - return err - } - } else { - oldValue, err = strconv.Atoi(string(val)) - if err != nil { - return err - } - } - err = txn.Set(key, []byte(strconv.Itoa(oldValue+1))) - if err != nil { - return err - } - err = txn.Commit(context.Background()) - return err - } - ``` - - > **Note:** If a key does not exist, `Get` returns a `kv.ErrNotExist` error. - 5. Call the Transactional Key-Value API's methods to access the data on TiKV. The Transactional Key-Value API contains the following methods: ```bash diff --git a/tikv/get-started/install-tikv-using-binary.md b/tikv/install-tikv-using-binary.md similarity index 100% rename from tikv/get-started/install-tikv-using-binary.md rename to tikv/install-tikv-using-binary.md diff --git a/tikv/get-started/tikv-overview.md b/tikv/tikv-overview.md similarity index 100% rename from tikv/get-started/tikv-overview.md rename to tikv/tikv-overview.md From cd06eff043825280cd880484ac6a6c5625d55da6 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Tue, 29 May 2018 15:33:19 +0800 Subject: [PATCH 08/12] tikv, readme: add Install TiKV Using Docker Compose --- README.md | 1 + tikv/install-tikv-docker-compose.md | 57 +++++++++++++++++++++++++++++ tikv/install-tikv-using-binary.md | 6 ++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tikv/install-tikv-docker-compose.md diff --git a/README.md b/README.md index a5270781dc471..f4807efc5cbd6 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ - [Overview](tikv/tikv-overview.md) + Install TiKV - [Prerequisites](op-guide/recommendation.md) + - [Install TiKV Using Docker Compose](tikv/install-tikv-docker-compose.md) - [Install TiKV Using Binary Files](tikv/install-tikv-using-binary.md) + Client Drivers - [Go](tikv/go-client-api.md) diff --git a/tikv/install-tikv-docker-compose.md b/tikv/install-tikv-docker-compose.md new file mode 100644 index 0000000000000..b567d350809cf --- /dev/null +++ b/tikv/install-tikv-docker-compose.md @@ -0,0 +1,57 @@ +--- +title: Install TiKV Using Docker Compose +category: user guide +--- + +# Install TiKV Using Docker Compose + +This guide describes how to quickly deploy a TiKV cluster using [Docker Compose](https://github.com/pingcap/tidb-docker-compose/). Currently, this installation method only supports the Linux system. + +## Prerequisites + +- Install Docker and Docker Compose. + + ``` + sudo yum install docker docker-compose + ``` + +- Install Helm. + + ``` + curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash + ``` + +## Install + +1. Download `tidb-docker-compose`. + + ``` + git clone https://github.com/pingcap/tidb-docker-compose.git + ``` + +2. Edit the `compose/values.yaml` file to configure `networkMode` to `host` and comment the TiDB section out. + + ``` + cd tidb-docker-compose/compose + networkMode: host + ``` + +3. Generate the `generated-docker-compose.yml` file. + + ``` + helm template compose > generated-docker-compose.yml + ``` + +4. Create and start the cluster using the `generated-docker-compose.yml` file. + + ``` + docker-compose -f generated-docker-compose.yml up -d + ``` + +You can check whether the TiKV cluster has been successfully deployed using the following command: + +``` +curl localhost:2379/pd/api/v1/stores +``` + +If the state of all the TiKV instances is "Up", you have successfully deployed a TiKV cluster. \ No newline at end of file diff --git a/tikv/install-tikv-using-binary.md b/tikv/install-tikv-using-binary.md index ad6f1ec57e78c..44fae49401c23 100644 --- a/tikv/install-tikv-using-binary.md +++ b/tikv/install-tikv-using-binary.md @@ -1,6 +1,6 @@ --- title: Install TiKV Using Binary Files -category: overview +category: user guide --- # Install TiKV Using Binary Files @@ -67,6 +67,8 @@ You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool t ./bin/pd-ctl store -d -u http://127.0.0.1:2379 ``` +If the state of all the TiKV instances is "Up", you have successfully deployed a TiKV cluster. + ## Deploy the TiKV cluster on multiple nodes for test This section describes how to deploy TiKV on multiple nodes. If you want to test TiKV with a limited number of nodes, you can use one PD instance to test the entire cluster. @@ -143,4 +145,4 @@ You can use the [pd-ctl](https://github.com/pingcap/pd/tree/master/pdctl) tool t ./pd-ctl store -d -u http://192.168.199.113:2379 ``` -The result displays the store count and detailed information regarding each store. \ No newline at end of file +The result displays the store count and detailed information regarding each store. If the state of all the TiKV instances is "Up", you have successfully deployed a TiKV cluster. \ No newline at end of file From f09c7fc07f4a297a336fc3374e9e0bd60ebc200f Mon Sep 17 00:00:00 2001 From: lilin90 Date: Tue, 29 May 2018 15:57:05 +0800 Subject: [PATCH 09/12] tikv: add two links to API usage --- tikv/tikv-overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tikv/tikv-overview.md b/tikv/tikv-overview.md index a50fd0162643d..550b618958538 100644 --- a/tikv/tikv-overview.md +++ b/tikv/tikv-overview.md @@ -48,11 +48,11 @@ When a node starts, the metadata of the Node, Store and Region are recorded into TiKV provides two types of APIs for developers: -- The Raw Key-Value API +- [The Raw Key-Value API](go-client-api.md#try-the-raw-key-value-api) If your application scenario does not need distributed transactions or MVCC (Multi-Version Concurrency Control) and only need to guarantee the atomicity towards one key, you can use the Raw Key-Value API. -- The Transactional Key-Value API +- [The Transactional Key-Value API](go-client-api.md#try-the-transactional-key-value-api) If your application scenario requires distributed ACID transactions and the atomicity of multiple keys within a transaction, you can use the Transactional Key-Value API. From b11fe3a2748e8e273f9db41d76c60f0d59195449 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Thu, 31 May 2018 10:29:26 +0800 Subject: [PATCH 10/12] tikv, readme: update file name and readme --- README.md | 6 +++--- ...tikv-docker-compose.md => deploy-tikv-docker-compose.md} | 0 ...all-tikv-using-binary.md => deploy-tikv-using-binary.md} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename tikv/{install-tikv-docker-compose.md => deploy-tikv-docker-compose.md} (100%) rename tikv/{install-tikv-using-binary.md => deploy-tikv-using-binary.md} (100%) diff --git a/README.md b/README.md index f4807efc5cbd6..306481c3506ca 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,10 @@ - [TiDB Controller](tools/tidb-controller.md) + TiKV Documentation - [Overview](tikv/tikv-overview.md) - + Install TiKV + + Install and Deploy TiKV - [Prerequisites](op-guide/recommendation.md) - - [Install TiKV Using Docker Compose](tikv/install-tikv-docker-compose.md) - - [Install TiKV Using Binary Files](tikv/install-tikv-using-binary.md) + - [Install and Deploy TiKV Using Docker Compose](tikv/deploy-tikv-docker-compose.md) + - [Install and Deploy TiKV Using Binary Files](tikv/deploy-tikv-using-binary.md) + Client Drivers - [Go](tikv/go-client-api.md) + TiSpark Documentation diff --git a/tikv/install-tikv-docker-compose.md b/tikv/deploy-tikv-docker-compose.md similarity index 100% rename from tikv/install-tikv-docker-compose.md rename to tikv/deploy-tikv-docker-compose.md diff --git a/tikv/install-tikv-using-binary.md b/tikv/deploy-tikv-using-binary.md similarity index 100% rename from tikv/install-tikv-using-binary.md rename to tikv/deploy-tikv-using-binary.md From e1b58632104b1b99663600a3b2558c91355f55de Mon Sep 17 00:00:00 2001 From: lilin90 Date: Thu, 31 May 2018 10:34:36 +0800 Subject: [PATCH 11/12] tikv: update wording --- tikv/deploy-tikv-docker-compose.md | 6 +++--- tikv/deploy-tikv-using-binary.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tikv/deploy-tikv-docker-compose.md b/tikv/deploy-tikv-docker-compose.md index b567d350809cf..6f5ab9d3e58e6 100644 --- a/tikv/deploy-tikv-docker-compose.md +++ b/tikv/deploy-tikv-docker-compose.md @@ -1,9 +1,9 @@ --- -title: Install TiKV Using Docker Compose +title: Install and Deploy TiKV Using Docker Compose category: user guide --- -# Install TiKV Using Docker Compose +# Install and Deploy TiKV Using Docker Compose This guide describes how to quickly deploy a TiKV cluster using [Docker Compose](https://github.com/pingcap/tidb-docker-compose/). Currently, this installation method only supports the Linux system. @@ -21,7 +21,7 @@ This guide describes how to quickly deploy a TiKV cluster using [Docker Compose] curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash ``` -## Install +## Install and deploy 1. Download `tidb-docker-compose`. diff --git a/tikv/deploy-tikv-using-binary.md b/tikv/deploy-tikv-using-binary.md index 44fae49401c23..eb73053b895a2 100644 --- a/tikv/deploy-tikv-using-binary.md +++ b/tikv/deploy-tikv-using-binary.md @@ -1,9 +1,9 @@ --- -title: Install TiKV Using Binary Files +title: Install and Deploy TiKV Using Binary Files category: user guide --- -# Install TiKV Using Binary Files +# Install and Deploy TiKV Using Binary Files This guide describes how to deploy a TiKV cluster using binary files. From 97162dbf3cc619c13e00522fa3e5ca4ff4a52867 Mon Sep 17 00:00:00 2001 From: lilin90 Date: Thu, 31 May 2018 11:38:53 +0800 Subject: [PATCH 12/12] tikv: update two links --- tikv/go-client-api.md | 2 +- tikv/tikv-overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tikv/go-client-api.md b/tikv/go-client-api.md index 431801e6f51d0..5f1c7078d13aa 100644 --- a/tikv/go-client-api.md +++ b/tikv/go-client-api.md @@ -7,7 +7,7 @@ category: user guide To apply to different scenarios, TiKV provides [two types of APIs](tikv-overview.md#two-types-of-apis) for developers: the Raw Key-Value API and the Transactional Key-Value API. This document guides you through how to use the two APIs in TiKV using two examples. -The usage examples are based on the [deployment of TiKV on multiple nodes for test](install-tikv.md#deploy-the-tikv-cluster-on-multiple-nodes-for-test). You can also quickly try the two types of APIs on a single machine. +The usage examples are based on the [deployment of TiKV using binary files on multiple nodes for test](deploy-tikv-using-binary.md#deploy-the-tikv-cluster-on-multiple-nodes-for-test). You can also quickly try the two types of APIs on a single machine. ## Try the Raw Key-Value API diff --git a/tikv/tikv-overview.md b/tikv/tikv-overview.md index 550b618958538..726e6c2445828 100644 --- a/tikv/tikv-overview.md +++ b/tikv/tikv-overview.md @@ -35,7 +35,7 @@ The key features of TiKV are as follows: The TiKV server software stack is as follows: -![The TiKV software stack](../../media/tikv_stack.png) +![The TiKV software stack](../media/tikv_stack.png) - **Placement Driver:** Placement Driver (PD) is the cluster manager of TiKV. PD periodically checks replication constraints to balance load and data automatically. - **Store:** There is a RocksDB within each Store and it stores data into local disk.