单节点部署多副本

我能够在一个节点(一台物理机)上部署多副本吗,如在一个节点部署 3 个 tidb,3 个 pd,3个 tikv ?

我使用 tidb operator 部署,一共 3 个 pd 只有一个 pod 正常 runnning,另外两个都报了 etcd 的错:

[main.go:288] [“run server failed”] [error=“[PD:etcd:ErrStartEtcd]member 10f0df000a58db81 has already been bootstrapped: member 10f0df000a58db81 has already been bootstrapped”] [stack=“main.start\n\t/workspace/source/pd/cmd/pd-server/main.go:288\nmain.createServerWrapper\n\t/workspace/source/pd/cmd/pd-server/main.go:194\ngithub.com/spf13/cobra.(*Command).execute\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115\ngithub.com/spf13/cobra.(*Command).Execute\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039\nmain.main\n\t/workspace/source/pd/cmd/pd-server/main.go:71\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:272”]

使用 operator 部署的话能够配置每个 pd 副本的 initial-cluster-state 吗?


更新:测试集群中有两个节点,我将 pd 的 replica 设置为2,可以看到两个 pd 的 pod 分别被schedule 到两个节点上了,并且分别挂载到各自的 pvc。

但是只有一个 pod 正常运行,另一个 pod 仍然报了相同的错误:

[INFO] [etcd.go:310] ["starting an etcd server"] [etcd-version=3.5.15] [git-sha="Not provided (use ./build instead of go build)"] [go-version=go1.23.12] [go-os=linux] [go-arch=amd64] [max-cpu-set=112] [max-cpu-available=112] [member-initialized=false] [name=tidb-pd-5j8zv2] [data-dir=/var/lib/pd] [wal-dir=] [wal-dir-dedicated=]
[member-dir=/var/lib/pd/member] [force-new-cluster=false] [heartbeat-interval=500ms] [election-timeout=3s] [initial-election-tick-advance=true] [snapshot-count=100000] [max-wals=5] [max-snapshots=5] [snapshot-catchup-entries=5000] [initial-advertise-peer-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2380]"] [listen-peer-urls="[\"http://[::]:2380\"]"] [advertise-client-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2379]"] [listen-client-urls="[\"http://[::]:2379\"]"] [listen-metrics-urls="[]"] [cors="[*]"] [host-whitelist="[*]"] [initial-cluster="tidb-pd-4jo1o5=http://tidb-pd-pd-4jo1o5.tidb-pd-pd-peer.test:2380,tidb-pd-5j8zv2=http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2380"] [initial-cluster-state=new] [initial-cluster-token=tidb-cluster] [quota-backend-bytes=8589934592] [max-request-bytes=157286400] [max-concurrent-streams=4294967295] [pre-vote=true] [initial-corrupt-check=false] [corrupt-check-time-interval=0s] [compact-check-time-enabled=false] [compact-check-time-interval=1m0s] [auto-compaction-mode=periodic] [auto-compaction-retention=1h0m0s] [auto-compaction-interval=1h0m0s] [discovery-url=] [discovery-proxy=] [downgrade-check-interval=5s]
[WARN] [server.go:344] ["exceeded recommended request limit"] [max-request-bytes=157286400] [max-request-size="157 MB"] [recommended-request-bytes=10485760] [recommended-request-size="10 MB"]
[INFO] [backend.go:81] ["opened backend db"] [path=/var/lib/pd/member/snap/db] [took=991.989µs]
[INFO] [etcd.go:377] ["closing etcd server"] [name=tidb-pd-5j8zv2] [data-dir=/var/lib/pd] [advertise-peer-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2380]"] [advertise-client-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2379]"]
[INFO] [etcd.go:379] ["closed etcd server"] [name=tidb-pd-5j8zv2] [data-dir=/var/lib/pd] [advertise-peer-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2380]"] [advertise-client-urls="[http://tidb-pd-pd-5j8zv2.tidb-pd-pd-peer.test:2379]"]
[FATAL] [main.go:288] ["run server failed"] [error="[PD:etcd:ErrStartEtcd]member 74834717553fce0f has already been bootstrapped: member 74834717553fce0f has already been bootstrapped"] [stack="main.start\n\t/workspace/source/pd/cmd/pd-server/main.go:288\nmain.createServerWrapper\n\t/workspace/source/pd/cmd/pd-server/main.go:194\ngithub.com/spf13/cobra.(*Command).execute\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115\ngithub.com/spf13/cobra.(*Command).Execute\n\t/root/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039\nmain.main\n\t/workspace/source/pd/cmd/pd-server/main.go:71\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:272"]

存储冲突了吧,多个 Pod 挂载同一个目录,数据会互相覆盖

  • 第一个节点initial-cluster-state=new
  • 后续节点initial-cluster-state=existing

可以,但是要保证硬件资源足够才行。很容易硬件不足导致无法全部启动。

201.1课程中的第一个实验就是使用tiup playground部署的单节点多副本

没有的,每个pd都有自己的pvc,挂载也没问题。

可以部署, 需要将initial-cluster-state从new改为existing

集群的初始化逻辑冲突。在单节点上部署多副本 PD 时,多个 PD Pod 会尝试使用同一个本地存储目录初始化 etcd 集群,而 etcd 不允许重复初始化同一个数据目录。

第一个 PD Pod 的 initial-cluster-state 设为 new

只要资源够用就行,可以部署,把端口规划好就行了。

pd貌似不行

这个理论上是可以的,需要有不同的pvc及pv。
用operator部署,不需要指定initial-cluster-state参数的

1 个赞

不推荐、也基本不支持在一台物理机(一个 Node)上部署 3 副本的 TiDB / PD / TiKV 用来“模拟高可用”。

PD 本质上就是一个 etcd 集群

TiDB 架构里:

PD = 内嵌 etcd

3 个 PD = 3 个 etcd member

etcd 的核心假设是:

每个 member 在不同的故障域(Failure Domain)

而你现在是:

3 个 PD Pod

都调度到同一个 Kubernetes Node(同一物理机)

没试过

如果每个pd都有独立的 pvc 呢?

对我也觉得用 operator 部署,应该不需要指定参数的。但是报错看起来是每个 pd 的 initial-cluster-state 参数都是 new 所导致的

不仅要有独立的pvc,pvc对应的实际挂载路径也要是独立的吧,你看看呢

感谢回复。

看了下对应的PV,都是独立的hostpath。

使用operator应该不需要单独配置每个副本的吧 :cry: