- PD cannot start
- PD losts its data because of disk failure.
- Version 1.13 or later is required because the Go modules are used.
Generally, you do not need to compile source code because the PD Control tool already exists in the released binary or Docker. However, developer users can refer to the instructions above for compiling source code.
Download the following installation package where PD Recover binary locates.
indicates the version number of TiKV. For example, if {version}
is v5.0.0
, the package download link is https://download.pingcap.org/tidb-v5.0.0-linux-amd64.tar.gz
.
This section describes how to use PD Recover to recover a PD cluster.
To recover a PD cluster, only two necessary parameters are required:
- Cluster ID
- Allocated ID
The cluster ID can be obtained from the log of PD, TiKV. To get the cluster ID, you can view the log directly on the server.
Get cluster ID from PD log (recommended)
To get the cluster ID from the PD log, run the following command:
[2019/10/14 10:35:38.880 +00:00] [INFO] [server.go:212] ["init cluster id"] [cluster-id=6747551640615446306]
...
Get cluster ID from TiKV log
To get the cluster ID from the TiKV log, run the following command:
...
Get allocated ID
The allocated ID value you specify must be larger than the currently largest allocated ID value. To get allocated ID, you can either get it from the monitor, or view the log directly on the server.
Get allocated ID from the monitor (recommended)
To get allocated ID from the monitor, you need to make sure that the metrics you are viewing are the metrics of the last PD leader, and you can get the largest allocated ID from the Current ID allocation panel in PD dashboard.
Get allocated ID from PD log
4000
...
Or you can simply run the above command in all PD servers to find the largest one.
Before deploying a new PD cluster, you need to stop the the existing PD cluster and then delete the previous data directory which is specified by --data-dir
.
Use pd-recover
When you see the prompted information that the recovery is successful, restart the whole cluster.
Multiple cluster IDs are found when getting the cluster ID
When a PD cluster is created, a new cluster ID is generated. You can determine the cluster ID of the old cluster by viewing the log.
The PD service is required when you execute pd-recover
. Deploy and start the PD cluster before you use PD Recover.