This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks-controller.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 25030c6  Add basic instruction for the raft engine in README (#233)
25030c6 is described below

commit 25030c6bd87a148ede5158d6ac2044e0da01ab7f
Author: hulk <[email protected]>
AuthorDate: Wed Dec 18 09:15:46 2024 +0800

    Add basic instruction for the raft engine in README (#233)
    
    Co-authored-by: Twice <[email protected]>
---
 README.md                                | 59 +++++++++++++++++++++++++++++---
 config/{config.yaml => config-raft.yaml} | 37 +++++++++-----------
 config/{config.yaml => config-zk.yaml}   | 18 +++-------
 config/config.yaml                       | 11 ++----
 4 files changed, 77 insertions(+), 48 deletions(-)

diff --git a/README.md b/README.md
index 4f10ccc..7975b3f 100644
--- a/README.md
+++ b/README.md
@@ -21,15 +21,18 @@ Apache Kvrocks Controller is a cluster management tool for 
[Apache Kvrocks](http
 $ git clone https://github.com/apache/kvrocks-controller
 $ cd kvrocks-controller
 $ make # You can find the binary file in the `_build` dir if all goes good
-# ---
-# If you do not have a suitable Golang compilation environment locally, you 
can also use 'make BUILDER_IMAGE=<golang:version>' to choose a Golang image for 
compilation.
-# $ make BUILDER_IMAGE=golang:1.20.3
 ```
 ### Overview
 ![image](docs/images/overview.png)
 For the storage, the ETCD is used as the default storage now. Welcome to 
contribute other storages like MySQL, Redis, Consul and so on. And what you 
need to do is to implement the [Engine 
interface](https://github.com/apache/kvrocks-controller/blob/unstable/store/engine/engine.go).
 
-### 1. Run the controller server
+### Supported Storage Engine
+
+- [x] ETCD
+- [x] Zookeeper
+- [x] Embedded Storage based on Raft (experimental)
+
+### Run the controller server
 
 ```shell
 # Use docker-compose to setup the etcd or zookeeper
@@ -37,9 +40,55 @@ $ make setup
 # Run the controller server
 $ ./_build/kvctl-server -c config/config.yaml
 ```
+
 ![image](docs/images/server.gif)
 
-### 2. Use the terminal client to interact with the controller server
+### Run server with the raft embedding engine
+
+> Note: The embedded Raft engine is still in the experimental stage, and it's 
not recommended to use it in the production environment.
+
+Change the storage type to `raft` in the configuration file.
+
+```yaml
+storage_type: raft
+
+raft:
+  id: 1
+  data_dir: "/data/kvrocks/raft/1"
+  cluster_state: "new"
+  peers:
+    - "http://127.0.0.1:6001";
+    - "http://127.0.0.1:6002";
+    - "http://127.0.0.1:6003";
+```
+
+- id: the node id for the raft node, it's also an index in the peers list
+- data_dir: the directory to store the raft data
+- cluster_state: the state of the raft cluster, it should be `new` when the 
cluster is initialized. And it should be `existing` when the cluster is already 
bootstrapped.
+- peers: the list of the raft peers, it should include all the nodes in the 
cluster.
+
+And then you can run the controller server with the configuration file.
+
+```shell
+$ ./_build/kvctl-server -c config/config-raft.yaml
+```
+
+#### Add/Remove a raft peer node
+
+We now support adding and removing via the HTTP API.
+
+```shell
+# Add a new peer node
+curl -XPOST -d '{"id":4,"peer":"http://127.0.0.1:6004","operation":"add"}'  
http://127.0.0.1:9379/api/v1/raft/peers
+
+# Remove a peer node
+curl -XPOST -d '{"id":4, "operation":"remove"}'  
http://127.0.0.1:9379/api/v1/raft/peers
+
+# List all the peer nodes
+curl http://127.0.0.1:9379/api/v1/raft/peers
+```
+
+### Use client to interact with the controller server
 
 ```shell
 # Show help
diff --git a/config/config.yaml b/config/config-raft.yaml
similarity index 62%
copy from config/config.yaml
copy to config/config-raft.yaml
index 2bec5dc..17973c7 100644
--- a/config/config.yaml
+++ b/config/config-raft.yaml
@@ -20,30 +20,25 @@ addr: "127.0.0.1:9379"
 
 
 # Which store engine should be used by controller
-# options: etcd, zookeeper
+# options: etcd, zookeeper, raft
+# Note: the raft engine is an experimental feature and is not recommended for 
production use.
+#
 # default: etcd
-storage_type: etcd
-
-etcd:
-  addrs:
-    - "127.0.0.1:2379"
-  username:
-  password:
-  elect_path:
-  tls:
-    enable: false
-    cert_file:
-    key_file:
-    ca_file:
+storage_type: raft
 
-zookeeper:
-  addrs:
-    - "127.0.0.1:2181"
-  scheme:
-  auth:
-  elect_path:
+raft:
+  id: 1
+  data_dir: "/data/kvrocks/raft"
+  # Cluster state must be 'new' or 'existing'.
+  # For a new cluster, its initial cluster state must be set to 'new'.
+  # And you would like to join an existing cluster, its initial cluster state 
must be set to 'existing'.
+  cluster_state: "new"
+  peers:
+    - "http://127.0.0.1:6001";
+    - "http://127.0.0.1:6002";
+    - "http://127.0.0.1:6003";
 
 controller:
   failover:
     ping_interval_seconds: 3
-    min_alive_size: 5
\ No newline at end of file
+    min_alive_size: 5
diff --git a/config/config.yaml b/config/config-zk.yaml
similarity index 82%
copy from config/config.yaml
copy to config/config-zk.yaml
index 2bec5dc..1bcfbf7 100644
--- a/config/config.yaml
+++ b/config/config-zk.yaml
@@ -20,21 +20,11 @@ addr: "127.0.0.1:9379"
 
 
 # Which store engine should be used by controller
-# options: etcd, zookeeper
+# options: etcd, zookeeper, raft
+# Note: the raft engine is an experimental feature and is not recommended for 
production use.
+#
 # default: etcd
-storage_type: etcd
-
-etcd:
-  addrs:
-    - "127.0.0.1:2379"
-  username:
-  password:
-  elect_path:
-  tls:
-    enable: false
-    cert_file:
-    key_file:
-    ca_file:
+storage_type: zookeeper
 
 zookeeper:
   addrs:
diff --git a/config/config.yaml b/config/config.yaml
index 2bec5dc..d2e414f 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -20,7 +20,9 @@ addr: "127.0.0.1:9379"
 
 
 # Which store engine should be used by controller
-# options: etcd, zookeeper
+# options: etcd, zookeeper, raft
+# Note: the raft engine is an experimental feature and is not recommended for 
production use.
+#
 # default: etcd
 storage_type: etcd
 
@@ -36,13 +38,6 @@ etcd:
     key_file:
     ca_file:
 
-zookeeper:
-  addrs:
-    - "127.0.0.1:2181"
-  scheme:
-  auth:
-  elect_path:
-
 controller:
   failover:
     ping_interval_seconds: 3

Reply via email to