Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update pd member peer url of running cluster #25050

Closed
truong-hua opened this issue Jun 2, 2021 · 2 comments
Closed

How to update pd member peer url of running cluster #25050

truong-hua opened this issue Jun 2, 2021 · 2 comments
Labels
type/question The issue belongs to a question. type/stale This issue has not been updated for a long time.

Comments

@truong-hua
Copy link

truong-hua commented Jun 2, 2021

Etcd has a command etcdctl member update <member_id> --peer-urls=<new_peer_url> to cover a case that a etcd member is restarted and it's IP address has been changed.

I have a 3 node pd cluster as follows:

version: '2.1'

services:
  pd0:
    image: pingcap/pd:latest
    volumes:
      - data0:/data
    command:
      - --name=pd3
      - --client-urls=http://0.0.0.0:2379
      - --peer-urls=http://0.0.0.0:2380
      - --advertise-client-urls=http://pd0:2379
      - --advertise-peer-urls=http://pd0:2380
      - --initial-cluster=pd0=http://pd0:2380,pd1=http://pd1:2380,pd2=http://pd2:2380
      - --data-dir=/data
  pd1:
    image: pingcap/pd:latest
    volumes:
      - data1:/data
    command:
      - --name=pd1
      - --client-urls=http://0.0.0.0:2379
      - --peer-urls=http://0.0.0.0:2380
      - --advertise-client-urls=http://pd1:2379
      - --advertise-peer-urls=http://pd1:2380
      - --initial-cluster=pd0=http://pd0:2380,pd1=http://pd1:2380,pd2=http://pd2:2380
      - --data-dir=/data
  pd2:
    image: pingcap/pd:latest
    volumes:
      - data2:/data
    command:
      - --name=pd2
      - --client-urls=http://0.0.0.0:2379
      - --peer-urls=http://0.0.0.0:2380
      - --advertise-client-urls=http://pd2:2379
      - --advertise-peer-urls=http://pd2:2380
      - --initial-cluster=pd0=http://pd0:2380,pd1=http://pd1:2380,pd2=http://pd2:2380
      - --data-dir=/data

volumes:
  data0:
  data1:
  data2:

Now I shutdown pd0, I keep all volumes persistent and replace pd0 with a new pd4 as follows:

version: '2.1'

services:
  pd4:
    image: pingcap/pd:latest
    volumes:
      - data0:/data
    command:
      - --name=pd4
      - --client-urls=http://0.0.0.0:2379
      - --peer-urls=http://0.0.0.0:2380
      - --advertise-client-urls=http://pd4:2379
      - --advertise-peer-urls=http://pd4:2380
      - --join=http://pd1:2380
      - --data-dir=/data
volumes:
  data0:

After pd4 has been started, it joined to the cluster successfully and every is seem worked. But when I do /pd-ctl member on a node, it gives me:

{
  "header": {
    "cluster_id": 6969063719555665170
  },
  "members": [
    {
      "name": "pd2",
      "member_id": 3486081234046183923,
      "peer_urls": [
        "http://pd2:2380"
      ],
      "client_urls": [
        "http://pd2:2379"
      ],
      "deploy_path": "/",
      "binary_version": "v5.0.1",
      "git_hash": "ea1449c7c693d94661b3c60d35b8679ebfb3da34"
    },
    {
      "name": "pd4",
      "member_id": 16382016976602811638,
      "peer_urls": [
        "http://pd0:2380"
      ],
      "client_urls": [
        "http://pd4:2379"
      ],
      "deploy_path": "/",
      "binary_version": "v5.0.1",
      "git_hash": "ea1449c7c693d94661b3c60d35b8679ebfb3da34"
    },
    {
      "name": "pd1",
      "member_id": 17107318113395953248,
      "peer_urls": [
        "http://pd1:2380"
      ],
      "client_urls": [
        "http://pd1:2379"
      ],
      "deploy_path": "/",
      "binary_version": "v5.0.1",
      "git_hash": "ea1449c7c693d94661b3c60d35b8679ebfb3da34"
    }
  ],
  "leader": {
    "name": "pd1",
    "member_id": 17107318113395953248,
    "peer_urls": [
      "http://pd1:2380"
    ],
    "client_urls": [
      "http://pd1:2379"
    ],
    "deploy_path": "/",
    "binary_version": "v5.0.1",
    "git_hash": "ea1449c7c693d94661b3c60d35b8679ebfb3da34"
  },
  "etcd_leader": {
    "name": "pd1",
    "member_id": 17107318113395953248,
    "peer_urls": [
      "http://pd1:2380"
    ],
    "client_urls": [
      "http://pd1:2379"
    ],
    "deploy_path": "/",
    "binary_version": "v5.0.1",
    "git_hash": "ea1449c7c693d94661b3c60d35b8679ebfb3da34"
  }
}

And you see, the pd4 peer url is still remain "http://pd0:2380" which is of the old pd0. How can I update that peer url to reflect a new address? In reality, I use Docker Swarm and I use IP address for peer urls and every time the container restarted, I have to update the peer urls config to a new IP address.

@truong-hua truong-hua added the type/question The issue belongs to a question. label Jun 2, 2021
@truong-hua
Copy link
Author

Sorry, but I believe this is a bug. The new old node rejoin to existed cluster should auto update it self address to reflect the new one. Isn't it?

@jebter
Copy link

jebter commented Jun 6, 2024

Please refer: #48740. I will close this issue. If there are any updates, you can reopen it.

@jebter jebter closed this as completed Jun 6, 2024
@jebter jebter added the type/stale This issue has not been updated for a long time. label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question The issue belongs to a question. type/stale This issue has not been updated for a long time.
Projects
None yet
Development

No branches or pull requests

2 participants