Migrate ZooKeeper Data to Alibaba Cloud MSE Using Snapshot Import
This guide explains how to move a self‑hosted ZooKeeper cluster to Alibaba Cloud MSE ZooKeeper by exporting the snapshot file, preparing the MSE instance, uploading the snapshot, and verifying the migration with example client code.
Background
Alibaba Cloud MSE offers a managed ZooKeeper service with higher stability than the open‑source version. When migrating an existing ZooKeeper cluster to MSE, you can either use real‑time sync (MSE Sync) or perform a full data import via snapshot files. This article focuses on the snapshot‑based migration, which is simple and fast for scenarios that allow brief downtime.
Principle
ZooKeeper periodically writes its in‑memory state to a snapshot.xxx file on disk. During startup, a ZooKeeper node loads this snapshot to initialize its data. By copying a snapshot from the source cluster to the target MSE cluster’s snapshot directory and restarting the MSE nodes, the full data set is imported.
Step‑by‑Step Migration
Step 1 – Obtain the Snapshot File
Locate the snapshot : Find the snapshot.xxx file generated by your self‑hosted ZooKeeper. The file path is defined by the dataDir entry in zoo.cfg (e.g., dataDir=/home/admin/zookeeper/zkData).
Select the latest file : If multiple snapshots exist, choose the one with the most recent timestamp.
Step 2 – Prepare the MSE ZooKeeper Cluster
Purchase an MSE ZooKeeper instance that matches your workload’s QPS/TPS requirements. Refer to the instance specifications table (not reproduced here) to select appropriate resources.
Step 3 – Upload the Snapshot
Log in to the Alibaba Cloud console, open the MSE ZooKeeper instance details page, and navigate to Node Management .
Click Data Import , then upload the snapshot.xxx file. The console will warn if the file exceeds the size limit (e.g., 800 MB for a 4C8G instance).
After uploading, the three‑node cluster will restart automatically; the import typically completes within five minutes.
Result Verification
Once the import finishes, you can connect to the MSE ZooKeeper endpoint (e.g., mse-xxxx-p.zk.mse.aliyuncs.com:2181) using standard ZooKeeper clients. Example Java code:
CuratorFrameworkFactory.builder()
.connectString("mse-xxxx-p.zk.mse.aliyuncs.com:2181")
.sessionTimeoutMs(10000)
.retryPolicy(retryPolicy)
.build()
.start();
ZooKeeper zk = new ZooKeeper("mse-xxxx-p.zk.mse.aliyuncs.com:2181", 30000, new Watcher() {
@Override
public void process(WatchedEvent event) {
System.out.println("ZooKeeper=====" + event);
}
});Successful connection confirms that the data has been migrated and is now accessible through the MSE service.
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.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
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.
