Dubbo-go 3.0 注冊中心

2022-04-14 17:51 更新

Dubbo-go 3.0 注冊中心配置

參考samples dubbo-go-samples/registry

Registry 注冊中心配置

  • Nacos 注冊中心
dubbo:
  application: # 應用信息,服務啟動后會將相關(guān)信息注冊到注冊中心,可被客戶端從 url 中識別
    name: myApp # application=myApp; name=myApp
    module: opensource # module=opensource
    organization: dubbo # organization=dubbo
    owner: laurence # owner=laurence
    version: myversion # app.version=myversion
    environment: pro # environment=pro
  registries:
    nacosWithCustomGroup:
      protocol: nacos # 注冊中心選擇 nacos 
      address: 127.0.0.1:8848 # nacos ip
      group: myGroup # nacos group, 默認 DEFAULT_GROUP
      namespace: 9fb00abb-278d-42fc-96bf-e0151601e4a1 # nacos namespaceID, should be created before. 默認public
      username: abc
      password: abc
  protocols:
    dubbo:
      name: dubbo
      port: 20000
  provider:
    services:
      UserProviderWithCustomGroupAndVersion: # 接口三元組:接口名、版本號、分組。client 和 server 需要保持一致。
        interface: org.apache.dubbo.UserProvider.Test # 接口名必填
        version: myInterfaceVersion # 默認為空
        group: myInterfaceGroup # 默認為空

Dubbo-go 的注冊中心配置的 group、namespace、username、password,均與 nacos 相關(guān)概念對應。

  • Zookeeper 注冊中心
dubbo:
  # application: 與nacos 一致,不再贅述
  registries:
    demoZK:
      protocol: zookeeper # 注冊中心選擇 nacos 
      address: 127.0.0.1:2181 # zookeeper ip
      group: myGroup # nacos group, 默認 dubbo
  protocols:
    triple:
      name: tri
      port: 20000
  provider:
    services:
      UserProviderWithCustomGroupAndVersion: # 接口三元組:接口名、版本號、分組。client 和 server 需要保持一致。
        interface: com.apache.dubbo.sample.basic.IGreeter # 接口名必填
        version: myInterfaceVersion # 默認為空
        group: myInterfaceGroup # 默認為空

zookeeper 注冊時,provider 端將接口信息注冊在 /$(group)/$(interface)/providers 節(jié)點,以上面配置為例,注冊的 zk path 為 /myGroup/com.apache.dubbo.sample.basic.IGreeter/providers/

consumer 端注冊在 /$(group)/$(interface)/consumers 作統(tǒng)計用。

  • ETCD 注冊中心
dubbo:
  registries:
    etcd:
      protocol: etcdv3
      timeout: 3s
      address: 127.0.0.1:2379
  protocols:
    dubbo:
      name: dubbo
      port: 20000
  provider:
    services:
      UserProvider:
        interface: org.apache.dubbo.UserProvider
  • 應用級服務注冊發(fā)現(xiàn)
dubbo:
  registries:
    demoZK:
      protocol: zookeeper # nacos/zookeeper
      address: 127.0.0.1:2181
      registry-type: service # 使用應用級服務發(fā)現(xiàn)
  metadata-report: # 配置元數(shù)據(jù)中心
    protocol: zookeeper
    address: 127.0.0.1:2181
  protocols:
    triple:
      name: tri
      port: 20000
  provider:
    services:
      GreeterProvider:
        interface: com.apache.dubbo.sample.basic.IGreeter



以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號