报错内容

  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 中启用 HTTP 响应压缩

    Confluence 能够支持 HTTP 的 GZip 传输编码.这个意味着 Confluence 将可以把数据压缩后传输给用户,这种配置能够针对不稳定的互联网状态下的传输速度缓慢和不稳定并且能够降低 ...

  2. Confluence 6 指定日志选项和已知问题

    指定 Confluence 日志选项 这里是一些特定的日志配置,你可能在对问题进行调试的时候需要. 在日志中记录数据库使用的 SQL 查询请求 你可能希望增加日志的中的内容,记录 Confluence ...

  3. Confluence 6 查看站点状态

    请注意,有关站点的活动信息在默认情况下是禁用的.请查看下面的说明. 如果这个插件被启用的话,有关站点的全局活动状态将会在你的 Confluence 站点中显示出来.显示的数据包括: 在给定的时间内有多 ...

  4. Vuejs的一些总结

    http://blog.csdn.net/xllily_11/article/details/52312044 原文链接:http://mrzhang123.github.io/2016/07/14/ ...

  5. 【shell】两种字符串提取场景的实现

    shell虽然比batch顺眼点儿,但还是老话,入门容易,精通难. 1.场景一是这样的,现有字符串的内容 name: tiger; age:18; location:china; 需求:提取每个属性的 ...

  6. Android 基础 一 AndroidManifest.xml

    一.概述 AndroidManifest.xml是Android应用的入口文件,它描述了package中暴露的组件(activities, services, 等等),他们各自的实现类,各种能被处理的 ...

  7. 中介模型以及优化查询以及CBV模式

    一.中介模型:多对多添加的时候用到中介模型 自己创建的第三张表就属于是中介模型 class Article(models.Model): ''' 文章表 ''' title = models.Char ...

  8. 最小标示法模板 poj1509

    最小标示法:给定一个字符串,不断将其最后一个字符放到开头,最终会得到n个字符串,称这n个字符串循环同构,这些字符串中字典序最小的一个,就是最小表示法 #include<iostream> ...

  9. Linux基础三:linux目录结构和目录文件的浏览、管理及维护

    目录文件的浏览.管理及维护(一) 1.Linux文件系统的层次结构 1)Linux文件系统的树状结构:在Linux或UNIX操作系统中,所有的文件和目录都被组织成一个以根节点开始的倒置的树状结构. 2 ...

  10. asp.net core 缓存和Session

    缓存 缓存在内存中 ASP.NET Core 使用 IMemoryCache内存中缓存是使用依赖关系注入从应用中引用的服务. 请在ConfigureServices中调用AddMemoryCache( ...