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.
Setting Up a Memory Broker Replica
项目地址:https://github.com/doyoubi/undermoon
Build the Binary
$ cargo buildRun 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_brokerRun 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_brokerVerify Replication
Insert data into the master:
# Put some data to the master:
$ ./examples/mem-broker/init.shCheck 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.tomlConnect 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:8899Recovering 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/recoveryAfter this call the system should resume normal operation.
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.
