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

Categories

0 votes
617 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 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...