成功解决:Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but

简介: 这篇文章讨论了在使用Docker启动Elasticsearch容器时遇到的一个具体问题:由于配置文件`elasticsearch.yml`解析出错导致容器启动失败。文章提供了详细的排查过程,包括查看容器的日志信息、检查并修正配置文件中的错误(特别是空格问题),并最终成功重新启动了容器。

前言

在根据镜像elasticsearch创建容器的时候,启动容器失败。

查看报错日志

查看日志
这里查看相关容器启动失败日志

docker logs e09

在这里插入图片描述

[root@localhost elasticsearch]# docker logs e09
Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1189)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1160)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:75)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:82)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
    at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:95)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
    at org.elasticsearch.cli.Command.main(Command.java:77)
    at org.elasticsearch.common.settings.KeyStoreCli.main(KeyStoreCli.java:33)
Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]
    at org.elasticsearch.common.xcontent.XContentParserUtils.parsingException(XContentParserUtils.java:77)
    at org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken(XContentParserUtils.java:70)
    at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:672)
    at org.elasticsearch.common.settings.Settings.access$400(Settings.java:75)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1185)
    ... 10 more
Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1189)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1160)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:75)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:82)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
    at org.elasticsearch.cli.Command.main(Command.java:77)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]
    at org.elasticsearch.common.xcontent.XContentParserUtils.parsingException(XContentParserUtils.java:77)
    at org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken(XContentParserUtils.java:70)
    at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:672)
    at org.elasticsearch.common.settings.Settings.access$400(Settings.java:75)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1185)
    ... 9 more

排查问题

是说在启动时在解析elasticsearch.yml出现错误,查看自己外部挂载的elasticsearch.yml配置文件(如没有挂载配置文件,则需去容器内查找)

/mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/dada:/usr/share/elasticsearch/dada \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.17.2

解决方法

修改 elasticsearch.yml中的配置。空格要特别注意

在这里插入图片描述

在这里插入图片描述

启动成功

重新启动容器

docker start e09e7a49ae97

在这里插入图片描述

资料参考:原因+解决方法

相关实践学习
以电商场景为例搭建AI语义搜索应用
本实验旨在通过阿里云Elasticsearch结合阿里云搜索开发工作台AI模型服务,构建一个高效、精准的语义搜索系统,模拟电商场景,深入理解AI搜索技术原理并掌握其实现过程。
ElasticSearch 最新快速入门教程
本课程由千锋教育提供。全文搜索的需求非常大。而开源的解决办法Elasricsearch(Elastic)就是一个非常好的工具。目前是全文搜索引擎的首选。本系列教程由浅入深讲解了在CentOS7系统下如何搭建ElasticSearch,如何使用Kibana实现各种方式的搜索并详细分析了搜索的原理,最后讲解了在Java应用中如何集成ElasticSearch并实现搜索。  
相关文章
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
1109 0
|
Python
通过 type 和 object 之间的关联,进一步分析类型对象
通过 type 和 object 之间的关联,进一步分析类型对象
410 3
|
JSON 数据格式 Python
【python】解决json.dump(字典)时报错Object of type ‘float32‘ is not JSON serializable
在使用json.dump时遇到的“Object of type ‘float32’ is not JSON serializable”错误的方法,通过自定义一个JSON编码器类来处理NumPy类型的数据。
1154 1
|
XML 缓存 API
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
290 0
|
JSON 前端开发 数据格式
【Python】已解决:TypeError: Object of type JpegImageFile is not JSON serializable
【Python】已解决:TypeError: Object of type JpegImageFile is not JSON serializable
717 0
R语言ggsurvplot绘制生存曲线报错 : object of type ‘symbol‘ is not subsettab
R语言ggsurvplot绘制生存曲线报错 : object of type ‘symbol‘ is not subsettab
报错modify sync object Modify sync object Failed!
报错modify sync object Modify sync object Failed!
228 1
FeignClient【问题】Cannot deserialize value of type``from Object value (token `JsonToken.START_OBJECT`)
FeignClient【问题】Cannot deserialize value of type``from Object value (token `JsonToken.START_OBJECT`)
1786 0
|
JavaScript
[Vue warn]: Method “components“ has type “object“ in the component definition. Did you reference the
[Vue warn]: Method “components“ has type “object“ in the component definition. Did you reference the
|
JavaScript
[Vue warn]: Method “components“ has type “object“ in the component definition. Did you reference the
[Vue warn]: Method “components” has type “object” in the component definition. Did you reference the
[Vue warn]: Method “components“ has type “object“ in the component definition. Did you reference the

热门文章

最新文章