Elasticsearch常见错误及解决方法

news/2025/1/10 22:37:20/

Elasticsearch常见错误及解决方法:

1、启动时候报错Caused by: java.net.BindException: Cannot assign requested address
解决方法:打开配置文件elasticsearch.yml 将 network.host: 192.168.0.1 修改为本机IP 0.0.0.0

[2020-04-03T19:41:11,382][INFO ][o.e.n.Node               ] [txvm2019] starting ...
[2020-04-03T19:41:11,649][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [txvm2019] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9300-9400]]; nested: BindException[Cannot assign requested address];at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.2.0.jar:7.2.0]at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.2.0.jar:7.2.0]
Caused by: org.elasticsearch.transport.BindTransportException: Failed to bind to [9300-9400]at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:389) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:355) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:136) ~[?:?]at org.elasticsearch.xpack.core.security.transport.netty4.SecurityNetty4Transport.doStart(SecurityNetty4Transport.java:81) ~[?:?]at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4ServerTransport.doStart(SecurityNetty4ServerTransport.java:43) ~[?:?]at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:59) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.transport.TransportService.doStart(TransportService.java:230) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:59) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.node.Node.start(Node.java:662) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:273) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:358) ~[elasticsearch-7.2.0.jar:7.2.0]at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.2.0.jar:7.2.0]... 6 more
Caused by: java.net.BindException: Cannot assign requested addressat sun.nio.ch.Net.bind0(Native Method) ~[?:?]at sun.nio.ch.Net.bind(Net.java:433) ~[?:?]at sun.nio.ch.Net.bind(Net.java:425) ~[?:?]at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[?:?]at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:132) ~[?:?]at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:563) ~[?:?]at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1332) ~[?:?]at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:503) ~[?:?]at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:488) ~[?:?]at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:984) ~[?:?]at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:259) ~[?:?]at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) ~[?:?]at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[?:?]at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) ~[?:?]at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[?:?]at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) ~[?:?]at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[?:?]at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

2、错误:max number of threads [2048] for user [elasticsearch] is too low, increase to at least [4096]
解决方法:编辑 /etc/security/limits.conf,追加以下内容;
 soft nofile 65536
 hard nofile 65536

[2020-04-03T19:46:34,046][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [txvm2019] [controller/27023] [Main.cc@110] controller (64 bit): Version 7.2.0 (Build 65aefcbfce449b) Copyright (c) 2019 Elasticsearch BV
[2020-04-03T19:46:34,526][DEBUG][o.e.a.ActionModule       ] [txvm2019] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-04-03T19:46:34,867][INFO ][o.e.d.DiscoveryModule    ] [txvm2019] using discovery type [zen] and seed hosts providers [settings]
[2020-04-03T19:46:35,768][INFO ][o.e.n.Node               ] [txvm2019] initialized
[2020-04-03T19:46:35,768][INFO ][o.e.n.Node               ] [txvm2019] starting ...
[2020-04-03T19:46:35,923][INFO ][o.e.t.TransportService   ] [txvm2019] publish_address {172.17.0.1:9300}, bound_addresses {0.0.0.0:9300}
[2020-04-03T19:46:35,932][INFO ][o.e.b.BootstrapChecks    ] [txvm2019] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max number of threads [2048] for user [elasticsearch] is too low, increase to at least [4096]
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2020-04-03T19:46:35,978][INFO ][o.e.n.Node               ] [txvm2019] stopping ...
[2020-04-03T19:46:36,012][INFO ][o.e.n.Node               ] [txvm2019] stopped
[2020-04-03T19:46:36,012][INFO ][o.e.n.Node               ] [txvm2019] closing ...
[2020-04-03T19:46:36,032][INFO ][o.e.n.Node               ] [txvm2019] closed

 

3、错误cluster.initial_master_nodes] must be configured
解决方法:
在elasticsearch的config目录下,修改elasticsearch.yml配置文件,将下面的配置加入到该配置文件中:

ip替换host1等,多节点请添加多个ip地址,单节点可写按默认来
#配置以下三者,最少其一
#[discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes]
cluster.initial_master_nodes: ["node-1"] #这里的node-1为node-name配置的值

[2020-04-03T19:51:41,427][DEBUG][o.e.a.ActionModule       ] [txvm2019] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-04-03T19:51:41,799][INFO ][o.e.d.DiscoveryModule    ] [txvm2019] using discovery type [zen] and seed hosts providers [settings]
[2020-04-03T19:51:42,729][INFO ][o.e.n.Node               ] [txvm2019] initialized
[2020-04-03T19:51:42,729][INFO ][o.e.n.Node               ] [txvm2019] starting ...
[2020-04-03T19:51:42,890][INFO ][o.e.t.TransportService   ] [txvm2019] publish_address {172.17.0.1:9300}, bound_addresses {0.0.0.0:9300}
[2020-04-03T19:51:42,900][INFO ][o.e.b.BootstrapChecks    ] [txvm2019] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

 

4、删除数据时错误:"reason":"Wildcard expressions or all indices are not allowed"
解决方法:
删除所有索引时
curl -X DELETE "http://localhost:9200/*"
或者
curl -X DELETE "localhost:9200/_all"
为了防止误删除,
可以设置 elasticsearch.yml属性 action.destructive_requires_name为true,
禁止使用通配符或_all删除索引,
必须使用名称或别名才能删除该索引。
修改为false即可删除所有
action.destructive_requires_name: false

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Wildcard expressions or all indices are not allowed"}],"type":"illegal_argument_exception","reason":"Wildcard expressions or all indices are not allowed"},"status":400}

5、创建索引错误:The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true.
解决方法:

修改为:

{"settings": {"number_of_shards": 3,"number_of_replicas": 2},"mappings": {"properties": {"commodity_id": {"type": "long"},"commodity_name": {"type": "text"},"picture_url": {"type": "text"},"price": {"type": "double"}}}
}

出现这个的原因是,elasticsearch7默认不在支持指定索引类型,默认索引类型是_doc,如果想改变,则配置include_type_name: true 即可(这个没有测试,官方文档说的,无论是否可行,建议不要这么做,因为elasticsearch8后就不在提供该字段)。

{"error":    {"root_cause": [      {"type": "illegal_argument_exception","reason": "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."}],"type": "illegal_argument_exception","reason": "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."},"status": 400
}

 

6、聚合查询时错误:"Fielddata is disabled on text fields by default. ...."
解决方法:
经过查找验证后发现出现该错误是因为5.x之后,Elasticsearch对排序、聚合所依据的字段用单独的数据结构(fielddata)缓存到内存里了,但是在text字段上默认是禁用的,这样做的目的是为了节省内存空间。所以如果需要进行聚合操作,需要单独开启。执行以下代码(city为相关text的字段名称):

PUT myindex/_mapping
{"properties": {"city": { "type":     "text","fielddata": true}}
}
"caused_by": {"type": "illegal_argument_exception","reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.","caused_by": {"type": "illegal_argument_exception","reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [city] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}
}

 


 


http://www.ppmy.cn/news/246567.html

相关文章

Typora、Markdown中的公式,颜色汇总

文章目录 前言表情符号人物自然物体地点符号 数学符号上标下标开方分数向量上下水平线上下水平大括号累加累乘极限积分加减乘除矩阵与行列式不带括号的矩阵:带括号{}的矩阵带括号[]的矩阵带括号()的矩阵不使用left和right关键词带省略号的矩阵带参数的矩阵行列式 特…

实战:如何设计一个高性能网关

你知道的越多,不知道的就越多,业余的像一棵小草! 你来,我们一起精进!你不来,我和你的竞争对手一起精进! 编辑:业余草 cnblogs.com/2YSP/p/14223892.html 推荐:https://ww…

NLP自然语言处理系列- week6-文本生成案例(2)(Encoder)

NLP自然语言处理系列- week6-文本生成案例(2)(Encoder) 目录 Seq2seq+Attention 架构图编码器嵌入层EmbeddingLSTM 层RNNBase类Seq2seq+Attention 架构图 本文实现编码器部分 编码器

LapStyle - 基于拉普拉斯金字塔的高质量风格化方法 | CVPR2021

点击上方“计算机视觉工坊”,选择“星标” 干货第一时间送达来源丨https://zhuanlan.zhihu.com/p/384504389 编辑丨AI算法与图像处理这篇专栏主要介绍我们团队(百度视觉技术部视频理解与编辑组)发表于CVPR 2021上的工作:”Draftin…

【FFmpeg】ffmpeg 命令查询二 ( 比特流过滤器 | 可用协议 | 过滤器 | 像素格式 | 标准声道布局 | 音频采样格式 | 颜色名称 )

FFmpeg 系列文章目录 【FFmpeg】Windows 搭建 FFmpeg 命令行运行环境 【FFmpeg】FFmpeg 相关术语简介 ( 容器 | 媒体流 | 数据帧 | 数据包 | 编解码器 | 复用 | 解复用 ) 【FFmpeg】FFmpeg 相关术语简介 二 【FFmpeg】FFmpeg 帮助文档使用 【FFmpeg】使用 FFmpeg 处理音视频…

情人节礼物 浪漫至死不渝

文章目录 一、爱心表白二、愿望清单三、礼物四、文案我想跟你一起生活,在某个小镇,共享无尽的黄昏,和绵绵不绝的钟声。 爱意东升西落,浪漫至死不渝。 以此文表达对 CSDN 征文活动的支持。生活需要一些仪式感,浪漫至死不渝。 一、爱心表白 MATLAB绘制 3D 爱心: clear; …

数学建模之差分方程模型详解

码字总结不易,老铁们来个三连:点赞、关注、评论 作者:[左手の明天] 原创不易,转载请联系作者并注明出处 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本…

五种编程语言解释数据结构与算法——顺序表1(理论与C语言实现)

1、线性表的分类 2、线性表的定义及其基本操作 2.1、定义:线性表是具有相同类型的n(n>0)个元素的有序序列,其中n为表长,当n0时,该表为空表。 2.3、线性表的逻辑结构为: 2.4、线性表的特点: 表中的元素…