Springboot集成ES启动报错
报错内容
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());}@Beanpublic 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连接异常原因
转载于:https://www.cnblogs.com/hujunzheng/p/9948243.html
Springboot集成ES启动报错相关推荐
- SpringBoot集成Redis 启动报错
SpringBoot启动报错:Field redisTemplate in com.test.redis.controller.TestController required a bean of ty ...
- springboot整合es启动报错的问题
今天打算用springboot整合es创建一个索引并往索引里面写数据的时候,项目启动的时候一直报下面的这个错误,错误大概如下, Caused by: org.springframework.beans ...
- es启动报错:could not find java in JAVA_HOME at /elk/es/elasticsearch-7.11.1/jdk/bin/java
es启动报错 错误排查 检查java环境变量是否配置 es启动要使用非root账户 es账户是否授权 如图:我的es账户未授权 通过执行命令解决: chown -R elk:elk /elk/* do ...
- 【已解决】Springboot服务 Netty启动报错Failed to submit a listener
[已解决]Springboot服务 Netty启动报错Failed to submit a listener Force-closing a channel whose registration ta ...
- ES启动报错error downloading geoip database [GeoLite2-ASN.mmdb]
elasticsearch "8.5.3"版本启动报错[o.e.i.g.GeoIpDownloader ] [localhost.localdomain] error downlo ...
- SpringBoot整合minio启动报错无法访问okhttp3.HttpUrl
问题: 项目启动报错: 无法访问okhttp3.HttpUrl 找不到okhttp3.HttpUrl的类文件 原因我猜应该是docekr pull下来的minio版本高了.因为几个月前我搞的时候还没有 ...
- Idea springboot应用,启动报错:org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputExcept
问题原因: application.yml 文件编写错误,一般情况在于空格多或者少的原因,检查下空格 application.yml 编码发生了改变,GBK和UTF-8两种编码格式的问题 解决: 最快 ...
- ES启动报错 :could not fidn java; set JAVA_HOME or ensure java is in PATH
环境 : Ubuntu 16.04 ES软件包 : tar.gz 1.报错信息 :could not fidn java; set JAVA_HOME or ensure java is in PAT ...
- SpringBoot多Module启动报错Could not transfer metadata
报错: [WARNING] Could not transfer metadata com.vipcode:zzj-test-common:1.0-SNAPSHOT/maven-metadata.xm ...
最新文章
- call和apply和bind的区别
- 使用JDK 8流在包装对象的集合和包装对象的集合之间转换
- python有什么内容_python能做什么
- mysql 以周为单位记录数据_mysql 按月/按周汇总统计函数 DATE_FORMAT() 函数
- python 当前时间的前一天_Python与Stata的数据交互
- 设计模式(十)—— 装饰者模式
- 工程项目利用AutoMake生成Makefile实战
- AI电话机器人源码买断 后私有云部署如何上线?
- 老男孩python怎么样_老男孩Python为什么这么受关注?老男孩到底怎么样?
- Qt播放常见视频格式的方法
- 【ENVI】监督分类
- 使用Spring Boot开发财务系统视频
- xlrd.biffh.XLRDError: Excel xlsx file; not supported 。我也来蹭一下热度~
- Linux上类似vbs脚本,VBS脚本常用经典代码收集
- 淘宝展示广告中的优化点击成本算法
- GEA 4.5比较各种旋转表达方式
- Java实现第九届蓝桥杯快速排序
- JAVA Helloworld以及JAVA标识符命名规范
- ironpython3_(最简单详细)IronPython下载、安装及简单使用
- 與网络故障专家的對話
热门文章
- lol模型导入ue4_Houdini amp; UE4 程序化建模——石头(一)基础工作流
- hive sql练习_经典的SparkSQL/Hive-SQL/MySQL面试-练习题
- spring5.x cxf3.4.x 服务端和客户端 非maven版本
- Java-分析类初始化
- .iml文件_jetbrains误删maven 项目.iml文件后的处理方法
- 如何查看一个组件的 classid是多少_如何查看iphone电池使用次数?6s电池容量多少需要更换?...
- 奖学金c语言程序,奖学金 (C语言代码)
- BugkuCTF-PWN题pwn2-overflow超详细讲解
- python金融数据怎么获取_class类怎样在python中获取金融数据?
- 华硕服务器主板型号命名规则,常见主板命名规则