Synchronize registry clusters

更新时间:
复制 MD 格式

The registry synchronization component synchronizes microservices from a source registry to a target registry and lets you visually manage each sync task in the MSHA console. This component currently supports one-way or two-way synchronization between Nacos-to-Nacos and ZooKeeper-to-ZooKeeper registries.

Step 1: Preparations

  1. Prepare an ECS instance.

    1. Prepare an ECS instance in a VPC. The instance must have at least 2 cores and 4 GB of memory.

    2. The MSHA console uses port 8080 to interact with the ECS instance. Before synchronization, you must open this port in the Rule Configuration of the instance's security group.

  2. Prepare an RDS instance.

    1. Prepare an RDS instance in the same VPC as the ECS instance. You must configure a database account and password, and set up a whitelist. You can use any database name. The table creation statements are as follows:

      CREATE TABLE `cluster`
      (
          `id`               int(11) NOT NULL AUTO_INCREMENT,
          `cluster_id`       varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `cluster_name`     varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `cluster_type`     varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `connect_key_list` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          PRIMARY KEY (`id`)
      ) ENGINE = InnoDB
        AUTO_INCREMENT = 5
        DEFAULT CHARSET = utf8mb4
        COLLATE = utf8mb4_bin;
      
      CREATE TABLE `task`
      (
          `id`                int(11) NOT NULL AUTO_INCREMENT,
          `dest_cluster_id`   varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `group_name`        varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `name_space`        varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `operation_id`      varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `service_name`      varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `source_cluster_id` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `task_id`           varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `task_status`       varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `version`           varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          `worker_ip`         varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
          PRIMARY KEY (`id`)
      ) ENGINE = InnoDB
        AUTO_INCREMENT = 6
        DEFAULT CHARSET = utf8mb4
        COLLATE = utf8mb4_bin;
      Note

      You can use a self-managed MySQL database instead of an RDS instance. The self-managed database and the ECS instance must be in the same VPC, and the database port must be 3306.

  3. Add the ECS instance to the MSHA console.

    1. Log on to the Multi-active Disaster Recovery for Application Service (MSHA) console.

    2. In the navigation pane on the left, choose Resource Management > ECS.

    3. Add an ECS server in one of the following two ways:

      • On the ECS page, click Add Server. On the Add Server page that opens, enter the ECS information and click OK.

      • On the ECS page, click Sync ECS. In the Sync ECS window, select the server that you want to add and click Confirm.

  4. Enable the registry synchronization module.

    1. In the navigation pane on the left of the MSHA console, choose Multi-active Base > Module Activation > Service Layer.

    2. Select Registry Synchronization Service.

    3. In the navigation pane on the left, choose Multi-active Instance.

    4. In the Actions column of the target namespace, click Edit.

    5. In the Multi-active Component module, you can select Geo-redundant Active-Active Registry Synchronization Service.

      Note

      The Geo-redundant Active-Active Registry Synchronization Service option is visible only after you enable the geo-redundant architecture.

Step 2: Configure a registry synchronization cluster

  1. Log on to the MSHA console.

  2. In the navigation pane on the left, choose Resource Management > Registry Synchronization Cluster.

  3. On the Registry Synchronization Cluster page, click Add Sync Cluster.

  4. In the Add Sync Cluster wizard, select the correct region and the ECS server that you added in Step 1: Preparations, and then click Next.

    Note

    You can select multiple ECS servers to form a synchronization cluster.

  5. In the Configure Cluster wizard, enter the database information and click Next.

  6. Confirm that port 8080 is open on the ECS server. In the Confirm Sync Cluster Installation dialog box, select I confirm that the port is open and click Confirm.

  7. In the Install and Start Cluster wizard, wait for the installation to complete.

    When the operation is complete, you can view the task details.

Related operations

  • View synchronization clusters

    • On the Registry Synchronization Cluster page, you can view information about existing synchronization clusters.

    • On the Registry Synchronization Cluster page, click the synchronization cluster name or Scaling to view the cluster details.

    • On the Registry Synchronization Cluster page, click Refresh to update the cluster status. Click Health Check to run a health check on the cluster. The check results are as follows:

  • Retry cluster creation

    If a synchronization cluster has a status of 'running failed' or 'initialization failed', you can click Retry in the Actions column for that cluster to create it again.

    Note

    If the health check fails during cluster creation and the retry is unsuccessful, check for the following issues:

    • Check whether port 8080 is open on the ECS server.

    • Check whether the RDS instance is in the same VPC as the ECS server.

    • Check whether the RDS database address, database name, account, and password are correct.

    • Check whether the IP address whitelist is enabled for the RDS instance.

  • Scale out a synchronization cluster

    To ensure high availability, a synchronization cluster can have multiple ECS instances for synchronization. This configuration ensures that if one instance becomes unavailable, the other instances can continue to provide the service.

    1. On the Registry Synchronization Cluster page, select a cluster and click Scale-out.

    2. On the ECS Scale-out page, select the instance that you added in Step 1: Preparations and click Confirm.

      Important

      The security group of the ECS instance that is used for scaling out must have port 8080 open.

    3. On the Task Details page, wait for the installation task to finish.

  • Scale in a synchronization cluster

    1. On the Registry Synchronization Cluster page, select the instance to uninstall and click Uninstall.

    2. In the Confirm Uninstall This Sync Cluster dialog box, click Confirm.

    3. On the Task Details page, after the uninstallation task is complete, click Close.

      Note

      If the instance that you are uninstalling is the last one in the synchronization cluster, the system checks whether any sync tasks are still using the cluster. If so, you cannot uninstall the instance. If you successfully uninstall the last instance, the synchronization cluster is also uninstalled.

  • Uninstall a synchronization cluster

    On the Registry Synchronization Cluster page, click Uninstall Cluster to uninstall the cluster.

    Note

    If there are active sync tasks, you cannot uninstall the cluster.

Step 3: Configure registry information

Before you can create a microservice sync task, you must configure the registry information. Registry synchronization currently supports Nacos-to-Nacos and ZooKeeper-to-ZooKeeper synchronization.

  1. Log on to the MSHA console.

  2. In the navigation pane on the left, choose Multi-active Instance. On the list page, select the target multi-active instance to view its details page.

  3. In the navigation pane on the left, choose Service Layer Configuration, and then choose Registry Synchronization Configuration.

  4. On the Registry Synchronization Configuration page, click Manage Registries.

  5. On the Registry List page, click Add Registry.

  6. On the Registry List page, you can enter the cluster information and click Confirm.

    Parameter

    Description

    Cluster Name

    Can be customized, but must be unique.

    Cluster Type

    Select ZK or NACOS as needed.

    Cluster Endpoint

    • The private network address and port of the registry.

    • You can enter multiple addresses in a batch, separated by commas (,).

    Region

    Select a region that is already configured in your console, as needed.

    Note

    By default, the registry and the instances in the synchronization cluster must be in the same VPC. If the registry uses a public IP address, the ECS instance must be able to access the public network. Otherwise, the synchronization fails.

Related operations

After adding a registry, you can perform the following operations on the Registry List page:

  • View information about all added registries. You can search for existing registries by cluster name, cluster endpoint, cluster type, or a combination of these criteria.

  • In the Actions column for the target registry, click Delete.

    Note

    If the target registry has active sync tasks, you cannot delete it.

Step 4: Configure a registry sync task

  1. Log on to the MSHA console.

  2. In the navigation pane on the left, choose Multi-active Instance to open the list page. Select a multi-active instance to view its details.

  3. In the navigation pane on the left, choose Service Layer Configuration > Registry Synchronization Configuration.

  4. On the Registry Synchronization Configuration page, click Add Sync Task.

    • Add a Nacos-to-Nacos sync task

      1. On the Add Sync Task page, specify the sync task configuration:

        Parameter

        Description

        Sync Cluster

        Select a created sync cluster. For more information, see Step 2: Configure a registry synchronization cluster.

        Source Registry

        Select a created registry as the source registry, as needed. For more information, see Step 3: Configure registry information.

        Target Registry

        Select a created registry as the target registry, as needed. For more information, see Step 3: Configure registry information.

        Namespace

        • Enter the Nacos namespace ID. For more information, see Create a namespace.

        • If you leave this blank, it defaults to public.

        Important

        For Nacos synchronization, the source and target registry namespace IDs must be the same. Nacos 1.2 and later support custom namespace IDs.

        Group Name

        • Enter the Nacos group name.

        • If you leave this blank, it defaults to DEFAULT_GROUP.

        Service Name

        • The service name you enter must match the service name queried from the actual registry.

        • You can enter multiple service names to synchronize in a batch, separated by commas (,).

        Note

        When Nacos is the source registry, you can display all service names under the specified namespace and group name in that registry. You can also click Select Service Name and select one or more services to add on the Select Service Name page.

      2. When the operation is complete, click OK.

    • Add a ZooKeeper-to-ZooKeeper sync task

      Note

      Currently, synchronization between ZooKeeper registries only supports Dubbo services.

      1. On the Add Sync Task page, configure the sync task:

        Parameter

        Description

        Sync Cluster

        Select a created sync cluster. For more information, see Step 2: Configure a registry synchronization cluster.

        Source Registry

        Select a created registry as the source registry, as needed. For more information, see Step 3: Configure registry information.

        Target Registry

        Select a created registry as the target registry, as needed. For more information, see Step 3: Configure registry information.

        Group Name

        Enter the ZooKeeper group name.

        Note

        The group name corresponds to the Group of the Dubbo service. If you leave this blank, no restriction is applied based on the Group.

        Version

        Enter the ZooKeeper version information.

        Note

        The version corresponds to the Version of the Dubbo service. If you leave this blank, no restriction is applied based on the Version.

        Service Name

        • The service name you enter must match the service name queried from the actual registry.

        • You can enter multiple service names to synchronize in a batch, separated by commas (,).

        • ZooKeeper-to-ZooKeeper sync tasks support full synchronization. If you enter "*" for the service name, all services under the corresponding Group and Version are synchronized.

          Note

          The feature to display all service names in a ZooKeeper source registry is not currently supported.

      2. When the operation is complete, click Confirm.

    • Batch creation

      • When you add multiple services, the MSHA console executes these tasks asynchronously. The status of the running tasks is Creating sync task.

      • A sync task status of Syncing indicates that the service is being synchronized from the source registry to the target registry.

Related operations

After you configure the registry synchronization, you can perform the following operations on the registry synchronization configuration page:

  • Pause a sync task: Select a sync task with a Running Status of Running and click Pause. After pausing, microservice synchronization stops, and the service goes offline in the target registry. A status of Paused indicates that the sync task has stopped.

    Note

    Both pausing and deleting can stop the current service synchronization and have the same effect. However, deleting also removes the task information from the MSHA console and the RDS database. To avoid re-entering task information, use the pause feature unless deletion is required.

  • Resume a sync task: Select a sync task whose Running Status is Paused and click Resynchronize. The Running Status changes to Syncing, and the service resumes synchronization from the source registry to the target registry.

  • Delete a sync task: Select a sync task and click Delete. In the Confirm Delete This Sync Task dialog box, click OK. After the sync task is deleted, the microservice synchronization stops and the task is removed from the page.

    Important

    When you delete sync tasks in a batch, some tasks might not stop synchronizing. To safely delete tasks in a batch, first perform a batch pause operation, and then delete the paused sync tasks in a batch.

  • Retry a sync task: Select a sync task with a Running Status of Task creation failed or Creation timed out and click Retry. If multiple retries fail, check if the ECS server passes the health check.

  • Batch operations: You can perform batch operations, such as pause, resynchronize, and delete, on multiple sync tasks by selecting their checkboxes. Because these operations are executed asynchronously, they may take some time to complete.