Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent使用zookeeper作注册中心,报registry not found #75

Open
captainbupt opened this issue Jul 7, 2018 · 1 comment
Open

Agent使用zookeeper作注册中心,报registry not found #75

captainbupt opened this issue Jul 7, 2018 · 1 comment

Comments

@captainbupt
Copy link

启动agent的时候报registry not found。查看了下zookeeper里面的内容,创建了一个/motan/agent/label-mesh/node节点,但是没有创建对应group的节点,我理解这表示zookeeper是可以连通的,但是注册的时候除了其他问题。

有意思的是,在同事的windows环境下,同样的配置是能够运行并注册成功的。但是它打包成linux的可执行文件后,也还是注册不了。难道agent会存在系统兼容的问题?

错误日志为:

E0707 10:19:59.905758    1094 server.go:59] registry not found! url &{Protocol:motan2 Host:192.168.10.57 Port:9102 Path:com.security.saker.common.interfaces.label.ILabelService Group: Parameters:map[proxy:motan2:8002 basicRefer:myBasicService conf-id:label-motan2 application:label-mesh nodeType:service export:motan2:9102] address: identity:}
E0707 10:19:59.905778    1094 agent.go:314] service export fail! url:&{motan2 192.168.10.57 9102 com.security.saker.common.interfaces.label.ILabelService  map[proxy:motan2:8002 basicRefer:myBasicService conf-id:label-motan2 application:label-mesh nodeType:service export:motan2:9102]  }, err:registry not found! url &{Protocol:motan2 Host:192.168.10.57 Port:9102 Path:com.security.saker.common.interfaces.label.ILabelService Group: Parameters:map[proxy:motan2:8002 basicRefer:myBasicService conf-id:label-motan2 application:label-mesh nodeType:service export:motan2:9102] address: identity:}

yaml配置文件如下:

#config fo agent
motan-agent:
  port: 9983
  mport: 8013
  log_dir: "./label-agent-logs"
  registry: "zk-registry" # registry id
  application: "label-mesh" #请求来源,用于在监控中标识请求的业务方,请各业务方务必修改成自己的标识,类似 APP_NAME

#config of registries
motan-registry: # motan-registry部分与client、server端的含义一致
  zk-registry: # registry id ,
    protocol: zookeeper
    address: "192.168.80.143:2181"

#conf of basic service
motan-basicService:
  myBasicService: # basic refer id
    group: hongbao # group name
    protocol: motan2 # rpc protocol
    registry: "zk-registry" # registry id
    #filter: "accessLog" # filter registed in extFactory
    serialization: simple
    nodeType: server

#conf of services
motan-service:
  label-motan2:
    path: com.security.saker.common.interfaces.label.ILabelService
    export: "motan2:9102"
    proxy: "motan2:8002"
    basicRefer: myBasicService

Agent启动文件如下:

package main

import (
	"github.com/weibocom/motan-go"
	"flag"
)

func main() {
	runAgent()
}

func runAgent() {
	//configFile := flag.String("config", "config.yml", "config file")
	flag.Parse()
	agent := motan.NewAgent(nil)   // agent 启动时可以指定自定义的扩展工厂,如果不指定则使用默认扩展工厂。默认扩展工厂包括了自带的不同类型的各种扩展实现。
	//agent.ConfigFile = *configFile // 指定agent配置文件不是必须操作,仅为方便demo运行。默认情况下agent支持启动参数 -c来指定配置文件。
	agent.ConfigFile = "labelConfig.yaml" // 指定agent配置文件不是必须操作,仅为方便demo运行。默认情况下agent支持启动参数 -c来指定配置文件。
	agent.StartMotanAgent()        // 启动agent
}
@dingzk
Copy link

dingzk commented Jul 19, 2018

demo中配置有一处错误,请注意下:对于server端agent来说yaml继承配置的key应该是"basicService" 而不是basicRefer,所以将你的yaml配置修改成:

#conf of services
motan-service:
label-motan2:
path: com.security.saker.common.interfaces.label.ILabelService
export: "motan2:9102"
proxy: "motan2:8002"
basicService: myBasicService

即 把basicRefer 替换成 basicService 即可。

见:core/globalContext.go 中第29行

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants