Modifying the tikv.toml configuration to change the default storage path for TiKV data is not effective

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 配置tikv.toml修改tikv数据默认存储路径不生效

| username: TiDBer_S4eEz9Qb

Version: v7.1.0

Reproduction steps:

  1. Copy the tikv/etc/config-template.toml from the official website to the local machine and modify storage.data-dir to “/data/0/tidb/tikv”.
  2. Start using tiup playground --kv.config ./tikv_config.toml.
  3. TiKV data is still stored in $HOME/.tiup/.

However, when checking the tikv.toml under the tikv-0 directory, it is found that storage.data-dir is indeed “/data/0/tidb/tikv”.

Why is this happening? Is it not taking effect? If the configuration method is incorrect, how can I modify the default storage path for TiKV data?

| username: 像风一样的男子 | Original post link

Use this command to modify the cluster configuration file: tiup cluster edit-config xxx, and after making changes, reload it with: tiup cluster reload xxx.

| username: TiDBer_S4eEz9Qb | Original post link

I directly used tiup playground to deploy the local test environment, without using cluster :joy:
When starting tiup cluster, it seems that root user permissions are required, which might not work for me, so I can only use tiup playground.

| username: 像风一样的男子 | Original post link

Root permissions are required during cluster installation, but regular user accounts are used to start the service.

| username: TiDBer_S4eEz9Qb | Original post link

The deployment command on the official website is: tiup cluster deploy tidb-test v7.1.0 ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
If I change --user to a regular user or omit --user, the deployment will fail.

| username: 有猫万事足 | Original post link

That shouldn’t be the case. What error is being reported?

I always use the tidb user for deployment. I’ve never encountered any issues. Add --user tidb -p at the end, without setting up passwordless access, but tidb has the same password. Like this.

| username: buptzhoutian | Original post link

It’s probably due to the limitations of the playground. After you start the playground cluster, you can check the tikv-server process, which is roughly like this:

$TIUP_HOME/components/tikv/v7.1.0/tikv-server \
  --addr=127.0.0.1:20160 \
  --advertise-addr=127.0.0.1:20160 \
  --status-addr=127.0.0.1:20180 \
  --pd-endpoints=http://127.0.0.1:2379 \
  --config=$TIUP_HOME/data/ThnhZLC/tikv-0/tikv.toml \
  --data-dir=$TIUP_HOME/data/ThnhZLC/tikv-0/data \
  --log-file=$TIUP_HOME/data/ThnhZLC/tikv-0/tikv.log

It adds the --data-dir parameter, and the value of this parameter has a higher priority than the value in your configuration file, so your configuration does not take effect.

| username: buptzhoutian | Original post link

tiup requires an SSH user on the server with sudo as root privileges.

| username: TiDB_C罗 | Original post link

Looks like a bug

func (inst *TiKVInstance) Start(ctx context.Context, version utils.Version) error {
	configPath := filepath.Join(inst.Dir, "tikv.toml")
	if err := prepareConfig(
		configPath,
		inst.ConfigPath,
		inst.getConfig(),
	); err != nil {
		return err
	}

	endpoints := pdEndpoints(inst.pds, true)
	args := []string{
		fmt.Sprintf("--addr=%s", utils.JoinHostPort(inst.Host, inst.Port)),
		fmt.Sprintf("--advertise-addr=%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.Port)),
		fmt.Sprintf("--status-addr=%s", utils.JoinHostPort(inst.Host, inst.StatusPort)),
		fmt.Sprintf("--pd-endpoints=%s", strings.Join(endpoints, ",")),
		fmt.Sprintf("--config=%s", configPath),
		fmt.Sprintf("--data-dir=%s", filepath.Join(inst.Dir, "data")),
		fmt.Sprintf("--log-file=%s", inst.LogFile()),
	}

In the prepareConfig function, inst.ConfigPath is received but not used

func prepareConfig(outputConfigPath string, userConfigPath string, preDefinedConfig map[string]any) error {
	dir := filepath.Dir(outputConfigPath)
	if err := utils.MkdirAll(dir, 0755); err != nil {
		return err
	}

	userConfig, err := unmarshalConfig(userConfigPath)
	if err != nil {
		return errors.Trace(err)
	}
	if userConfig == nil {
		userConfig = make(map[string]any)
	}

	cf, err := os.Create(outputConfigPath)
	if err != nil {
		return errors.Trace(err)
	}

	enc := toml.NewEncoder(cf)
	enc.Indent = ""
	return enc.Encode(spec.MergeConfig(preDefinedConfig, userConfig))
}

It just merges userConfigPath and writes it to tikv.toml, but the actual startup uses the fmt.Sprintf(“–data-dir=%s”, filepath.Join(inst.Dir, “data”)) in args

| username: tidb狂热爱好者 | Original post link

Nonsense. There are no deployment plans or methods available on the internet.

| username: 像风一样的男子 | Original post link

tiup playground is used for experiencing and testing environments.

| username: buptzhoutian | Original post link

The configuration file is used, specified by --config. However, it generates a fixed value for --data-dir, which has a higher priority than the one in the configuration file.

| username: buptzhoutian | Original post link

How is quickly getting started with TiDB through the playground considered messing around? The command line parameters used are all officially supported.

| username: TiDB_C罗 | Original post link

This is not a matter of priority. The generated configuration file is supposed to be in the user-specified path, but in reality, it is not in the user-specified path.

| username: buptzhoutian | Original post link

In practice, the configuration file used will include all the content specified by the user. Therefore, the generation and use of the configuration file are not problematic. However, it also manages several command-line parameters. If both the configuration file and the command-line parameters specify data-dir, the command-line parameter will take effect.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.