[NacosSync] Registry Synchronization Component Use Tutorial ZooKeeper Migrates to Nacos

introduce

  • NacosSync is a synchronization component that supports multiple registries. It is based on the Spring boot development framework. The data layer uses Spring Data JPA. It follows the standard JPA access specification and supports multiple data source storage. It uses Hibernate by default to support tables more conveniently. Automatically create updates for
  • Using an efficient event asynchronous drive model, supports a variety of custom events, making the delay control of synchronous task processing within 3s, 8C16G stand-alone can support 6K synchronous tasks
  • In addition to stand-alone deployment, NacosSync also provides a highly available cluster deployment mode. NacosSync is a stateless design that migrates state data such as tasks to the database, making cluster expansion very convenient
  • The core interface of the Sync component is abstracted, and the synchronization types are distinguished through annotations, so that developers can easily expand different registration centers according to their own needs. Currently supported synchronization types:
    • Nacos data synchronization to Nacos
    • Synchronize Zookeeper data to Nacos
    • Nacos data synchronization to Zookeeper
    • Synchronize Eureka data to Nacos
    • Synchronize Consul data to Nacos

System Module Architecture

insert image description here

Get the installation package

There are two ways to get NacosSyncthe installation package

  • Directly download NacosSyncthe binary installation package of :https://github.com/nacos-group/nacos-sync/releases
  • Version 0.4.8 download page:https://github.com/nacos-group/nacos-sync/releases/tag/0.4.8
  • Build from source GitHubdownloaded fromNacosSync
    • git clone -b
    • cd nacosSync/
    • mvn clean package -U

    Path to object file:nacos-sync/nacossync-distribution/target/nacosSync.${version}.zip

database configuration

#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/nacos_sync?characterEncoding=utf8
spring.datasource.url=jdbc:postgresql://localhost:5432/nacos_sync
spring.datasource.username=nacos_sync
spring.datasource.password=nacos_sync

start server

startup restart

console

Access path:http://127.0.0.1:8083/

Add registry cluster information

  • Click the "Cluster Configuration" button in the left navigation bar to add a new cluster, first add a Zookeeper cluster, and select the cluster type as ZK.

    Note: The cluster name can be customized, but once confirmed, it cannot be modified. Otherwise, tasks added based on this cluster will not recover successfully after NacosSync restarts.

  • In the same steps, add a NacosSync cluster.
  • After adding, you can find it in the list
    insert image description here

Add sync task

  • Add a synchronization task from the Zookeeper cluster to the Nacos cluster. The granularity of synchronization is the service. The Zookeeper cluster is called the source cluster, and the Nacos cluster is called the target cluster.

  • After the addition is complete, you can view the added synchronization tasks in the service synchronization list

  • After the synchronization is complete, check whether the data is successfully synchronized to the Nacos cluster, and you can query it through the Nacos console.

  • At this moment, the data has been successfully synchronized from the Zookeeper cluster to the Nacos cluster, and the deployment structure is as follows
    insert image description here

  • Before upgrading the Provider, you need to ensure that the services released by the Provider have been configured in NacosSync. The synchronization method is from Nacos to Zookeeper, because after the Provider is upgraded and connected to Nacos, you need to ensure that the old Dubbo Consumer client can be in Zookeeper Subscribe to the address of the Provider, now, we add a synchronization task

    Note: The Nacos service is synchronized to Zookeeper, and there is no need to fill in the version number. When you select the source cluster, the input box for the version number will be automatically hidden.

  • During the upgrade process, there will be new and old versions of the client at the same time, the deployment structure is as follows
    insert image description here

  • After all client migrations are completed, the deployment structure is as follows
    insert image description here

  • Now, the Zookeeper cluster and NacosSync cluster can go offline.

Precautions

  • After the synchronization task is added, you need to ensure that the next service is successfully synchronized to the target cluster, which can be queried through the console of the target cluster.
  • NacosSync supports high-availability cluster mode deployment, you only need to configure the same database.
  • If you can't sort out the subscribed and published services, it is recommended to synchronize the services in two directions.
  • The Dubbo client currently does not support the weight function of Nacos. If you use the weight function, you need to reconsider whether the solution is suitable.

Guess you like

Origin blog.csdn.net/friendlytkyj/article/details/131756279