如何选举tidb的owner ?

【 TiDB 版本】: 5.7.25-TiDB-v5.4.0
【K8s 版本】:v1.20.15
【TiDB Operator 版本】:1.3.2
【遇到的问题】:
现在三个tidb节点,但是没有owner节点,导致无法执行DDL,如何选取owner节点呢 ?

出现这个问题的情况是,当时的owner节点tidb-tidb-1 挂掉了,因为是无状态的服务,我重启了后,还是不能选出owner

使用curl -X POST http://10.20.186.225:10080/ddl/owner/resign 提示连接不上,或者是 This node is not a ddl owner, can’t be resigned:
···
curl -X POST http://10.20.186.225:10080/ddl/owner/resign
This node is not a ddl owner, can’t be resigned./ # curl -X POST http://10.20.186.225:10080/ddl/owner/resign
curl: (28) Failed to connect to 10.20.186.225 port 10080 after 131920 ms: Operation timed out
···

看官方文档,还有一种方法:

tidb-ctl etcd delowner [LeaseID] [flags] + ownerKey

但是我如何知道LeaseID 和 flags 呢

使用admin show ddl 结果如下 :

文档中是使用delowner :

https://docs.pingcap.com/zh/tidb/stable/tidb-troubleshooting-map#31-ddl


 tidb-ctl etcd delowner [LeaseID] [flags] + ownerKey

但实际命令里面没有delowner :

/tmp/tidb-community-server-v5.4.0-linux-amd64 # ./tidb-ctl etcd delowner 7fe29d0d-1376-49f3-918f-37f6e8057c9d
control the info about etcd by grpc_gateway

Usage:
  tidb-ctl etcd [command]

Available Commands:
  ddlinfo     Show All Information about DDL
  delkey      Delete the key associated with DDL by `delkey [key]`
  putkey      [ONLY FOR TEST!] put a key in the path of TiDB schema versions by `putkey [key] [value]`

Flags:
  -h, --help   help for etcd

Global Flags:
      --ca string         TLS CA path
      --host ip           TiDB server host (default 127.0.0.1)
      --pdhost ip         PD server host (default 127.0.0.1)
      --pdport uint16     PD server port (default 2379)
      --port uint16       TiDB server port (default 10080)
      --ssl-cert string   TLS Cert path
      --ssl-key string    TLS Key path

Use "tidb-ctl etcd [command] --help" for more information about a command.
subcommand is required

难道文档的是写错了 ?
就是要把etcd的key删了才能自动选择owner吗 ?

先用ddlinfo命令去查看,找到key的名字,然后用delkey来删除试试,例如:

tidb-ctl etcd delkey "/tidb/ddl/fg/owner/XXXXXXXXXXXXXXXX"
1 个赞

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。