Failed to establish connection 错误与elasticsearch
Failed to establish connection error with elasticsearch
我一直在关注有关开发个性化语音助手的简单教程。为此,我正在使用 Elasticsearch。当我尝试 运行 代码时,elasticsearch 显示 Failed to establish new connection
出现错误。我不确定是什么导致了这个错误,因为我已经安装了 elasticsearch 及其 python 客户端。
我检查了是否安装了 elasticsearch 及其 python 客户端,我已经安装了。我已经通过 pip3 安装安装了 python 客户端。我还检查了连接 URL 是否正确,我相信它是正确的,即 https://localhost:9200/
.
我正在使用 macOS。
s = Elasticsearch(['https://localhost:9200/'])
bulk(es, records, index='voice_assistant', doc_type='text', raise_on_error=True)
def search_es(query):
res = es.search(index="voice_assistant", doc_type="text", body={
"query" :{
"match": {
"voice_command": {
"query": query,
"fuzziness": 2
}
}
},
})
return res['hits']['hits'][0]['_source']['sys_command'
实际的错误信息是
File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 105, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused)
谁能帮我解决这个错误。我是第一次使用elasticsearch
编辑:我曾尝试在终端中 运行 elasticsearch,但收到以下警告,
OpenJDK 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
我在谷歌上进一步搜索了这个警告,并找到了一个答案,提到它可能是弹性搜索中的 ab ug,我不确定,因为我使用的是最新版本。我提到的答案是
编辑2:
现在,当我尝试在 erminal 中启动 elasticsearch 时,出现以下错误
StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.0.jar:7.4.0]
我昨天也遇到了同样的错误,但是当我重新启动我的系统时,一切正常,是不是因为某种操作在运行ning 后面并且它有任何特定的killall
命令在启动之前终止所有操作吗?
通过使用最新版本的 python-es 模块,问题得到解决,因此最好升级模块。在上面的例子中,之前使用的版本是2.4.0v,现在使用的最新版本是6.0.0v,所以问题已经解决了。
我一直在关注有关开发个性化语音助手的简单教程。为此,我正在使用 Elasticsearch。当我尝试 运行 代码时,elasticsearch 显示 Failed to establish new connection
出现错误。我不确定是什么导致了这个错误,因为我已经安装了 elasticsearch 及其 python 客户端。
我检查了是否安装了 elasticsearch 及其 python 客户端,我已经安装了。我已经通过 pip3 安装安装了 python 客户端。我还检查了连接 URL 是否正确,我相信它是正确的,即 https://localhost:9200/
.
我正在使用 macOS。
s = Elasticsearch(['https://localhost:9200/'])
bulk(es, records, index='voice_assistant', doc_type='text', raise_on_error=True)
def search_es(query):
res = es.search(index="voice_assistant", doc_type="text", body={
"query" :{
"match": {
"voice_command": {
"query": query,
"fuzziness": 2
}
}
},
})
return res['hits']['hits'][0]['_source']['sys_command'
实际的错误信息是
File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 105, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused)
谁能帮我解决这个错误。我是第一次使用elasticsearch
编辑:我曾尝试在终端中 运行 elasticsearch,但收到以下警告,
OpenJDK 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
我在谷歌上进一步搜索了这个警告,并找到了一个答案,提到它可能是弹性搜索中的 ab ug,我不确定,因为我使用的是最新版本。我提到的答案是
编辑2: 现在,当我尝试在 erminal 中启动 elasticsearch 时,出现以下错误
StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.0.jar:7.4.0]
我昨天也遇到了同样的错误,但是当我重新启动我的系统时,一切正常,是不是因为某种操作在运行ning 后面并且它有任何特定的killall
命令在启动之前终止所有操作吗?
通过使用最新版本的 python-es 模块,问题得到解决,因此最好升级模块。在上面的例子中,之前使用的版本是2.4.0v,现在使用的最新版本是6.0.0v,所以问题已经解决了。