How to Manually Set Up an Undermoon Redis Cluster
This step‑by‑step tutorial shows how to build Undermoon from source, deploy a memory broker, coordinator, two server proxies and four Redis nodes on a single machine, register them via JSON APIs, create a named cluster, and verify its operation with redis‑cli.
Project address: https://github.com/doyoubi/undermoon
Architecture
All components are deployed on a single machine:
mem_broker (memory broker)
coordinator
2 server proxies
4 Redis nodes
Build the binary
$ cargo buildRedis must be installed before proceeding.
Deploy Memory Broker
$ RUST_LOG=undermoon=debug,mem_broker=debug UNDERMOON_ADDRESS=127.0.0.1:7799 target/debug/mem_brokerDeploy Coordinator
$ RUST_LOG=undermoon=debug,coordinator=debug UNDERMOON_BROKER_ADDRESS=127.0.0.1:7799 target/debug/coordinatorDeploy Server Proxy and Redis
Chunk implementation
For a detailed description of the chunk mechanism, refer to the external Undermoon documentation.
Run Server Proxy and Redis
Start two server proxies and four Redis instances. Each command should be run in a separate terminal.
# First half
$ redis-server --port 7001
$ redis-server --port 7002
$ RUST_LOG=undermoon=debug,server_proxy=debug UNDERMOON_ADDRESS=127.0.0.1:6001 target/debug/server_proxy
# Second half
$ redis-server --port 7003
$ redis-server --port 7004
$ RUST_LOG=undermoon=debug,server_proxy=debug UNDERMOON_ADDRESS=127.0.0.1:6002 target/debug/server_proxyRegister Server Proxy and Redis with Memory Broker
Because all processes run on 127.0.0.1, the registration JSON must contain distinct host fields (e.g., localhost1 and localhost2) so the memory broker treats the proxies as belonging to different hosts.
curl -XPOST -H 'Content-Type: application/json' "http://localhost:7799/api/v3/proxies/meta" -d '{"proxy_address": "127.0.0.1:6001", "nodes": ["127.0.0.1:7001", "127.0.0.1:7002"], "host": "localhost1"}'
curl -XPOST -H 'Content-Type: application/json' "http://localhost:7799/api/v3/proxies/meta" -d '{"proxy_address": "127.0.0.1:6002", "nodes": ["127.0.0.1:7003", "127.0.0.1:7004"], "host": "localhost2"}'Verify registration:
$ curl http://localhost:7799/api/v3/proxies/addresses
{"addresses":["127.0.0.1:6001","127.0.0.1:6002"]}
$ curl http://localhost:7799/api/v3/proxies/meta/127.0.0.1:6001
{..."free_nodes":["127.0.0.1:7001","127.0.0.1:7002"]...}
$ curl http://localhost:7799/api/v3/proxies/meta/127.0.0.1:6002
{..."free_nodes":["127.0.0.1:7003","127.0.0.1:7004"]...}Create the cluster
Ask the memory broker to create a cluster named mycluster that uses four Redis nodes.
$ curl -XPOST -H 'Content-Type: application/json' http://localhost:7799/api/v3/clusters/meta/mycluster -d '{"node_number": 4}'Connect to the cluster with redis-cli and verify slot distribution and key routing.
$ redis-cli -h 127.0.0.1 -p 6001 -c
127.0.0.1:6001> cluster nodes
mycluster___________2261c530e98070a6____ 127.0.0.1:6001 myself,master - 0 0 3 connected 8192-16383
mycluster___________ad095468b9deeb2d____ 127.0.0.1:6002 master - 0 0 3 connected 0-8191
127.0.0.1:6001> get a
(nil)
127.0.0.1:6001> get b
-> Redirected to slot [3300] located at 127.0.0.1:6002
"1"Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
