Spring boot “使用tcp端口”;9300“;在application.properties文件中,但仍然得到;所有配置的节点都不可用;
错误: 版本: Spring引导版本:2.1.6和Elasticsearch版本:7.3.0 这是我的elasticsearch.yml文件:Spring boot “使用tcp端口”;9300“;在application.properties文件中,但仍然得到;所有配置的节点都不可用;,spring-boot,
elasticsearch,Spring Boot,
elasticsearch,错误: 版本: Spring引导版本:2.1.6和Elasticsearch版本:7.3.0 这是我的elasticsearch.yml文件: failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{uyXiOMnyRpyTSXqUoNx
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}]
这是我的application.properties文件:
# ======================== 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
我重新启动了应用程序,重新启动了elasticsearch.bat,甚至重新启动了整个电脑,但一切都不正常
此外,我还以为其他一些应用程序会占用这个端口,但它被elasticsearch本身占用了。(我在浏览器中键入“localhost:9300”,它的响应是“这不是HTTP端口”)。我猜“cluster name=elastic”可能是错误的。您确定elastic使用这样的群集名称运行吗?我问了这个问题,我找到了解决方案 有两个主要的内部问题:
对于第一个问题,可以为每个实体创建单独的索引。要解决第二个问题,您可以将Elasticsearch的版本降级到6.4.3,也可以将Maven依赖项中的jar版本升级到7.3.0(但在7.3.0 jar中,一些内置方法有些不同,您可能不知道)。不,这不是问题所在。事实上,我发现了错误(总共3个错误),并将自己回答这个问题。但我现在有点忙。我很快就会写出解决方案。顺便说一下,谢谢你给我时间回答这个问题。你好@Dario,我已经添加了答案。看一看。
#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