报错内容

  None of the configured nodes are available

elasticsearch.yml配置

  1. cluster.name: ftest
  2. node.name: node-72
  3. node.master: true
  4. node.data: true
  5. network.host: 112.122.245.212
  6. http.port: 39200
  7. transport.tcp.port: 39300
  8. discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
  9. discovery.zen.ping.unicast.hosts.resolve_timeout: 30s
  10. #index.codec: best_compression
  11. http.cors.allow-origin: "/.*/"
  12. http.cors.enabled: true
  13. path.repo: ["/home/xxx/backups"]

Java客户端配置

  1. import com.xxx.commons.log.BaseLogger;
  2. import com.xxx.data.elasticsearch.core.ElasticsearchTemplate;
  3. import java.net.InetAddress;
  4. import org.elasticsearch.client.Client;
  5. import org.elasticsearch.client.transport.TransportClient;
  6. import org.elasticsearch.common.settings.Settings;
  7. import org.elasticsearch.common.transport.InetSocketTransportAddress;
  8. import org.elasticsearch.common.transport.TransportAddress;
  9. import org.elasticsearch.transport.client.PreBuiltTransportClient;
  10. import org.springframework.beans.factory.annotation.Value;
  11. import org.springframework.context.annotation.Bean;
  12. import org.springframework.context.annotation.Configuration;
  13.  
  14. @Configuration
  15. public class ElasticsearchConfiguration extends BaseLogger {
  16. private static TransportClient transport = null;
  17. @Value("${elasticsearch.cluster.sniff:true}")
  18. private Boolean sniff;
  19. @Value("${elasticsearch.cluster.name:elasticsearch}")
  20. private String clusterName;
  21. @Value("${elasticsearch.cluster.hostname:localhost}")
  22. private String hostname;
  23. @Value("${elasticsearch.cluster.port:9300}")
  24. private int port;
  25.  
  26. public ElasticsearchConfiguration() {
  27. }
  28.  
  29. @Bean(
  30. name = {"elasticsearchTemplate"}
  31. )
  32. public ElasticsearchTemplate elasticsearchTemplate() {
  33. return new ElasticsearchTemplate(this.client());
  34. }
  35.  
  36. @Bean
  37. public Client client() {
  38. if (transport == null) {
  39. Settings settings = Settings.builder().put("client.transport.sniff", this.sniff).put("cluster.name", this.clusterName).build();
  40. this.logger.info("connection elasticserch info : hostname:{}, port: {}", this.hostname, this.port);
  41. transport = new PreBuiltTransportClient(settings, new Class[0]);
  42. String[] hostnames = this.hostname.split(",");
  43.  
  44. try {
  45. for(int i = 0; i < hostnames.length; ++i) {
  46. this.logger.info("链接es=======>:{}", hostnames[i]);
  47. TransportAddress transportAddress = new InetSocketTransportAddress(InetAddress.getByName(hostnames[i]), this.port);
  48. transport.addTransportAddresses(new TransportAddress[]{transportAddress});
  49. }
  50.  
  51. return transport;
  52. } catch (Exception var5) {
  53. this.logger.error("", var5);
  54. return null;
  55. }
  56. } else {
  57. return null;
  58. }
  59. }
  60. }

ES客户端属性配置

  1. <profile>
  2. <id>test-HA</id>
  3. <properties>
  4.  
  5. <!--系统配置-->
  6. <server.bind.host>0.0.0.0</server.bind.host>
  7. <server.bind.port>30030</server.bind.port>
  8.  
  9. <!--elasticsearch配置-->
  10. <elasticsearch.cluster.name>fans</elasticsearch.cluster.name>
  11. <elasticsearch.cluster.hostname>112.122.245.212</elasticsearch.cluster.hostname>
  12. <elasticsearch.cluster.port>39200</elasticsearch.cluster.port>
  13. </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. angularjs 监听 文档click 事件

    项目 上遇到  innHTML  放入 一大段的html 内容 中带有 click 事件 如onclick="callInMethod("http://www.crm.bmcc.c ...

  2. verilog-testbench 时钟和复位模板

    /********************************************* ** Clocks & Reset ******************************* ...

  3. Git 在webstrom上安装git

    Git下载地址:https://git-scm.com/download/win 用webstorm迁入迁出代码时,首先要先下载git,网址一搜就可以搜到,然后开始配置webstorm,打开webst ...

  4. MySQL外键使用详解

    一.基本概念 1.MySQL中“键”和“索引”的定义相同,所以外键和主键一样也是索引的一种.不同的是MySQL会自动为所有表的主键进行索引,但是外键字段必须由用户进行明确的索引.用于外键关系的字段必须 ...

  5. 左查询left join on简单总结

    应用场景分析:(个人观点,欢迎小祖宗们指正补充) 适合存在父子关系的单表,以及多表的查询   话不多说上代码 代码:mapper里的sql 表名字段什么的本来是单独集中配置的,现在还原到sql中了 & ...

  6. OrCAD Capture CIS 为库里的元器件添加新属性

    1.进入元器件编辑界面 2.菜单:Options > Part Properties... 3.在窗口User Properties中,点击按钮New... 4.在弹出的子窗口NewProper ...

  7. 启动tomcat出现内存溢出错误 java.lang.OutOfMemoryError: PermGen space

    三种因素引起: 1.jvm(jdk)的内存引起. 2. eclipse的内存引起. 3.tomcat的内存引起. 1.解决方法: 2.解决方法: 解决问题的方式就是:修改了安装目录eclipse.in ...

  8. 论文阅读笔记二十:LinkNet: Exploiting Encoder Representations for Efficient Semantic Segmentation(CVPR2017)

    源文网址:https://arxiv.org/abs/1707.03718 tensorflow代码:https://github.com/luofan18/linknet-tensorflow 基于 ...

  9. 读书笔记——《You Don't Know JS》

    第一部:<You don't know JS: this & Object prototype> 第三章 Object 对象常量 var myObject = {}; Object ...

  10. 饮冰三年-人工智能-linux-05 Linux进程

    1:top 命令,查看cpu使用情况.(由于top是实时刷新,占用内存比较大) P:按照cpu使用率降序排列 M:按照内存使用率降序排列 2:free 命令,查看内存使用情况 free -m 以M为单 ...