github.com/olivere/elastic/v7库连接es库时出现问题
在使用elasticsearch时,您使用github.com/olivere/elastic/v7库尝试连接到带密码的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集群根据不同索引创建了不同的用户。官方库可以使用小权限用户连接集群,而olivere需要使用具有最大权限的帐户才能连接。因此,需要使用具有最大权限的帐户连接es库。
以上就是使用olivere/elastic/v7库连接带密码的ES库时,为什么会出现“health check timeout”错误?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号