ElasticSearch 问题分析:No data nodes with HTTP-enabled available
环境:ES-5.4.0版本,部署方式:3master node+2client node+3data node
说明:data node和client node都配置了http.enabled: false,程序在写数据时报错:No data nodes with HTTP-enabled available
源码分析:
public static void filterNonDataNodesIfNeeded(Settings settings, Log log) {
if (!settings.getNodesDataOnly()) {
return;
} RestClient bootstrap = new RestClient(settings);
try {
String message = "No data nodes with HTTP-enabled available";
List<NodeInfo> dataNodes = bootstrap.getHttpDataNodes();
// 找不到dataNodes就会报错
if (dataNodes.isEmpty()) {
throw new EsHadoopIllegalArgumentException(message);
}
...
} finally {
bootstrap.close();
}
}
接下来看看RestClient.getHttpDataNodes()方法的取值逻辑
public List<NodeInfo> getHttpDataNodes() {
List<NodeInfo> nodes = getHttpNodes(false);
// 遍历上面获取到的节点
Iterator<NodeInfo> it = nodes.iterator();
while (it.hasNext()) {
NodeInfo node = it.next();
// 如果不是数据节点,则移除
if (!node.isData()) {
it.remove();
}
}
return nodes;
} // 获取http节点_nodes/http
public List<NodeInfo> getHttpNodes(boolean clientNodeOnly) {
// 通过es接口“_nodes/http”来获取nodes的信息
Map<String, Map<String, Object>> nodesData = get("_nodes/http", "nodes");
List<NodeInfo> nodes = new ArrayList<NodeInfo>(); for (Entry<String, Map<String, Object>> entry : nodesData.entrySet()) {
NodeInfo node = new NodeInfo(entry.getKey(), entry.getValue());
// 如果不是查找client节点,则只要节点运行网络访问就可以add了;如果查找client节点,则还要通过isClient验证才能add
if (node.hasHttp() && (!clientNodeOnly || node.isClient())) {
nodes.add(node);
}
}
return nodes;
}
最后再来看看node.hasHttp(),isClient(),isData()的方法
private final String id;
private final String name;
private final String host;
private final String ip;
private final String publishAddress;
private final boolean hasHttp;
private final boolean isClient;
private final boolean isData;
private final boolean isIngest; public NodeInfo(String id, Map<String, Object> map) {
this.id = id;
EsMajorVersion version = EsMajorVersion.parse((String) map.get("version"));
this.name = (String) map.get("name");
this.host = (String) map.get("host");
this.ip = (String) map.get("ip");
// 5.0以下版本的分支
if (version.before(EsMajorVersion.V_5_X)) {
Map<String, Object> attributes = (Map<String, Object>) map.get("attributes");
if (attributes == null) {
this.isClient = false;
this.isData = true;
} else {
String data = (String) attributes.get("data");
this.isClient = data == null ? true : !Boolean.parseBoolean(data);
this.isData = data == null ? true : Boolean.parseBoolean(data);
}
this.isIngest = false;
// 5.0版本以上的分支
} else {
List<String> roles = (List<String>) map.get("roles");
// 如果roles列表中不包含"data",则此节点是client
this.isClient = roles.contains("data") == false;
// 如果roles列表中包含"data",则此节点是data
this.isData = roles.contains("data");
// 如果roles列表中包含"ingest",则此节点是ingest
this.isIngest = roles.contains("ingest");
}
Map<String, Object> httpMap = (Map<String, Object>) map.get("http");
// 如果节点数据中包含key:http
if (httpMap != null) {
String addr = (String) httpMap.get("publish_address");
// 如果http数据中包含key:publish_address
if (addr != null) {
StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(addr);
this.publishAddress = ipAndPort.ip + ":" + ipAndPort.port;
// 则此节点可以提供http服务,即:http.enabled: true
this.hasHttp = true;
} else {
this.publishAddress = null;
this.hasHttp = false;
}
} else {
this.publishAddress = null;
this.hasHttp = false;
}
}
从上面的源码分析可以得出:如果一个data节点不配置http.enabled:true,则此节点不会被getHttpDataNodes()方法搜索到,那么就会直接抛出异常:No data nodes with HTTP-enabled available
解决的方法无非两种:
第一:数据节点配置 http.enabled:true
第二:绕过filterNonDataNodesIfNeeded()校验,需要settings.getNodesDataOnly()返回false;看下面源码可知,默认es.nodes.data.only是true,在客户端中将其设置为false即可。
/** Clients only */
String ES_NODES_CLIENT_ONLY = "es.nodes.client.only";
String ES_NODES_CLIENT_ONLY_DEFAULT = "false"; /** Data only */
String ES_NODES_DATA_ONLY = "es.nodes.data.only";
String ES_NODES_DATA_ONLY_DEFAULT = "true"; /** Ingest only */
String ES_NODES_INGEST_ONLY = "es.nodes.ingest.only";
String ES_NODES_INGEST_ONLY_DEFAULT = "false"; /** WAN only */
String ES_NODES_WAN_ONLY = "es.nodes.wan.only";
String ES_NODES_WAN_ONLY_DEFAULT = "false"; ... public boolean getNodesDataOnly() {
// by default, if not set, return a value compatible with the other settings
// 默认es.nodes.data.only是true,在客户端中将其设置为false即可
return Booleans.parseBoolean(getProperty(ES_NODES_DATA_ONLY), !getNodesWANOnly() && !getNodesClientOnly() && !getNodesIngestOnly());
} public boolean getNodesIngestOnly() {
return Booleans.parseBoolean(getProperty(ES_NODES_INGEST_ONLY, ES_NODES_INGEST_ONLY_DEFAULT));
} public boolean getNodesClientOnly() {
return Booleans.parseBoolean(getProperty(ES_NODES_CLIENT_ONLY, ES_NODES_CLIENT_ONLY_DEFAULT));
} public boolean getNodesWANOnly() {
return Booleans.parseBoolean(getProperty(ES_NODES_WAN_ONLY, ES_NODES_WAN_ONLY_DEFAULT));
}
最后附上一段"_nodes/http"接口的返回值:
"nodes": {
"YgwRm4j1RwiK3jjDHY8Hzw": {
"name": "node-02",
"transport_address": "192.168.100.10:9300",
"host": "192.168.100.10",
"ip": "192.168.100.10",
"version": "5.4.0",
"build_hash": "780f8c4",
"roles": [
"master",
"ingest"
],
"attributes": {
"ml.enabled": "true"
},
"http": {
"bound_address": [
"192.168.100.10:9200"
],
"publish_address": "192.168.100.10:9200",
"max_content_length_in_bytes": 104857600
}
}
...
}
ElasticSearch 问题分析:No data nodes with HTTP-enabled available的更多相关文章
- Elasticsearch提示low disk watermark [85%] exceeded on [UTyrLH40Q9uIzHzX-yMFXg][Sonofelice][/Users/baidu/Documents/work/soft/data/nodes/0] free: 15.2gb[13.4%], replicas will not be assigned to this node
mac本地启动es之后发现运行一段时间一分钟就能打印好几条info日志: [--13T10::,][INFO ][o.e.c.r.a.DiskThresholdMonitor] [Sonofelice ...
- ElasticSearch评分分析 explian 解释和一些查询理解
ElasticSearch评分分析 explian 解释和一些查询理解 按照es-ik分析器安装了ik分词器.创建索引:PUT /index_ik_test.索引包含2个字段:content和nick ...
- Elasticsearch日志分析系统
Elasticsearch日志分析系统 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.什么是Elasticsearch 一个采用Restful API标准的高扩展性的和高可用性 ...
- 图解Janusgraph系列-图数据底层序列化源码分析(Data Serialize)
图解Janusgraph系列-图数据底层序列化源码分析(Data Serialize) 大家好,我是洋仔,JanusGraph图解系列文章,实时更新~ 图数据库文章总目录: 整理所有图相关文章,请移步 ...
- Change the default MySQL data directory with SELinux enabled
转载:https://rmohan.com/?p=4605 Change the default MySQL data directory with SELinux enabled This is a ...
- Elasticsearch 技术分析(九):Elasticsearch的使用和原理总结
前言 之前已经分享过Elasticsearch的使用和原理的知识,由于近期在公司内部做了一次内部分享,所以本篇主要是基于之前的博文的一个总结,希望通过这篇文章能让读者大致了解Elasticsearch ...
- org.elasticsearch.transport.ReceiveTimeoutTransportException[cluster:monitor/nodes/liveness] request_id [31] timed out after [5000ms]
ES连接超时,异常信息 2017-09-07 10:42:45.042 [elasticsearch[Bantam][transport_client_worker][T#17]{New I/O wo ...
- elasticsearch之hello(spring data整合)
1.书写pom.xml文件 <dependencies> <dependency> <groupId>org.springframework.data</gr ...
- ElasticSearch聚合分析
聚合用于分析查询结果集的统计指标,我们以观看日志分析为例,介绍各种常用的ElasticSearch聚合操作. 目录: 查询用户观看视频数和观看时长 聚合分页器 查询视频uv 单个视频uv 批量查询视频 ...
随机推荐
- [C#]安装WindowsService的关键步骤
使用.Net编写好了WindowsService以后,不安装到系统里就没有任何作用. [添加Installer] 在服务的设计器画面,属性页面里,选择[Add Installer]链接. 如此便会生成 ...
- GlusterFS 一
GlusterFS 一 1 安装源 yum install centos-release-gluster312.noarch 列出所有可用安装包yum list gluster* 安装glusterf ...
- IPA文件的自动化生成和无线分发
1. IPA的无线分发 iOS应用开发测试过程中,通过无线网络进行IPA包的分发将是非常便捷的,于是也就有了类似testflightapp之类的平台.对于这一功能,我们也可以自己实现,只需要一个简单的 ...
- 自定义Team Foundation Server (TFS) 与Project Professional的集成字段
用户可以象使用Office Excel一样,使用Project Professional连接TFS,将数据下载到本地修改,并且发布到TFS服务器上,如果你习惯使用Project来计划你的项目,那么Pr ...
- 查看jar包的jdk版本并降级
用解压工具打开jar包(例子都是用7zip) 进入到META-INF目录,查看MANIFEST.MF文件,查看Bulid-Jdk,下图就为1.7.0_55版本的JDK,这就表示jetty-serv ...
- bootstrap-table简单使用
开发项目时总想着能不能有一款插件包含分页,查询等常用功能,后来发现了bootstrap-table 直接看代码和效果图 <!DOCTYPE html> <html lang=&quo ...
- shell相关文件
站在用户登录的角度来说,SHELL的类型: 登录式shell: 正常通常某终端登录 su - USERNAME su -l USERNAME 非登录式shell: su USERNAME 图形终端下 ...
- org.springframework.dao.CannotAcquireLockException解决
java.sql.SQLException: Lock wait timeout exceeded 该异常为一个service中调用了另一个service,两个service对同一表进行操作,造成事务 ...
- 遇到问题-----cas4.2.x登录成功后报错No principal was found---cas中文乱码问题完美解决
情况 我们之前已经完成了cas4.2.x登录使用MongoDB验证方式并且自定义了加密. 单点登录(十五)-----实战-----cas4.2.x登录mongodb验证方式实现自定义加密 但是悲剧的是 ...
- django系列1--介绍与简单原理, wsgiref模块
一.web应用框架 Web应用框架(Web application framework)是一种计算机软件框架,用来支持动态网站.网络应用程序及网络服务的开发.这种框架有助于减轻网页开发时共通性活动的工 ...