Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
632 views
in Technique[技术] by (71.8m points)

github.com/olivere/elastic/v7库无法连接带账号密码的ES库

我使用go的github.com/olivere/elastic/v7库连接es,但是无法连接带密码的es库,代码如下:
`

client, err = elastic.NewClient(
    // elastic.SetSniff(false),
    elastic.SetHealthcheckInterval(10*time.Second),
    elastic.SetMaxRetries(3),
    elastic.SetURL("http://xx:9200"),
    elastic.SetBasicAuth("username", "password"),
)

`
报错是:health check timeout: no Elasticsearch node available

请问是我初始化有问题还是这个库不支持带密码的es?
谢谢!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

问题已解决!!
原因是,es集群上根据不同索引创建了不同的用户,官方库可以使用小权限用户连接集群,而olivere需要使用最大权限账户才可以连接。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...