I would like to ask, I want to debug the TiKV code. When deploying, it usually starts with 3 TiKV nodes. Can I start with only one TiKV? Will there be any impact? I’m a newbie to TiDB, just getting started.
You need to set the replication to 1 to start only one TiKV node. By default, the replication is set to 3, and a single TiKV cannot provide services externally.
How should I set it up? I compiled TiDB, TiKV, and PD myself. Since I mainly want to debug and get familiar with the code, I feel that multiple replicas are not necessary. One TiKV should theoretically be enough.
replication.max-replicas is used to set the number of replicas
There is a setting in the PD configuration. It can be modified online or set in the file using tiup cluster edit-config.
Directly connect to TiDB
View configuration
SHOW config WHERE NAME LIKE ‘replication.max-replicas’
Modify configuration
SET config pd replication.max-replicas=1;
I reinstalled a virtual machine and only managed to compile successfully in a clean environment. I guess the previous environment had too many compilation tasks, which caused some conflicts.
You can connect to TiDB and make online modifications as well.
Or installing a TiUP won’t take more than a few minutes, it’s very quick.
I read the debugging documentation, and it says that to debug TiKV separately, you can use only PD and TiKV. TiDB is not necessary.
Creating tables and inserting data, can TiDB be unnecessary? I see that the documentation shows MySQL connecting to TiDB, right? Installing TiUP, then how to use the self-compiled version to start it?
You can use tikv-client to connect to TiKV without TiDB, treating TiKV as a transactional key-value store.
The latter issue does seem a bit troublesome. It’s better to connect through TiDB. Alternatively, you could modify the PD configuration file.
[root@tidb1 conf]# pwd
/tidb-deploy/pd-2379/conf
[root@tidb1 conf]# cat pd.toml
# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
# You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
# All configuration items you want to change can be added to:
# server_configs:
# pd:
# aa.b1.c3: value
# aa.b2.c4: value
When deploying formally, this configuration file will be generated by tiup, and it is not recommended to modify it. However, if you are compiling and don’t have tiup, it might be faster to directly modify this file and restart PD.
Yes, the settings related to PD in the topo.yaml file will eventually be written into the pd.toml file. Both TiDB and TiKV have corresponding configuration files, and the content is also from the topo.yaml file, which is automatically generated into the configuration files of each component.
It seems that the compiled version doesn’t have these configurations. I found a method to start with an installation package. Let’s start it first and then see how to set it up. Single-node deployment and startup of TiDB - Likecs.com
As long as you can see the following parameter in the compiled pd-server: --config string config file
you should be able to set the pd.toml file using this parameter.
Here is a complete startup parameter process for your reference: