GVKun编程网logo

获取org.elasticsearch.transport.NodeDisconnectedException:[] [inet [localhost / 127.0.0.1:9300]] [集群/节点/信息]已断开连接

6

对于想了解获取org.elasticsearch.transport.NodeDisconnectedException:[][inet[localhost/127.0.0.1:9300]][集群/节

对于想了解获取org.elasticsearch.transport.NodeDisconnectedException:[] [inet [localhost / 127.0.0.1:9300]] [集群/节点/信息]已断开连接的读者,本文将提供新的信息,并且为您提供关于API:127.0.01:8844/nacos/v1/ns/instance/beat. code:500 msg: java.net.ConnectException: Connection ref、Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案、com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known serve、curl: (7) Failed to connect to localhost port 9200: Connection denied elasticsearch 无法启动或加载的有价值信息。

本文目录一览:

获取org.elasticsearch.transport.NodeDisconnectedException:[] [inet [localhost / 127.0.0.1:9300]] [集群/节点/信息]已断开连接

获取org.elasticsearch.transport.NodeDisconnectedException:[] [inet [localhost / 127.0.0.1:9300]] [集群/节点/信息]已断开连接

我是Elastic Search Java Api [5.0]的新手。我正在使用elasticsearch-5.0.0。我尝试用Spring
Boot创建一个Java Application(Maven)。运行应用程序后,它显示

2016-11-04 23:32:19.339  INFO 8280 --- [][generic][T#2]]      org.elasticsearch.client.transport       : [X-Ray] failed to get node info for [#transport#-1][DESKTOP-8SIPHSN][inet[localhost/127.0.0.1:9300]], disconnecting...org.elasticsearch.transport.NodeDisconnectedException: [][inet[localhost/127.0.0.1:9300]][cluster:monitor/nodes/info] disconnected

我的配置文件是

@Configurationpublic class ElasticsearchConfiguration {  @Bean  public Client client() {        TransportClient client = new TransportClient();        TransportAddress address = new  InetSocketTransportAddress("localhost",9300);        client.addTransportAddress(address);                return client;    }}

我正在使用默认群集“ elasticsearch”。我需要帮助以适当地找出原因来解决我的问题。

答案1

小编典典

尝试使用PreBuiltTransportClient5.0文档中提到的内容:

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

https://www.elastic.co/guide/zh-CN/elasticsearch/client/java-
api/current/transport-
client.html

另请注意,TransportClientfor ES版本2.x与5.x不兼容:

客户端必须具有与集群中的节点相同的主版本(例如2.x或5.x)。客户端可以连接到具有不同次要版本(例如2.3.x)的群集,但是有可能不支持新功能。理想情况下,客户端应具有与群集相同的版本。

https://www.elastic.co/guide/zh-CN/elasticsearch/client/java-
api/current/client.html

更新资料

作为连接测试,请尝试执行以下简单程序:

import org.elasticsearch.client.transport.TransportClient;import org.elasticsearch.common.settings.Settings;import org.elasticsearch.common.transport.InetSocketTransportAddress;import org.elasticsearch.transport.client.PreBuiltTransportClient;import java.net.InetAddress;import java.net.UnknownHostException;public class App {    public static void main(String[] args) throws UnknownHostException {        // The following settings aren''t strictly necessary, because the default cluster name is "elasticsearch".        Settings settings = Settings.builder().put("cluster.name", "elasticsearch").build();        TransportClient client = new PreBuiltTransportClient(settings);        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));        System.out.println(client.connectedNodes());    }}

它应该打印到标准输出,如下所示:

[{luhcORJ}{luhcORJOSzSLPBeXocDsuQ}{mkTJpwIAQGuNYTHfRLqUIw}{127.0.0.1}{127.0.0.1:9300}]

API:127.0.01:8844/nacos/v1/ns/instance/beat. code:500 msg: java.net.ConnectException: Connection ref

API:127.0.01:8844/nacos/v1/ns/instance/beat. code:500 msg: java.net.ConnectException: Connection ref

ERROR [com.alibaba.nacos.client.naming:454] - [uuid=] [token=] - request 127.0.0.1:8844 Failed. ErrCode:500, ErrMsg:Failed to req API:127.0.01:8844/nacos/v1/ns/instance/beat. code:500 msg: java.net.ConnectException: Connection refused

遇到这种错误有

以下几种方法解决

1、如果是集群 重启一定要用这个命令:sh startup.sh -p 8848 -m standalone否则继续报错

2、删除nacos文件夹下的data文件夹

Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案

Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案

Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案

作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/

在启动hadoop时,出现了如下错误:

Call From java.net.UnknownHostException: ubuntu-larntin: ubuntu-larntin to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused;

而且启动datanode、yarn都正常,只有namenode一直挂掉

解决方案如下:

wrr@ubuntu:~$ hadoop namenode -format

之后,重新启动所有的集群,即可

wrr@ubuntu:~$ cd /home/wrr/java/hadoop-2.7.6/sbin
wrr@ubuntu:~/java/hadoop-2.7.6/sbin$ ./hadoop-daemon.sh start namenode
starting namenode, logging to /home/wrr/java/hadoop-2.7.6/logs/hadoop-wrr-namenode-ubuntu.out
wrr@ubuntu:~/java/hadoop-2.7.6/sbin$ jps
8307 DataNode
9317 NameNode
7431 
9352 Jps
8476 ResourceManager

之后,再次在eclipse上运行程序,就没问题了。

新建了一个java文件

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class HDFSFileIfExist {
    public static void main(String[] args){
        try{
            String fileName = "test";
            Configuration conf = new Configuration();
            conf.set("fs.defaultFS", "hdfs://localhost:9000");
            conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
            FileSystem fs = FileSystem.get(conf);
            if(fs.exists(new Path(fileName))){
                System.out.println("文件存在");
            }else{
                System.out.println("文件不存在");
            }
 
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

判断当前hadoop-2.7.6目录下是否存在test文件

如果想看更多关于java API的内容,可以看大数据技术原理与应用 第三章 分布式文件系统HDFS 学习指南_厦大数据库实验室博客

 

 

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known serve

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known serve

SpringCloud 的eureka服务端,它默认会为自己注册到服务端,所以才会报这个错:

可以在application.yml做这样设置:

eureka:
  client:
    fetch-registry: false 

它默认是true,我们把它改为fasle就好了

curl: (7) Failed to connect to localhost port 9200: Connection denied elasticsearch 无法启动或加载

curl: (7) Failed to connect to localhost port 9200: Connection denied elasticsearch 无法启动或加载

如何解决curl: (7) Failed to connect to localhost port 9200: Connection denied elasticsearch 无法启动或加载?

我按照 this guide 在 Ubuntu 20.04 (LEMP) 上安装 Elasticsearch。当我跑步时:

curl ''localhost:9200''
@H_301_4@

我收到此错误:

curl: (7) Failed to connect to localhost port 9200: Connection refused
@H_301_4@

每当我运行:sudo -i service elasticsearch start@H_301_4@ 命令需要大约 20 分钟才能完成时,服务器会进入 504 Gateway Time-out 直到命令结束,并以以下错误结束:

Job for elasticsearch.service Failed because a fatal signal was delivered to the control process.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
@H_301_4@

我已编辑 sudo nano /etc/elasticsearch/elasticsearch.yml@H_301_4@ 无济于事。

当我运行 journalctl -xe@H_301_4@ 时,我看到下面的长屏幕。如果有人可以请给我一个有关如何解决此问题的指示,我将不胜感激。我尝试了 every scenario on this page,但没有成功。

enter image description here

运行 journalctl -f --unit elasticsearch@H_301_4@ 给出以下结果:

Jul 31 06:09:03 Domain.com systemd[1]: Failed to start Elasticsearch.
Jul 31 06:09:03 Domain.com systemd-entrypoint[40315]: 2021-07-31 04:09:03,074610 UTC [40315] INFO  Main.cc@106 Parent process died - ML controller exiting
Jul 31 06:18:46 Domain.com systemd[1]: Starting Elasticsearch...
Jul 31 06:18:49 Domain.com systemd-entrypoint[41903]: encountered [2] errors parsing [/etc/elasticsearch/jvm.options]
Jul 31 06:18:49 Domain.com systemd-entrypoint[41903]: [1]: encountered improperly formatted JVM option in [/etc/elasticsearch/jvm.options] on line number [33]: [ -xms2g]
Jul 31 06:18:49 Domain.com systemd-entrypoint[41903]: [2]: encountered improperly formatted JVM option in [/etc/elasticsearch/jvm.options] on line number [34]: [ -Xmx2g]
Jul 31 06:18:49 Domain.com systemd[1]: elasticsearch.service: Main process exited,code=exited,status=1/FAILURE
Jul 31 06:18:49 Domain.com systemd[1]: elasticsearch.service: Failed with result ''exit-code''.
Jul 31 06:18:49 Domain.com systemd[1]: Failed to start Elasticsearch.
Jul 31 06:21:43 Domain.com systemd[1]: Starting Elasticsearch...
@H_301_4@

jvm.options@H_301_4@ 文件包括:

################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file,or set any additional options,you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required,it should be done through a file in jvm.options.d,## and the min and max should be set to the same value. For
## example,to set the heap to 4 GB,create a new file in the
## jvm.options.d directory containing these lines:
##
## -xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead,create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcmarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC,uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcmarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=/var/lib/elasticsearch

# specify an alternative path for JVM Fatal error logs
-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringdistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:/var/log/elasticsearch/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
@H_301_4@

以下是elasticsearch.yml@H_301_4@文件的内容:

# ======================== 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: my-application
#
# ------------------------------------ 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: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- 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 -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: localhost
#network.host: localhost
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#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.
#
# ---------------------------------- VarIoUs -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
@H_301_4@

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

我们今天的关于获取org.elasticsearch.transport.NodeDisconnectedException:[] [inet [localhost / 127.0.0.1:9300]] [集群/节点/信息]已断开连接的分享就到这里,谢谢您的阅读,如果想了解更多关于API:127.0.01:8844/nacos/v1/ns/instance/beat. code:500 msg: java.net.ConnectException: Connection ref、Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案、com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known serve、curl: (7) Failed to connect to localhost port 9200: Connection denied elasticsearch 无法启动或加载的相关信息,可以在本站进行搜索。

本文标签: