Issues Related to Deploying TiDB with Docker-Compose on Linux CentOS 8.5

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

Original topic: Linux Centos8.5 docker-compose部署TiDB的相关问题

| username: wenrou

[TiDB Usage Environment] Production Environment
[TiDB Version]
[Reproduction Path]
[Encountered Issues: Problem Phenomenon and Impact]
Using git clone GitHub - pingcap/tidb-docker-compose
Deployment is done using the default configuration in docker-compose.yml to start the deployment directly.
Issue 1:
The disk usage under the tidb-docker-compose/data/ folder is too large, with some folders taking up too much space (prometheus, tikv0, tikv1, tikv2).
Which files in which folders can be deleted directly, or how to solve the problem of excessive disk usage?
Issue 2:
Can TiDB restore the database directly by migrating folders? If it can be migrated directly, which folders need to be migrated? It’s similar to directly copying /tidb-docker-compose/data/ to the corresponding location on the target server and then restarting docker-compose.
Issue 3:
When deploying with docker-compose, how to adjust the relevant configuration files to prevent excessive memory and disk usage?
[Resource Configuration]
64G memory, 52G already used
100G disk for storing tidb-docker-compose, 34G already used
[Attachments: Screenshots/Logs/Monitoring]
image

| username: Billmay表妹 | Original post link

Please refer to the official requirements for deployment.

| username: Billmay表妹 | Original post link

Question 1:
In the tidb-docker-compose/data/ folder, the folders prometheus, tikv0, tikv1, tikv2 are components of the TiDB cluster. Prometheus is the monitoring component, and tikv0, tikv1, tikv2 are TiKV components. If you do not need monitoring data, you can delete the prometheus folder; if your TiKV data has been backed up, you can delete the tikv0, tikv1, tikv2 folders. However, it is recommended to back up the data before deleting to avoid accidental data loss. If you need to retain monitoring data and TiKV data, you can consider adding more hard disk space.

Question 2:
You can use folder migration to restore the database. In the TiDB cluster, TiDB, PD, and TiKV all have data that needs to be backed up. The data of TiDB and PD can be backed up by backing up the corresponding data directories, and the data of TiKV can be backed up by backing up the corresponding data and db directories. Specifically, you can back up the tidb, pd, tikv0, tikv1, tikv2 directories under the tidb-docker-compose/data/ directory to the corresponding locations on the designated server, and then mount the corresponding data and db directories to the container when starting the TiDB cluster. Note that if your TiDB cluster uses the TiCDC component, you also need to back up the TiCDC checkpoint directory.

Question 3:
When deploying a TiDB cluster using docker-compose, you can adjust the relevant configuration files by modifying the configuration in the docker-compose.yml file. For example, you can adjust the memory and disk usage of the TiKV component by modifying the configuration of tikv. Specifically, you can find the configuration of tikv in the docker-compose.yml file and then modify the corresponding parameters. For example, you can adjust the memory usage of the TiKV component by modifying the server.memory-quota parameter, and adjust the disk usage of the TiKV component by modifying the storage.block-cache-size parameter. Note that the TiDB cluster needs to be restarted for the changes to take effect after modifying the configuration file.