How to Configure a Memory Broker Replica in Undermoon

This guide shows how to build Undermoon, run a master and replica Memory Broker, verify data replication, and manually switch to the replica via the coordinator API when the master fails, ensuring continued service operation.

Hacker Afternoon Tea
Hacker Afternoon Tea
Hacker Afternoon Tea
How to Configure a Memory Broker Replica in Undermoon

Setting Up a Memory Broker Replica

项目地址:https://github.com/doyoubi/undermoon

Build the Binary

$ cargo build

Run the Replica

Start a replica instance with environment variables:

$ RUST_LOG=warp=info,undermoon=info,mem_broker=info UNDERMOON_ADDRESS=127.0.0.1:8899 UNDERMOON_META_FILENAME=metadata2 target/debug/mem_broker

Run the Master Memory Broker

Start the master and point it to the replica address, enabling periodic metadata synchronization (interval 3 seconds):

$ RUST_LOG=warp=info,undermoon=info,mem_broker=info UNDERMOON_REPLICA_ADDRESSES=127.0.0.1:8899 UNDERMOON_SYNC_META_INTERVAL=3 target/debug/mem_broker

Verify Replication

Insert data into the master:

# Put some data to the master:
$ ./examples/mem-broker/init.sh

Check master metadata: curl localhost:7799/api/v3/metadata After three seconds, check replica metadata (same endpoint): curl localhost:7799/api/v3/metadata The replica should return identical metadata.

Manual Failover When the Master Crashes

If the master fails, the system does not automatically fall back to the replica. The coordinator’s API must be invoked to switch the Memory Broker endpoint. During this interval the server proxy continues handling requests, but scaling and failover are unavailable until the coordinator’s Memory Broker endpoint is switched to the replica.

Switching the Coordinator

Assuming a coordinator is already running:

$ RUST_LOG=undermoon=info,coordinator=info target/debug/coordinator conf/coordinator.toml

Connect to the coordinator via the Redis protocol (port 6699) and change the broker configuration to point to the replica:

$ redis-cli -p 6699 CONFIG SET brokers 127.0.0.1:8899

Recovering from Incomplete Metadata Replication

If the master’s latest metadata has not been copied to the replica before failure, data loss may occur. To recover, collect the epoch from all recorded proxies and increase the metadata epoch via the coordinator API:

$ curl -XPUT localhost:7799/api/v3/epoch/recovery

After this call the system should resume normal operation.

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.

RustRedisReplicaUndermoonMemory BrokerCoordinator API
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.