Dubbo-go 3.0 注冊(cè)中心

2022-04-14 17:51 更新

Dubbo-go 3.0 注冊(cè)中心配置

參考samples dubbo-go-samples/registry

Registry 注冊(cè)中心配置

  • Nacos 注冊(cè)中心
dubbo:
  application: # 應(yīng)用信息,服務(wù)啟動(dòng)后會(huì)將相關(guān)信息注冊(cè)到注冊(cè)中心,可被客戶端從 url 中識(shí)別
    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 # 注冊(cè)中心選擇 nacos 
      address: 127.0.0.1:8848 # nacos ip
      group: myGroup # nacos group, 默認(rèn) DEFAULT_GROUP
      namespace: 9fb00abb-278d-42fc-96bf-e0151601e4a1 # nacos namespaceID, should be created before. 默認(rèn)public
      username: abc
      password: abc
  protocols:
    dubbo:
      name: dubbo
      port: 20000
  provider:
    services:
      UserProviderWithCustomGroupAndVersion: # 接口三元組:接口名、版本號(hào)、分組。client 和 server 需要保持一致。
        interface: org.apache.dubbo.UserProvider.Test # 接口名必填
        version: myInterfaceVersion # 默認(rèn)為空
        group: myInterfaceGroup # 默認(rèn)為空

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

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

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

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

  • ETCD 注冊(cè)中心
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
  • 應(yīng)用級(jí)服務(wù)注冊(cè)發(fā)現(xiàn)
dubbo:
  registries:
    demoZK:
      protocol: zookeeper # nacos/zookeeper
      address: 127.0.0.1:2181
      registry-type: service # 使用應(yīng)用級(jí)服務(wù)發(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)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)