NoNodeAvailableException [没有已配置的节点可用] Elasticsearch

时间:2019-12-09 12:21:58

标签: java elasticsearch

我已经尝试了Internet上发布的所有可用解决方案,但是这些解决方案无法解决我所遇到的错误。我已经创建了单节点主服务器和数据服务器,集群的配置如下:

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 see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
 cluster.name: ers-reseller-data
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
 node.name: node-1
#
# Add custom attributes to the node:

 node.master: true
# node.client: true
 node.data: true

# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /opt/seamless/etc/dist/core/database/elasticsearch
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
 bootstrap.memory_lock: true
 bootstrap.system_call_filter: false
#
# Make sure that the `ES_HEAP_SIZE` environment variable 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: 0.0.0.0
 cluster.initial_master_nodes: node-1
#
# Set a custom port for HTTP:
#
 http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["node-1", "node-2", "node-3"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
 node.max_local_storage_nodes: 2
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
#node.local: true
# discovery.zen.ping.multicast.enabled: false
# discovery.zen.ping.unicast.hosts: ["node-1"]

当我执行curl 'http://locahost:9200'时,它显示以下输出,这表示节点已启动并正在运行

{
  "name" : "node-1",
  "cluster_name" : "ers-reseller-data",
  "version" : {
    "number" : "2.2.0",
    "build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe",
    "build_timestamp" : "2016-01-27T13:32:39Z",
    "build_snapshot" : false,
    "lucene_version" : "5.4.1"
  },
  "tagline" : "You Know, for Search"
}

在执行curl 'http://localhost:9200/_nodes'时,还会显示有关可用节点的详细信息。但是,当我尝试用Java代码连接execute时,它显示了以下异常。

例外:

java.lang.Exception: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{Ntvnz9ljSha0lZ7-2d3VGQ}{localhost}{127.0.0.1:9200}]]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
    at se.seamless.mcs.profilingsystem.services.impl.ElasticSearchSalesDataService.findCreditScoreMetrics(ElasticSearchSalesDataService:79)
    at se.seamless.mcs.profilingsystem.services.SalesDataService$findCreditScoreMetrics.call(Unknown Source)
    at o

请指导我遗失或做错的事情,以及为什么抛出不可用节点异常。谢谢

0 个答案:

没有答案