Multiple Registration Centers

Multiple Registration Centers

A Dubbo application can configure multiple registration centers at different interface dimensions. Multiple registration centers can be used for cluster isolation, migration, and various other scenarios. For a more detailed explanation, refer to the Dubbo Java Multiple Registration Center Documentation.

API Configuration Method

  1. ins, _ := dubbo.NewInstance(
  2. dubbo.WithRegistry(
  3. registryWithID("nacos"),
  4. registry.WithNacos(),
  5. registry.WithAddress("127.0.0.1:8848"),
  6. ),
  7. dubbo.WithRegistry(
  8. registryWithID("zookeeper"),
  9. registry.WithZookeeper(),
  10. registry.WithAddress("127.0.0.1:2181"),
  11. ),
  12. )

Specify which registration center a service under a specific server should register to:

  1. // Specify that the service under the server registers to the zookeeper registration center
  2. srv, _ := ins.NewServer(server.WithServerRegistryIDs([]string{"zookeeper"}))
  3. // Specify that the service under the server registers to the nacos registration center
  4. srv2, _ := ins.NewServer(server.WithServerRegistryIDs([]string{"nacos"}))

Specify which registration center a particular service should register to:

  1. srv, _ := ins.NewServer()
  2. greet.RegisterGreetServiceHandler(srv, &GreetTripleServer{}, server.WithRegistryIDs([]string{"zookeeper"}))

The usage on the client side is similar.

YAML Configuration Method

Modify the server configuration at go-server/conf/dubbogo.yaml to register the service in both registration centers.

  1. dubbo:
  2. registries:
  3. zookeeper: # Specify the zookeeper registration center
  4. protocol: zookeeper
  5. address: 127.0.0.1:2181
  6. nacos: # Specify the nacos registration center
  7. protocol: nacos
  8. address: 127.0.0.1:8848
  9. protocols:
  10. triple:
  11. name: tri
  12. port: 20000

Supported Registration Centers

  • Nacos
  • Zookeeper
  • Polaris
  • Kubernetes

For example, when using Polaris as a registration center, you need to specify the following content, both via API or YAML configuration file:

  1. dubbo:
  2. registries:
  3. polarisMesh:
  4. protocol: polaris
  5. address: ${Polaris Server IP}:8091
  6. namespace: ${Polaris Namespace Info}
  7. token: ${Polaris Resource Authorization Token} # If Polaris server enables client authorization, this parameter needs to be configured

For usage with Kubernetes registration centers, please refer to the Control Plane documentation.

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)