Placement driver for TiKV
Go to file
Ryan Leung 071b864ea6
*: remove a stale alert (#9553)
ref tikv/pd#9548

Signed-off-by: Ryan Leung <rleungx@gmail.com>
2025-07-15 08:41:54 +00:00
.github *: fix typo (#8982) 2025-01-08 12:12:37 +00:00
client *: enable errcheck in test (#9505) 2025-07-10 09:53:00 +00:00
cmd/pd-server *: add leak check to the main package (#8043) 2025-07-07 07:58:54 +00:00
conf chore(dashboard): update TiDB Dashboard to v8.4.0-6a0d342d [master] (#8581) 2024-09-05 03:08:52 +00:00
docs *: check file header (#9015) 2025-01-21 03:35:17 +00:00
metrics *: remove a stale alert (#9553) 2025-07-15 08:41:54 +00:00
pkg keyspace, tso: disable default keyspace in next-gen (#9499) 2025-07-11 09:43:18 +00:00
plugin/scheduler_example util: move keyrange to keyutils (#9321) 2025-05-15 06:06:08 +00:00
scripts chore(dashboard): update TiDB Dashboard to v9.0.0-e1f8338b [master] (#9463) 2025-07-03 07:19:36 +00:00
server keyspace, tso: disable default keyspace in next-gen (#9499) 2025-07-11 09:43:18 +00:00
tests test: make TestTransferLeaderForScheduler stable (#9517) 2025-07-14 06:06:51 +00:00
tools keyspace, tso: disable default keyspace in next-gen (#9499) 2025-07-11 09:43:18 +00:00
.deepsource.toml Add deepsource analyze (#3271) 2020-12-15 18:32:26 +08:00
.gitignore test: add etcd key compatibility test (#9126) 2025-03-18 05:59:30 +00:00
.golangci.yml *: enable errcheck in test (#9505) 2025-07-10 09:53:00 +00:00
CHANGELOG.md Remove adjacent region scheduler (#3071) 2020-10-15 14:14:25 +08:00
CONTRIBUTING.md readme: update Go version, wording (#5777) 2022-12-13 17:16:52 +08:00
Dockerfile *: upgrade go to 1.23 (#8637) 2024-10-08 03:29:12 +00:00
LICENSE *: fix the license (#3752) 2021-06-09 11:26:29 +08:00
Makefile *: support next-gen build tag (#9345) 2025-05-27 10:37:25 +00:00
OWNERS OWNERS: Auto Sync OWNERS files from community membership (#8487) 2024-08-05 07:27:41 +00:00
OWNERS_ALIASES ci: udpate OWNERS_ALIASES file (#8598) 2024-09-06 09:50:35 +00:00
README.md readme: remove the TSO consistency test status badge (#8815) 2024-11-14 10:11:35 +00:00
codecov.yml tools: remove tidb dependencies (#9436) 2025-06-24 10:12:15 +00:00
errors.toml keyspace, tso: disable default keyspace in next-gen (#9499) 2025-07-11 09:43:18 +00:00
go.mod chore(dashboard): update TiDB Dashboard to v9.0.0-e1f8338b [master] (#9463) 2025-07-03 07:19:36 +00:00
go.sum chore(dashboard): update TiDB Dashboard to v9.0.0-e1f8338b [master] (#9463) 2025-07-03 07:19:36 +00:00
pd.code-workspace *: remove the Local TSO test cases (#8810) 2024-11-14 06:41:50 +00:00
tools.go *: improve the linter and fix some bugs (#8015) 2024-04-11 09:00:22 +00:00

README.md

PD

Check Status Build & Test Status GitHub release Go Report Card codecov

PD is the abbreviation for Placement Driver. It manages and schedules TiKV clusters.

PD supports fault-tolerance by embedding etcd.

contribution-map

If you're interested in contributing to PD, see CONTRIBUTING.md. For more contributing information about where to start, click on the contributor icon above.

Build

  1. Make sure Go (version 1.23) is installed.
  2. Use make to install PD. pd-server will be installed in the bin directory.

Usage

PD can be configured using command-line flags. For more information, see PD Configuration Flags.

Single node with default ports

You can run pd-server directly on your local machine. If you want to connect to PD from outside, you can let PD listen on the host IP.

# Set HOST_IP to the address you want to listen on
export HOST_IP="192.168.199.105"

pd-server --name="pd" \
          --data-dir="pd" \
          --client-urls="http://${HOST_IP}:2379" \
          --peer-urls="http://${HOST_IP}:2380" \
          --log-file=pd.log

Using curl to view PD members:

curl http://${HOST_IP}:2379/pd/api/v1/members

{
  "members": [
    {
      "name": "pd",
      "member_id": 15980934438217023866,
      "peer_urls": [
        "http://192.168.199.105:2380"
      ],
      "client_urls": [
        "http://192.168.199.105:2379"
      ],
      "deploy_path": "/",
      "binary_version": "v6.1.3",
      "git_hash": "1a4e975892512a97fb0e5b45c9be69aa76148793"
    }
  ]
}

You can also use httpie to call the API:

http http://${HOST_IP}:2379/pd/api/v1/members

Access-Control-Allow-Headers: accept, content-type, authorization
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: *
Content-Length: 1003
Content-Type: application/json; charset=UTF-8
Date: Mon, 12 Dec 2022 13:46:33 GMT

{
  "members": [
    {
      "name": "pd",
      "member_id": 15980934438217023866,
      "peer_urls": [
        "http://192.168.199.105:2380"
      ],
      "client_urls": [
        "http://192.168.199.105:2379"
      ],
      "deploy_path": "/",
      "binary_version": "v6.1.3",
      "git_hash": "1a4e975892512a97fb0e5b45c9be69aa76148793"
    }
  ]
}

Docker

You can choose one of the following methods to get a PD image:

  • Build locally:

    docker build -t pingcap/pd .
    
  • Pull from Docker Hub:

    docker pull pingcap/pd
    

Then you can run a single node using the following command:

# Set HOST_IP to the address you want to listen on
export HOST_IP="192.168.199.105"

docker run -d -p 2379:2379 -p 2380:2380 --name pd pingcap/pd \
          --name="pd" \
          --data-dir="pd" \
          --client-urls="http://0.0.0.0:2379" \
          --advertise-client-urls="http://${HOST_IP}:2379" \
          --peer-urls="http://0.0.0.0:2380" \
          --advertise-peer-urls="http://${HOST_IP}:2380" \
          --log-file=pd.log

Cluster

As a component of the TiKV project, PD needs to run with TiKV to work. The cluster can also include TiDB to provide SQL services. For detailed instructions to deploy a cluster, refer to Deploy a TiDB Cluster Using TiUP or TiDB on Kubernetes Documentation.