异常org.elasticsearch.client.transport.NoNodeAvailableException

http://localhost:9200/_cluster/health/ 查看一下:

{"cluster_name":"elasticsearch","status":"green","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0}

本菜鸟我第一次接触elasticsearch,一开始就碰到了No node available,诶,真的是菜鸟啊,用别人的例子照着做都不能跑出来,

现在依稀还记得这个问题是怎么解决的,记录下来吧

 org.elasticsearch.client.transport.NoNodeAvailableException: No node available

可能是以下几种错

1 端口错

client = new TransportClient().addTransportAddress(new InetSocketTransportAddress(ipAddress, 9300));

这里9300 写成9200的话会No node available

要是你连的不是本机,注意IP有没有正确

2 jar报引用版本不匹配,开启的服务是什么版本,引用的jar最好匹配(这个我没有去试,反正我的是匹配的)

3 要是你改了集群名字,还有设置集群名字

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "xxx").build();
            client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(ipAddress, 9300));

本人的问题是:jar包版本不正确,将项目的elasticsearch版本和部署服务器的jar包版本换成一致即可。


你可能感兴趣的:(elasticsearch)