报错内容

  None of the configured nodes are available

elasticsearch.yml配置

cluster.name: ftest
node.name: node-72
node.master: true
node.data: true
network.host: 112.122.245.212
http.port: 39200
transport.tcp.port: 39300
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
discovery.zen.ping.unicast.hosts.resolve_timeout: 30s
#index.codec: best_compression
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
path.repo: ["/home/xxx/backups"]

Java客户端配置

import com.xxx.commons.log.BaseLogger;
import com.xxx.data.elasticsearch.core.ElasticsearchTemplate;
import java.net.InetAddress;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; @Configuration
public class ElasticsearchConfiguration extends BaseLogger {
private static TransportClient transport = null;
@Value("${elasticsearch.cluster.sniff:true}")
private Boolean sniff;
@Value("${elasticsearch.cluster.name:elasticsearch}")
private String clusterName;
@Value("${elasticsearch.cluster.hostname:localhost}")
private String hostname;
@Value("${elasticsearch.cluster.port:9300}")
private int port; public ElasticsearchConfiguration() {
} @Bean(
name = {"elasticsearchTemplate"}
)
public ElasticsearchTemplate elasticsearchTemplate() {
return new ElasticsearchTemplate(this.client());
} @Bean
public Client client() {
if (transport == null) {
Settings settings = Settings.builder().put("client.transport.sniff", this.sniff).put("cluster.name", this.clusterName).build();
this.logger.info("connection elasticserch info : hostname:{}, port: {}", this.hostname, this.port);
transport = new PreBuiltTransportClient(settings, new Class[0]);
String[] hostnames = this.hostname.split(","); try {
for(int i = 0; i < hostnames.length; ++i) {
this.logger.info("链接es=======>:{}", hostnames[i]);
TransportAddress transportAddress = new InetSocketTransportAddress(InetAddress.getByName(hostnames[i]), this.port);
transport.addTransportAddresses(new TransportAddress[]{transportAddress});
} return transport;
} catch (Exception var5) {
this.logger.error("", var5);
return null;
}
} else {
return null;
}
}
}

ES客户端属性配置

<profile>
<id>test-HA</id>
<properties> <!--系统配置-->
<server.bind.host>0.0.0.0</server.bind.host>
<server.bind.port>30030</server.bind.port> <!--elasticsearch配置-->
<elasticsearch.cluster.name>fans</elasticsearch.cluster.name>
<elasticsearch.cluster.hostname>112.122.245.212</elasticsearch.cluster.hostname>
<elasticsearch.cluster.port>39200</elasticsearch.cluster.port>
</profile>

问题追踪

在异常栈中定位到 org.elasticsearch.client.transport.TransportClientNodesService#ensureNodesAreAvailable

继续找到 org.elasticsearch.client.transport.TransportClientNodesService#execute

this.nodes变量的添加逻辑是在 org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler#doSample

this.nodes变量保存了可用的ES连接节点信息,从上图可以看出,ReceiveTimeoutTransportException。很明显,连接超时了。

直接访问es ip+端口可以获得如下信息。

按理配置是没有问题的。后来突然意识到 “transport” 这个关键字,然后发觉端口配置错误了。

 

总结一下es连接异常原因

    1、es服务端没有启动
    2、cluster.name 不匹配
    3、端口写错,java客户端要配置 transport.tcp.port: 39300。
     以上3条逐个排查,多半问题就解决了。

Springboot集成ES启动报错的更多相关文章

  1. SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required

    Spring Boot发布war包流程: 1.修改web model的pom.xml <packaging>war</packaging> SpringBoot默认发布的都是j ...

  2. SpringBoot整合nacos启动报错:java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata

    报错信息 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nacosCo ...

  3. springboot多数据源启动报错:required a single bean, but 6 were found:

    技术群: 816227112 参考:https://stackoverflow.com/questions/43455869/could-not-autowire-there-is-more-than ...

  4. SpringBoot项目集成Swagger启动报错: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is

    使用的Swagger版本是2.9.2.knife4j版本是2.0.4. SpringBoot 版本是2.6.2将SpringBoot版本回退到2.5.6就可以正常启动

  5. SpringBoot学习之启动报错【This application has no explicit mapping for /error.....】

    今天做SpringBoot小例子,在请求controller层的时候出现如下问题. Whitelabel Error Page This application has no explicit map ...

  6. springboot放到linux启动报错:The temporary upload location [/tmp/tomcat.8524616412347407692.8111/work/Tomcat/localhost/ROOT/asset] is not valid

    1.背景 笔者的springboot在一个非root用户环境下运行,这种环境下可以保证不被潜在的jar/开源框架漏洞提权. 比如在防火墙上把外网访问来的443端口映射到本地8443的java web端 ...

  7. SpringBoot整合Elasticsearch启动报错处理 nested exception is java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8]

    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wit ...

  8. ES启动报错之引导检测失败

    [--16T18::,][ERROR][o.e.b.Bootstrap ] [node-] node validation exception [] bootstrap checks failed [ ...

  9. ES启动报错最大进程数太少

    [--16T18::,][INFO ][o.e.b.BootstrapChecks ] [node-] bound or publishing to a non-loopback address, e ...

随机推荐

  1. Confluence 6 的 WebDAV 客户端整合介绍

    WebDAV 允许用户通过一个 WebDAV 客户端来访问 Confluence.例如,微软 Windows 的 'My Network Places'.通过为访问的用户提供权限,这个用户可以在 Co ...

  2. Confluence 6 从关闭的连接中恢复

    当数据库服务器进行重启或者因为网络问题导致连接中断.所有在数据库连接池中的连接都会被中断.希望处理这个问题,通常需要 Confluence 进行重启. 但是,数据库连接池中的连接可以通过运行 SQL ...

  3. GitHub搭配使用Travis CI 进行自动构建服务

    Travis CI (Continuous Integration)持续集成服务 用处:自动监控软件仓库,可以在代码提交后立刻执行自动测试或构建 1.在Github自己的仓库根目录里添加.travis ...

  4. 第四周学习总结-HTML

    2018年8月5日 这是暑假第四周,这一周我在菜鸟教程网学到了许多HTML的知识.HTML编写网页不像C语言.Java语言那必须有主方法.主函数什么的,它基本上都是标签(元素),但是它可以与CSS(层 ...

  5. jmeter IP欺骗功能

    使用过loadrunner的同学,应该都了解有个IP欺骗功能,jmeter遇到类似需求怎样实现呢? 环境:windows7,jdk1.8,jmeter3.1 使用IP欺骗功能前提是本地有多个可用IP, ...

  6. Jenkins构建后发送邮件

    我们首先安装Jenkins邮件扩展插件“ Email Extension Plugin ”. Jenkins和插件的安装方法见上一篇文章:http://qicheng0211.blog.51cto.c ...

  7. 出现xml错误的时候都是配置文件的名字没有改造成的

    The error may exist in com/bjpowernode/dao/PlayerDao.xml

  8. Php7有哪些新特性:

    PHP7在PHP5的基础上又做了一次质的提升,当然改变很多,我这里以我的总结简单说下,主要发生了下面这些更改: 移除了一些旧的特性 ZEND引擎升级到Zend Engine 3,也就是所谓的PHP N ...

  9. Ansible playbook 部署filebeat

    - hosts: all tasks: - name: Copy Package copy: src=/usr/local/filebeat--linux-x86_64.tar.gz dest=/us ...

  10. Android 实现连续两次点击或连续多次点击退出应用

    前言:  日常开发过程中,经常会遇到“连续点击两次退出应用”的需求(和“连续点击多次”的需求(如:手机从设置中进入开发者选项). 直接上代码:双击退出: private long exitTime = ...