This guide describes how to use MSE Sync to synchronize all service data from a self-managed Consul instance to a Microservices Engine (MSE) Nacos instance, replace client dependencies, update application configurations, and verify the migration.
Migration stages
| Stage | Description |
|---|---|
| 1. Configure MSE Sync | Start MSE Sync and set it up with the source Consul instance and destination MSE Nacos instance to synchronize service data. |
| 2. Replace client dependencies | Replace the Consul SDK with the Nacos SDK in application projects. |
| 3. Update application configurations | Point applications to the MSE Nacos instance instead of the Consul instance. |
| 4. Repackage, deploy, and verify | Rebuild applications and confirm that services register correctly with MSE Nacos. |
Prerequisites
Before you begin, ensure that you have:
An MSE Nacos engine. For more information, see Create a Nacos engine
MSE Sync deployed and running. For more information, see Migration solution based on MSE Sync
Step 1: Start MSE Sync and import configurations
Start MSE Sync and import the source and destination instance configurations by using a YAML configuration file.
Create the configuration file
Create a YAML file with the following content:
clusters:
- clusterName: dst
connectKeyList:
- {nacos.endpoint}:8848
clusterType: NACOS
- clusterName: src
connectKeyList:
- {consul.endpoint}:8500
clusterType: CONSUL
tasks:
- source: src
destination: dstReplace the placeholder values:
| Placeholder | Replace with | Example |
|---|---|---|
{nacos.endpoint} | The endpoint of the MSE Nacos instance | mse-zzzzz-.nacos-ans.mse.aliyuncs.com |
{consul.endpoint} | The IP address of the Consul instance | 10.0.0.1 |
Import the configuration file
Start MSE Sync and import the configuration file. After the import, MSE Sync periodically scans for new services in both the source and destination instances and automatically creates synchronization tasks.
MSE Sync periodically scans the Consul instance and synchronizes updates. To adjust the scan interval, set the consul.refresh.interval parameter. The default value is 5 seconds.
Verify synchronization
View the number of completed synchronization tasks in MSE Sync. Confirm that all service data has been synchronized from Consul to the MSE Nacos instance.
Step 2: Replace client dependencies
Replace the Consul SDK with the Nacos SDK in application projects.
For Spring Cloud applications, update the Maven dependency as follows:
| groupId | artifactId | |
|---|---|---|
| Before (Consul) | org.springframework.cloud | spring-cloud-starter-consul-discovery |
| After (Nacos) | com.alibaba.cloud | spring-cloud-starter-alibaba-nacos-discovery |
Remove the Consul dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>Add the Nacos dependency:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>Use a version of spring-cloud-starter-alibaba-nacos-discovery compatible with the Spring Cloud version in the project.
Step 3: Update application configurations
Replace the Consul configuration block in the application configuration file with the Nacos configuration block to set the MSE Nacos instance as the service registry.
Example configuration (application.yml):
server:
port: 9999
spring:
application:
name: sp-provider
cloud:
nacos:
discovery:
server-addr: mse-xxxxx-nacos-ans.mse.aliyuncs.com:8848The following commented-out block shows the original Consul configuration for reference:
# consul:
# host: 11.164.x.x
# port: 8500
# config:
# enabled: false
# discovery:
# health-check-path: /healthStep 4: Repackage and deploy applications
Rebuild application packages with the updated dependencies and configurations. Deploy the new packages to the environment.
Step 5: Verify the migration
After deployment, complete the following checks:
Confirm that all applications start without errors.
Test service-to-service calls to verify that service discovery works correctly.
Open the MSE console and check that all applications are registered with the MSE Nacos instance.
FAQ
Service data in Consul is not synchronized to MSE Nacos
Check whether the service in Consul passes its health check. MSE Sync synchronizes only data of healthy instances. Unhealthy or failing services are excluded from synchronization.
References
For more information about MSE Sync and other supported instance types, see Migration solution based on MSE Sync.