All Products
Search
Document Center

Microservices Engine:Migrate service data from Consul instances to MSE Nacos instances

Last Updated:Feb 06, 2024

You can use MSE Sync to synchronize all service data from a Consul instance to a Microservices Engine (MSE) Nacos instance by performing simple configurations. During the migration, service dependencies are replaced, and application configurations are repackaged. This topic describes how to migrate service data from a Consul instance to an MSE Nacos instance.

Prerequisites

Procedure

  1. Start MSE Sync and import configurations of the source and destination instances to MSE Sync by using a configuration file.

    1. Create a configuration file that contains the following content:

      clusters:
        - clusterName: dst
          connectKeyList:
            - {nacos.endpoint}:8848
          clusterType: NACOS
        - clusterName: src
          connectKeyList:
            - {consul.endpoint}:8500
          clusterType: CONSUL
      tasks:
        - source: src
          destination: dst
      
      • Replace {nacos.endpoint} in the configuration file with the endpoint of the MSE Nacos instance. For example, replace {nacos.endpoint} with mse-zzzzz-.nacos-ans.mse.aliyuncs.com.

      • Replace {consul.endpoint} in the configuration file with the IP address of the Consul instance. For example, replace {consul.endpoint} with 10.0.0.1.

    2. Import the configuration file into MSE Sync. After the import, MSE Sync periodically scans new services in the source and destination instances and automatically creates tasks to synchronize service data.

    3. View the number of completed synchronization tasks and check whether all service data is synchronized.

  2. Replace the client dependency and modify configurations.

    1. Replace the client dependency. Replace the Consul SDK with the Nacos SDK.

      For Spring Cloud applications, replace spring-cloud-starter-consul-discovery with spring-cloud-starter-alibaba-nacos-discovery that is compatible with Spring Cloud.

    2. Modify configurations. Modify the configuration file to configure the MSE Nacos instance as the registry.

      In this example, the configuration of the Consul instance is replaced with the configuration of the MSE Nacos instance. The annotation shows the original configuration.

      server:
        port: 9999
      
      spring:
        application:
          name: sp-provider
        cloud:
          nacos:
            discovery:
              server-addr: mse-xxxxx-nacos-ans.mse.aliyuncs.com:8848
      #    consul:
      #      host: 11.164.x.x
      #      port: 8500
      #      config:
      #        enabled: false
      #      discovery:
      #        health-check-path: /health
  3. Repackage and release applications.

  4. Check whether applications are normally started and called, and check whether applications are registered with the MSE Nacos instance in the MSE console.

Note

MSE Sync periodically scans information about the Consul instance and synchronizes information updates. You can adjust the interval at which the instance information is updated by specifying consul.refresh.interval. The default value is 5 seconds.

FAQ

Service data in the Consul instance is not synchronized to the MSE Nacos instance. Why?

Check whether the service in Consul passes the health check. MSE Sync synchronizes only data of healthy instances.

References

For more information about MSE Sync and other instance types that are supported by MSE Sync, see Migration solution based on MSE Sync.