错误:
failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{uyXiOMnyRpyTSXqUoNxTyg}{localhost}{127.0.0.1:9300}]
版本:
Spring-Boot版本:2.1.6和Elasticsearch版本:7.3.0
这是我的elasticsearch.yml文件:
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
cluster.name: elastic
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
path.data: D:\JEE_Projects\spring\Spring_WorkSpace\spring-boot-with-mongodb
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
# http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
这是我的application.properties文件:
#Local MongoDB config
spring.data.mongodb.uri=mongodb://localhost:27017/newtest
# App config
server.port=8080
spring.application.name=BootMongo
server.address=localhost
# elastic search
spring.data.elasticsearch.cluster-name=elastic
#spring.main.allow-bean-definition-overriding=true
#spring.data.elasticsearch.repositories.enabled = true
spring.data.elasticsearch.cluster-nodes =localhost:9300
我重新启动了应用程序,重新启动了elasticsearch.bat,甚至重新启动了整个计算机,但没有任何反应。
此外,我以为其他一些应用程序会占用该端口,但它会被Elasticsearch本身占用。 (我在浏览器中输入了“ localhost:9300”,它的响应是“这不是HTTP端口”。)
答案 0 :(得分:0)
我猜想'cluster-name = elastic'可能是错误的。您确定弹性运行具有这样的集群名称吗?
答案 1 :(得分:0)
我问了这个问题,我找到了解决方法。
主要存在两个内部问题:
解决方案:
对于第一个问题,您可以为每个实体创建单独的索引。要解决第二个问题,您可以将Elasticsearch的版本降级到6.4.3,或者可以将Maven依赖项中的jar版本升级到7.3.0(但是在7.3.0 jar中,某些内置方法有些不同可能对您来说是未知的。