- Write some data via go-ycsb, and then verify whether the data is replicated in triplicate by default.
- Add two more nodes and see how TiKV automatically rebalances replicas to efficiently use all available capacity.
Do not apply this operation in the production environment.
Make sure that you have installed TiUP as described in .
Step 1: Start a 3-node cluster
Check your TiUP version. Execute the following command:
Depending on the TiUP version, execute the command to start a 3-node local cluster.
If TiUP version is v1.5.2 or later, execute the following command:
tiup playground --mode tikv-slim --kv 3
If TiUP version is earlier than v1.5.2, execute the following command:
tiup playground --kv 3
After you execute the command, the output is as follows:
Starting component `playground`: /home/pingcap/.tiup/components/playground/v1.5.0/tiup-playground --mode tikv-slim --kv 3
Using the version v5.0.2 for version constraint "".
If you'd like to use a TiDB version other than v5.0.2, cancel and retry with the following arguments:
Specify version range: tiup playground ^5
The nightly version: tiup playground nightly
Playground Bootstrapping...
Start pd instance
Start tikv instance
Start tikv instance
PD client endpoints: [127.0.0.1:2379]
To view the Prometheus: http://127.0.0.1:33703
To view the Grafana: http://127.0.0.1:3000
On another terminal session, you can use go-ycsb to launch a workload.
Build the application from the source.
make
Load a small workload using
go-ycsb
.# By default, this workload will insert 1000 records into TiKV.
./bin/go-ycsb load tikv -P workloads/workloada -p tikv.pd="127.0.0.1:2379" -p tikv.type="raw"
Step 3: Verify the replication
To understand the replication in TiKV, it is important to review several concepts in the architecture.
Open the Grafana at (printed from the
tiup-playground
command), and then log in to Grafana using usernameadmin
and passwordadmin
.
In this section, you can launch a larger workload, scale the 3-node local cluster to a 5-node cluster, and then check whether the load of the TiKV cluster is rebalanced as expected.
Start a new terminal session and launch a larger workload with
go-ycsb
. For example, on a machine with 16 virtual cores, you can launch a workload by executing the following command:./bin/go-ycsb load tikv -P workloads/workloada -p tikv.pd="127.0.0.1:2379" -p tikv.type="raw" -p tikv.conncount=16 -p threadcount=16 -p recordcount=1000000
Step 5: Add two more nodes
Start another terminal session and use the
tiup playground
command to scale out the cluster.Verify the scale-out cluster by executing the following command:
tiup playground display
The output is as follows:
Pid Role Uptime
--- ---- ------
282731 pd 4h1m23.792495134s
282752 tikv 4h1m23.77761744s
282757 tikv 4h1m23.761628915s
282761 tikv 4h1m23.748199302s
308242 tikv 9m50.551877838s
308243 tikv 9m50.537477856s
Go to the Grafana page as mentioned above. You can find some Regions are split and rebalanced to the two new nodes.
Step 7: Stop and delete the cluster
If you do not need the local TiKV cluster anymore, you can stop and delete it.
To stop the TiKV cluster, get back to the terminal session in which you have started the TiKV cluster. Press Ctrl + C and wait for the cluster to stop.