apache / kvrocks-controller

Apache Kvrocks Controller is a cluster management tool for Apache Kvrocks.
https://kvrocks.apache.org/
Apache License 2.0
78 stars 42 forks source link

Add support of the failover command #173

Closed git-hulk closed 2 months ago

git-hulk commented 2 months ago

Before running the failover command, the cluster state is:

|-------|------------------------------------------|----------------|--------|-----------|
| SHARD |                 NODE ID                  |    ADDRESS     |  ROLE  | MIGRATING |
|-------|------------------------------------------|----------------|--------|-----------|
|     0 | YNgiFCBjjRYJYA3k9kyGmQrCESfgQdMhmQrdfG1g | 127.0.0.1:7770 | MASTER | NO        |
|     0 | gJy7c9V7Yn1DHMdOrNSrUBtqW4AroOFsHHuk6mLy | 127.0.0.1:7771 | SLAVE  | NO        |
|-------|------------------------------------------|----------------|--------|-----------|

Then run the failover command with:

❯ ./_build/kvctl failover shard 0 -n test-ns -c test-cluster
failover shard 0 successfully, new master id: gJy7c9V7Yn1DHMdOrNSrUBtqW4AroOFsHHuk6mLy.

And it will get the cluster:

|-------|------------------------------------------|----------------|--------|-----------|
| SHARD |                 NODE ID                  |    ADDRESS     |  ROLE  | MIGRATING |
|-------|------------------------------------------|----------------|--------|-----------|
|     0 | YNgiFCBjjRYJYA3k9kyGmQrCESfgQdMhmQrdfG1g | 127.0.0.1:7770 | SLAVE  | NO        |
|     0 | gJy7c9V7Yn1DHMdOrNSrUBtqW4AroOFsHHuk6mLy | 127.0.0.1:7771 | MASTER | NO        |
|-------|------------------------------------------|----------------|--------|-----------|