This guide describes how to install and deploy TiKV for test using TiUP playground and binary installation.

TiUP Playground

This chapter describes how to deploy a TiKV cluster using TiUP Playground.

  1. Install TiUP by executing the following command:

    1. curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  2. Set the TiUP environment variables:

    Redeclare the global environment variables:

    1. source .bash_profile

    Confirm whether TiUP is installed:

    1. tiup
  3. If TiUP is already installed, update the TiUP playground component to the latest version:

    1. tiup update --self && tiup update playground
  4. Use TiUP playground to start a local TiKV cluster

    Show TiUP version:

    1. tiup -v

    version >= 1.5.2:

    1. tiup playground --mode tikv-slim

    version < 1.5.2:

    1. tiup playground
  5. Press Ctrl + C to stop the local TiKV cluster

Refer to TiUP playground document to find more TiUP playground commands.

Install binary manually

This chapter describes how to deploy a TiKV cluster using binary files.

The TiKV team strongly recommends you use the TiUP Cluster Deployment method.

Other methods are documented for informational purposes.

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.

    1. # Download the package.
    2. wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
    3. wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256
    4. # Check the file integrity. If the result is OK, the file is correct.
    5. sha256sum -c tidb-latest-linux-amd64.sha256
    6. # Extract the package.
    7. tar -xzf tidb-latest-linux-amd64.tar.gz
    8. cd tidb-latest-linux-amd64
  2. Start PD.

    1. ./bin/pd-server --name=pd1 \
    2. --data-dir=pd1 \
    3. --client-urls="http://127.0.0.1:2379" \
    4. --peer-urls="http://127.0.0.1:2380" \
    5. --initial-cluster="pd1=http://127.0.0.1:2380" \
    6. --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:

    1. ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \
    2. --addr="127.0.0.1:20160" \
    3. --data-dir=tikv1 \
    4. --log-file=tikv1.log
    5. ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \
    6. --addr="127.0.0.1:20161" \
    7. --data-dir=tikv2 \
    8. --log-file=tikv2.log
    9. ./bin/tikv-server --pd-endpoints="127.0.0.1:2379" \
    10. --addr="127.0.0.1:20162" \
    11. --data-dir=tikv3 \
    12. --log-file=tikv3.log

You can use the pd-ctl tool to verify whether PD and TiKV are successfully deployed:

  1. ./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 testing

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:

NameHost IPServices
Node1192.168.199.113PD1
Node2192.168.199.114TiKV1
Node3192.168.199.115TiKV2
Node4192.168.199.116TiKV3

To deploy a TiKV cluster with multiple nodes for test, take the following steps:

  1. Download the official binary package on each node.

    1. # Download the package.
    2. wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
    3. wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256
    4. # Check the file integrity. If the result is OK, the file is correct.
    5. sha256sum -c tidb-latest-linux-amd64.sha256
    6. # Extract the package.
    7. tar -xzf tidb-latest-linux-amd64.tar.gz
    8. cd tidb-latest-linux-amd64
  2. Start PD on Node1.

    1. ./bin/pd-server --name=pd1 \
    2. --data-dir=pd1 \
    3. --client-urls="http://192.168.199.113:2379" \
    4. --peer-urls="http://192.168.199.113:2380" \
    5. --initial-cluster="pd1=http://192.168.199.113:2380" \
    6. --log-file=pd1.log
  3. Log in and start TiKV on other nodes: Node2, Node3 and Node4.

    Node2:

    1. ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \
    2. --addr="192.168.199.114:20160" \
    3. --data-dir=tikv1 \
    4. --log-file=tikv1.log

    Node3:

    1. ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \
    2. --addr="192.168.199.115:20160" \
    3. --data-dir=tikv2 \
    4. --log-file=tikv2.log

    Node4:

    1. ./bin/tikv-server --pd-endpoints="192.168.199.113:2379" \
    2. --addr="192.168.199.116:20160" \
    3. --data-dir=tikv3 \
    4. --log-file=tikv3.log

You can use the pd-ctl tool to verify whether PD and TiKV are successfully deployed:

  1. ./pd-ctl store -d -u http://192.168.199.113:2379

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.