-
Notifications
You must be signed in to change notification settings - Fork 480
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
Support cluster mode #302
Support cluster mode #302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the cluster topology and version would store on local storage?
@git-hulk That is a good question, I still consider that, we must should know the nodes may keep old cluster topology if restarted. That may cause terrible things if the IP and port are reused. |
yup, use ip:port as the unique identifier would cause problems, the node id would be better if we also persist it. |
One cluster mode is similar with redis cluster, please see #219
One cluster mode is similar with redis cluster, please see apache#219
One cluster mode is similar with redis cluster, please see #219
resolves #219
Deploy Kvrocks Cluster
In our cluster solution, you should firstly deploy some kvrocks instances and set replication relationship, and
Kvrocks doesn't support to communicate with each others, so we need to tell every node the cluster topology.
The command is
CLUSTER SETNODES
$ALL_NODES_INFO
$VERSION
$FORCE
$ALL_NODES_INFO
format:$node_id
$ip $port
$role
$master_node_id
$slot_range
.$role
: master or slave,$master_node_id
: master_node_id if it is slave, otherwise, this value is-
. slave needn't set$slot_range
.Example:
$VERSION
means current cluster topology version that is stored or generated by management component such as config server or meta-server.Kvrocks can know itself node id by compared with itself ip and port in received
all nodes info
, but you maybe bind kvrorks to0.0.0.0
, so it is necessary to setNODEID
explicitly to let it know itself. As the same with redis cluster, node id is 40 characters length.$NODE_ID
Moreover, cluster doesn't handle failover and migration, you should set cluster topology again after failover, of course, you should do that if you add some new nodes into cluster.
Access Kvrocks Cluster
After setting cluster topology, we have tested, it adopt
redis-cli
,redis-benchmark
,python redis cluster sdk
, andredis-cluster-proxy
. So you may doesn't need to change your redis cluster request code to access kvrocks cluster.Have a try
In
tool/try_cluster
, you can changeBIN_PATH
of kvrocks bin path, and then./try_cluster.sh start
to create a small cluster that has 6 nodes(3 maters and 3 replicas)then run
./try_cluster.sh watch
to observe cluster nodes, you also can do some tests byredis-cli
,redis-benchmark
,redis cluster sdk
andredis-cluster-proxy
for your fun.finally you can run
./try_cluster.sh stop
to stop all nodes and clean up directory.Supplements
Use
CLUSTERX
command to set cluster topology instead ofCLUSTER
#324