Databases 6 min read

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.

Hacker Afternoon Tea
Hacker Afternoon Tea
Hacker Afternoon Tea
How to Manually Set Up an Undermoon Redis Cluster
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 build

Redis 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_broker

Deploy Coordinator

$ RUST_LOG=undermoon=debug,coordinator=debug UNDERMOON_BROKER_ADDRESS=127.0.0.1:7799 target/debug/coordinator

Deploy 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_proxy

Register 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"
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RustRedisClusterUndermoonMemory BrokerServer Proxy
Hacker Afternoon Tea
Written by

Hacker Afternoon Tea

You might find something interesting here ^_^

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.