对于这个问题,大部分人出现在这个地方:

Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("172.16.2.13", 9300));​

问题在于前面初始化settings时给cluster设置了个新的名字,如:Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "tonsonmiao").build();

因为如果设置clustername后,容器会在添加transportaddress时,从集群名为tonsonmiao里查找是否有要设置的这个IP和端口,此时肯定找不到,所以会报这个错。

但是我今天又遇到这个问题,而在此之前一切正常,也就是说并不会因为代码的错误导致这个问题出现,这几天修改了下网关,可以访问这台服务器,于是我觉得可能是网络的变动,导致es出了问题,进入服务器查看:

[root@es elasticsearch-1.4.2]# ps -eaf | grep java
root 8782 8752 0 05:53 pts/1 00:00:00 grep java
root 27251 1 1 2015 ? 1-10:15:49 /usr/bin/java -Xms256m -Xmx1g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Delasticsearch -Des.path.home=/opt/elasticsearch-1.4.2 -cp :/opt/elasticsearch-1.4.2/lib/elasticsearch-1.4.2.jar:/opt/elasticsearch-1.4.2/lib/*:/opt/elasticsearch-1.4.2/lib/sigar/* org.elasticsearch.bootstrap.Elasticsearch [root@es elasticsearch-1.4.2]# netstat -anp | grep 9300
tcp 0 0 10.18.7.97:9300 10.17.3.96:51633 SYN_RECV -
tcp 0 0 10.18.7.97:9300 10.17.3.96:51635 SYN_RECV -
tcp 0 0 :::9300 :::* LISTEN 27251/java
tcp 0 0 ::ffff:10.18.7.97:41035 ::ffff:10.18.7.97:9300 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:9300 ::ffff:10.18.7.97:41030 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:41033 ::ffff:10.18.7.97:9300 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:41037 ::ffff:10.18.7.97:9300 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:41036 ::ffff:10.18.7.97:9300 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:41026 ::ffff:10.18.7.97:9300 ESTABLISHED 27251/java
tcp 0 0 ::ffff:10.18.7.97:9300 ::ffff:10.18.7.97:41025 ESTABLISHED 27251/java

 

可以看到es监听的ip地址发生了变化,对于多网卡的情况下,es默认会绑定其中任意一张网卡,如果es中间出现问题自动修复,那么会随机修改绑定网卡,导致节点被t出集群,曾经我在某银行系统,就遇到这个问题,某几个节点不定时的被t出集群。

对于这个问题的解决,需要修改es配置:

# Set the bind address specifically (IPv4 or IPv6):
#
network.bind_host: 10.18.7.97 # Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
network.publish_host: 10.18.7.97 # Set both 'bind_host' and 'publish_host':
#
network.host: 10.18.7.97

强制指明ip地址即可

Elasticsearch使用java读取数据报错NoNodeAvailableException: None of the configured nodes are available: [127.0.0.1:9300]的更多相关文章

  1. 解决ES报错NoNodeAvailableException[None of the configured nodes are available:问题

    elasticSearch的错误 NoNodeAvailableException[None of the configured nodes are available: [{#transport#- ...

  2. NoNodeAvailableException[None of the configured nodes are available:[.127.0.0.1}{127.0.0.1:9300]

    我在springboot 集成 elasticsearch,启动springboot测试创建索引,建立索引的时候报 : NoNodeAvailableException[None of the con ...

  3. ElasticSearch java客户端更新时出现的错误:NoNodeAvailableException[None of the configured nodes are available

    下午尝试 用ElasticSearch  的java客户端去做数据检索工作,测试了一下批量更新,代码如下: public static void bulkUpdateGoods(List<Goo ...

  4. (转)Elasticsearch NoNodeAvailableException None of the configured nodes are available

    问题背景:将es部署到内网中两台服务器,其Ip地址分别为:192.111.222.5,192.111.222.1(部署方式完全一样,是将192.111.222.1服务器上es整个部署包,拷贝到了192 ...

  5. 解决Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of the configured nodes are available

    Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of ...

  6. Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available

    连接elasticsearch已经成功,但是会报以下错误,字面意思是节点不可用这样 Exception in thread "main" NoNodeAvailableExcept ...

  7. NoNodeAvailableException[None of the configured nodes are available:

    elasticSearch的错误 NoNodeAvailableException[None of the configured nodes are available: [{#transport#- ...

  8. elasticsearch 使用tcp 访问NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{Yk0WjtKbQXqYCJSDFRYlRA}

    默认的 elasticsearch.yml 端口是9200,是给tcp提供的.如果想使用 自带的  TransportClient 需要配置为 tcp 的9300端口.配置方式为: 在/config/ ...

  9. Elasticsearch 9300无法访问,客户端出现NoNodeAvailableException[None of the configured nodes are available:  [{#transport#‐1}{exvgJLR‐RlCNMJy‐hzKtnA}

    1.  进入容器 docker exec ‐it ID /bin/bash 2. 拷贝配置文件到宿主机 docker cp  ID:/usr/share/elasticsearch/config/el ...

随机推荐

  1. 使用ExecutorService实现线程池

    ExecutorService是java提供的用于管理线程池的类. 线程池的作用: - 控制线程数量 - 重用线程 当一个程序中创建了许多线程,并在任务结束后销毁,会给系统带来过度消耗资源,以及过度切 ...

  2. 2017 Multi-University Training Contest - Team 2 Puzzle

    题目大意: 给定n, m, p.然后按照一个规则往n*m的方格里填数,最后一个方格是空格,然后玩拼图游戏,问能否复原 规则是:把1~n*m-1的排列中的第1,p+1,2*p+1.....个数依次取出来 ...

  3. [bzoj3886] [USACO15JAN]电影移动Moovie Mooving

    题目链接 状压\(dp\). 注意到\(n\leq 20\)且每个只能用一次,所以很显然可以压缩每部电影看过没,记\(f[sta]\)为状态为\(sta\)时最多可以看多久. 转移时先枚举状态,然后枚 ...

  4. BZOJ1202:狡猾的商人(带权并查集)

    1202: [HNOI2005]狡猾的商人 题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1202 Description: 刁姹接到一个 ...

  5. Equal Sums (map的基本应用) 多学骚操作

    C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  6. (转)如何用python抓取网页并提取数据

    最近一直在学这部分,今日发现一篇好文,虽然不详细,但是轮廓是出来了: 来自crifan:http://www.crifan.com/crawl_website_html_and_extract_inf ...

  7. Spring securiuty 过滤器

    1. HttpSessionContextIntegrationFilter 位于过滤器顶端,第一个起作用的过滤器. 用途一,在执行其他过滤器之前,率先判断用户的session中是否已经存在一个Sec ...

  8. css划斜线

    http://stackoverflow.com/questions/18012420/draw-diagonal-lines-in-div-background-with-css

  9. HDU 2554 N对数的排列问题 ( 数学 )

    题目链接 Problem Description 有N对双胞胎,他们的年龄分别是1,2,3,--,N岁,他们手拉手排成一队到野外去玩,要经过一根独木桥,为了安全起见,要求年龄大的和年龄小的排在一起,好 ...

  10. HDU 1798 Tell me the area (数学)

    题目链接 Problem Description     There are two circles in the plane (shown in the below picture), there ...