Elasticsearch 常见的 8 种错误及最佳实践

题记

Elasticsearch 社区有大量关于 Elasticsearch 错误和异常的问题。

深挖这些错误背后的原因,把常见的错误积累为自己的实战经验甚至是工具,不仅可以节省我们的开发和运维时间,而且可以帮助确保 Elasticsearch 集群的长期健康运行。

常见的异常、原因和常规最佳实践拆解如下,这些最佳实践可以帮助我们更有效地识别、最小化定位和处理异常问题。

1、 Mapper_parsing_exception

Elasticsearch 依靠映射(Mapping)定义的数据类型处理数据。

映射定义了文档中的字段并指定了它们对应的数据类型,例如日期类型 Date、长整数类型 long 和  字符串类型 text。

如果索引文档包含没有定义数据类型的新字段,Elasticsearch将使用动态映射来估计字段的类型,并在必要时将其从一种类型转换为另一种类型。

如果Elasticsearch无法执行此转换,它将引发“ mapper_parsing_exception无法解析” 异常。

如果此类异常太多会降低索引吞吐量。

实战举例如下:

DELETE mytest_0001
PUT mytest_0001/_doc/1
{
  "name":"John"
}

PUT mytest_0001/_doc/2
{
  "name": {
    "firstname": "John",
    "lastname": "doe"
  }
}

为避免此问题,可以在创建索引时显示定义Mapping,明确敲定字段类型。或者可以使用 _mapping 动态添加新字段映射。

动态更新索引实战:

PUT mytest_0001/_mapping
{
  "properties": {
    "title": {
      "type": "text"
    }
  }
}

请注意:虽然可以通过如上命令动态添加字段,但是不能更改现有字段映射。

若想做字段类型的修改,需要重新定义Mapping 结合 reindex 和 alias 别名 实现。

2、BulkIndexError

批量索引大型数据集通常更有效。

例如,您可以执行一个批量操作来索引 1,000 个文档,而不是使用 1,000 个索引操作。

批量操作可以通过 bulk API 完成。

批量操作实战:

PUT my_index_0003/_bulk
{"index":{"_id":1}}
{"myid":"c12345"}
{"index":{"_id":2}}
{"myid":"C12456"}
{"index":{"_id":3}}
{"myid":"C31268"}

但是,此过程容易出错。执行批量操作的过程中,你需要仔细检查:数据类型不匹配和空值匹配等问题。

对于批量 API ,你需要格外警惕,因为即使有数百个肯定的响应,批量中的某些索引请求也可能失败。

批量操作捕获错误实战:

 @Override
  public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
 if (response.hasFailures()) {
  for (int i = 0; i < response.getItems().length; i++) {
   BulkItemResponse item = response.getItems()[i];
   if (item.isFailed()) {
      IndexRequest ireq = (IndexRequest) request.requests().get(i);
      logger.error("Failed while indexing to " + item.getIndex() + " type " + item.getType() + " " +
          "request: [" + ireq + "]: [" + item.getFailureMessage() + "]");
   }
  }
 }
  }

除了提前设置具有所有适当条件的批量 API 之外,还要浏览响应列表并检查每个响应,以确保所有数据均按预期索引。

3、搜索超时错误:ConnectionTimeout,ReadTimeoutError,RequestTimeout 等

如果在指定的搜索时间内未收到响应,则请求将失败并返回错误消息。这称为搜索超时。

搜索超时很常见,多种原因都可以导致搜索超时,例如:大型数据集或占用大量内存的查询。

要消除搜索超时,可以通过如下实现解决:

3.1 增加 elasticsearch.requestTimeout

设置注意:应该在 HTTP 客户端而不是 Elasticsearch 中指定 timeout 值,Elasticsearch 端没有请求超时参数。

kibana 请求显示超时,优化方案如下:

kibana 默认请求等待时间是 30 秒,可以在 kibana.yml 中调整该值。

elasticsearch.requestTimeout: 90000

3.2 减少每个请求返回的文档数量

不要将请求的 size 值设置太大,结合:from、size 深度翻页机制实现。

全量遍历借助 scroll 实现。

3.3 缩小时间范围

请求时间范围越长(比如 时间跨度周期 1  年以上的数据),请求数据量越大,超时的可能性越高。

3.4 调整内存设置

通过配置单个查询的内存断路器来限制单个查询的内存使用量。

如:将 index.breaker.request.limit 限制为 40%,默认是 60%。

集群层面设置请求熔断内存实战:

PUT /_cluster/settings
{
  "persistent": {
    "indices.breaker.request.limit": "40%"
  }
}

通过将search.max_buckets设置为 5000 (默认值:10000)来限制用于聚合的存储桶数。

PUT _cluster/settings
{
  "transient": {
    "search.max_buckets": 5000
  }
}

3.5 优化查询、索引和分片。

3.6 启用慢速搜索日志

监视搜索运行时间,扫描繁重的搜索等等。

慢日志开启实战:

PUT /_settings
{
  "index.search.slowlog.threshold.query.debug": "30s",
  "index.search.slowlog.threshold.fetch.debug": "30s",
  "index.indexing.slowlog.threshold.index.debug": "30s"
}

4、 All Shards Failed

在 Elasticsearch 搜索时,可能会遇到 “All Shards Failed” 的错误消息。

发生 All Shards Failed 的几种情况:

  • 当读取请求无法从分片获得响应时

  • 当由于集群或节点仍处于初始启动过程而无法搜索数据

  • 当分片丢失或处于恢复模式并且集群为红色时

造成 All Shards Failed 可能的原因:

  • 节点可能已断开连接或重新连接

  • 正在查询的分片可能正在恢复中,因此不可用

  • 磁盘可能已损坏

  • 搜索query 语句可能写的有问题。例如,引用字段类型错误的字段。

  • 配置错误可能导致操作失败。

问题排查实战举例:

GET /_cat/health
GET /_cat/indices?v
GET _cluster/health/?level=shards
GET _cluster/allocation/explain

5、进程内存锁定失败:“memory locking requested for elasticsearch process but memory is not locked”

为了使节点保持健康,必须确保没有将 JVM 内存换出到磁盘。

发生系统 swapping (交换)的时候 Elasticsearch 节点的性能会非常差,也会影响节点的稳定性。

所以要不惜一切代价来避免 swapping 。swapping会导致Java GC的周期延迟从毫秒级恶化到分钟,更严重的是会引起节点响应延迟甚至脱离集群。

限制 elasticsearch占用的内存情况,可选择少用swap。而:启用 bootstrap.memory_lock 就是限制交换的三种方案之一。

在 elasticsearch.yml 中 启动 memory_lock 实践:

bootstrap.memory_lock: true

报错复现如下:

[,260][INFO ][o.e.n.Node               ] [node-1] starting ...
[,529][INFO ][o.e.t.TransportService   ] [node-1] publish_address {172.17.0.5:9300}, bound_addresses {172.17.0.5:9300}
[,537][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[,565][ERROR][o.e.b.Bootstrap          ] [node-1] node validation exception
[1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[,575][INFO ][o.e.n.Node               ] [node-1] stopping ...
[,596][INFO ][o.e.n.Node               ] [node-1] stopped
[,597][INFO ][o.e.n.Node               ] [node-1] closing ...
[,615][INFO ][o.e.n.Node               ] [node-1] closed

centos 7.x 解决方案:在 /etc/security/limits.conf 文件中添加如下内容,并保持,然后重启 elasticsearch 即可。

elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

最佳实践之验证启动是否成功:

GET _nodes?filter_path=**.mlockall

正确返回结果如下:

{
  "nodes" : {
    "gJUT-E48u_nUw" : {
      "process" : {
        "mlockall" : true
      }
    }
  }
}

6、引导检查失败 Bootstrap Checks Failed

Bootstrap 检查会在 Elasticsearch 开始之前检查各种设置和配置,以确保其可以安全运行。

如果引导检查失败,则它们可以阻止 Elasticsearch 启动(如果处于生产模式)或在开发模式下发出警告日志。

建议你熟悉引导检查所强制执行的设置,并注意它们在开发和生产模式上是不同的。通过将系统属性

es.enforce.bootstrap.checks设置为true,可以强制执行引导检查。

主要检查内容包含但不限于:

  • 堆的大小检查

  • 文件描述符

  • 最大线程数

  • 文件大小限制

  • 最大虚拟内存

  • 最大映射数

  • 客户端jvm检查

  • 垃圾收集检查

  • OnError和OnOutOfMemoryError检查 ......

最佳实践:在 jvm.option 中添加如下配置后重启 Elasticsearch。

-Des.enforce.bootstrap.checks=true

7、TransportError

在Elasticsearch中,传输模块核心功能是:集群中节点之间的通信。

传输错误Transport errors 经常出现,失败可能是如下的原因引起的:

  • 分片丢失

  • 设置冲突

  • 数据建模不合理

  • 网络故障

  • .....

常见的 Transport errors 错误如下:

TransportError(403, u'cluster_block_exception', u'blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];')

原因分析:

当没有足够的可用磁盘空间供 Elasticsearch 在节点之间分配时,可能会发生这种情况。

解决方案:

  • 增加磁盘空间

  • 删除旧数据以释放空间

  • 更新索引只读模式。

注意:当磁盘使用率>=95%,index.blocks.read_only_allow_delete设置是防止节点用完磁盘空间的最后手段。不再允许写入,只能删除。

以下命令能重置索引上的只读索引块:

PUT /_all/_settings
{
  "index.blocks.read_only_allow_delete": null
}

在分配所有分片之前,尝试使用刚刚创建的索引时,可能会出现另一种传输错误。

在这种情况下,报错如下:

TransportError(503, u”). 

传输错误也可能与  Mapping 问题相关。

例如,当您尝试索引具有与其映射不同的数据类型的字段时,可能报错如下:

TransportError (400, u’mapper_pasing_exception’) 

8、初始化/启动失败 Initialization/Startup Failures

有时候,分片的问题可能会阻止 Elasticsearch 启动。

例如,当使用有冲突的 Elasticsearch 版本时,您可能报错如下:

“ Elasticsearch java client initialization fails” 

 “\Common was unexpected at this time.”

最佳实践:

做好版本核验,确保开发使用的 jar 包版本和部署版本一致。

9、如何最小化错误和异常?探究错误及解决方案的底层逻辑

如果你不想仅仅一次处理一条错误消息,当你处理的问题多了以后,你会发现:很多错误和异常与如下三个更深层次的问题相关:

  • 安装和配置问题

  • 索引新数据问题

  • 集群运行变慢问题

深究拆解如下:

9.1  安装和配置问题

快速安装 Elasticsearch 很容易,但是要确保其生产级别的运行,需要仔细核对配置。

这可以帮助避免各种错误和异常,例如:引导检查失败  bootstrap checks failure 问题。

9.2 索引新数据问题

在 Elasticsearch 中,你必须非常仔细的对字段命名、正确使用模板 template、数据建模规范化。

仔细核对这些参数配置,可以帮助你避免诸如:映射 mapping 异常和批量索引错误( bulk index errors)之类的问题。

9.3 集群速度变慢问题

随着数据规模的扩大,以及操作频繁度的扩展,Elasticsearch 有时会发生意外导致检索响应速度慢,并可能弹出超时报错。

因此,你必须持续监控集群的如下指标内容:

  • 借助 kibana 或者 cerebro 等可视化工具观察错误率及走势

  • 监控错误日志

  • 核对拒绝的指标

以提前将可能错误扼杀在摇篮阶段,并确保集群一切正常。

10、结论

Elasticsearch 运维或开发实战必定会遇到错误或异常。

尽管我们无法完全避免,但是可以采用一些最佳实践来帮助减少错误或异常的发生,并在出现问题时更有效地解决问题。

快速有效地解决集群缓慢等复杂问题离不开如下三点:

第一:密切关注各项设置和配置;

第二:索引新数据时要小心;

第三:确保集群各项指标可被监视与可视化查看。

简而言之,你应该将错误和异常视为优化 Elasticsearch 集群基础架构的机会,而不必过分担心它们的出现。


参考:

https://opster.com/blogs/common-elasticsearch-errors-and-exceptions/

Elasticsearch 官方文档 

https://discuss.elastic.co/t/how-to-identify-message-causing-error-in-bulk-request/42885/5

短时间快习得多干货!

中国近 1/4 的 Elastic认证工程师出自于此!

已标记关键词 清除标记
org.springframework.data.elasticsearch.ElasticsearchException: Bulk indexing has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages [{35175013607=java.lang.NullPointerException, 6571398=java.lang.NullPointerException, 7092274=java.lang.NullPointerException, 100000963930=java.lang.NullPointerException, 35175013605=java.lang.NullPointerException, 35175013603=java.lang.NullPointerException, 6494554=java.lang.NullPointerException, 38256172506=java.lang.NullPointerException, 38256172507=java.lang.NullPointerException, 100001233836=java.lang.NullPointerException, 34136834279=java.lang.NullPointerException, 100001233834=java.lang.NullPointerException, 100002570176=java.lang.NullPointerException, 100001233798=java.lang.NullPointerException, 31689214694=java.lang.NullPointerException, 31461047265=java.lang.NullPointerException, 7224923=java.lang.NullPointerException, 34775809762=java.lang.NullPointerException, 8239713=java.lang.NullPointerException, 34775809761=java.lang.NullPointerException, 100001485604=java.lang.NullPointerException, 34250730130=java.lang.NullPointerException, 100001485602=java.lang.NullPointerException, 7305675=java.lang.NullPointerException, 100000377904=java.lang.NullPointerException, 27012482300=java.lang.NullPointerException, 7930047=java.lang.NullPointerException, 27012486904=java.lang.NullPointerException, 27012486902=java.lang.NullPointerException, 100000237438=java.lang.NullPointerException, 100000003145=java.lang.NullPointerException, 100000237436=java.lang.NullPointerException, 7534113=java.lang.NullPointerException, 34818293603=java.lang.NullPointerException, 100000773847=java.lang.NullPointerException, 28287095112=java.lang.NullPointerException, 34250730122=java.lang.NullPointerException, 100001485116=java.lang.NullPointerException, 34250730124=java.lang.NullPointerException, 34250730123=java.lang.NullPointerException, 34250730126=java.lang.NullPointerException, 34250730125=java.lang.NullPointerException, 7092290=java.lang.NullPointerException, 34250730128=java.lang.NullPointerException, 100001333076=java.lang.NullPointerException, 34250730127=java.lang.NullPointerException, 34250730129=java.lang.NullPointerException, 34818456356=java.lang.NullPointerException, 34818456355=java.lang.NullPointerException, 34818456357=java.lang.NullPointerException, 100001045283=java.lang.NullPointerException, 28287095110=java.lang.NullPointerException, 34375690702=java.lang.NullPointerException, 34375690701=java.lang.NullPointerException, 29713999685=java.lang.NullPointerException, 100001319058=java.lang.NullPointerException, 7154350=java.lang.NullPointerException, 7643011=java.lang.NullPointerException, 29244755574=java.lang.NullPointerException, 29244755575=java.lang.NullPointerException, 29244755573=java.lang.NullPointerException, 8025794=java.lang.NullPointerException, 100000154516=java.lang.NullPointerException, 8025792=java.lang.NullPointerException, 8239695=java.lang.NullPointerException, 8788160=java.lang.NullPointerException, 100000184021=java.lang.NullPointerException, 100001878521=java.lang.NullPointerException, 29711314927=java.lang.NullPointerException, 28287095109=java.lang.NullPointerException, 100001485076=java.lang.NullPointerException, 100001485074=java.lang.NullPointerException, 7404615=java.lang.NullPointerException, 100001464948=java.lang.NullPointerException, 7428766=java.lang.NullPointerException, 100000237458=java.lang.NullPointerException, 7428762=java.lang.NullPointerException, 100000988351=java.lang.NullPointerException, 34375682099=java.lang.NullPointerException, 7191024=java.lang.NullPointerException, 100001319060=java.lang.NullPointerException, 100001906474=java.lang.NullPointerException, 34375682098=java.lang.NullPointerException, 34375682097=java.lang.NullPointerException, 100000773875=java.lang.NullPointerException, 100001319116=java.lang.NullPointerException, 100002338246=java.lang.NullPointerException, 100000183995=java.lang.NullPointerException, 100001156469=java.lang.NullPointerException, 29175021860=java.lang.NullPointerException, 100000154532=java.lang.NullPointerException, 100000237484=java.lang.NullPointerException, 100001156467=java.lang.NullPointerException, 100001156465=java.lang.NullPointerException, 100002338244=java.lang.NullPointerException, 36121534193=java.lang.NullPointerException, 36121534194=java.lang.NullPointerException, 33617936375=java.lang.NullPointerException, 100001485122=java.lang.NullPointerException, 33617936376=java.lang.NullPointerException, 100000911722=java.lang.NullPointerException, 100001595210=java.lang.NullPointerException, 100001439479=java.lang.NullPointerException, 100000773885=java.lang.NullPointerException, 100001156473=java.lang.NullPointerException, 100000773887=java.lang.NullPointerException, 100001156471=java.lang.NullPointerException, 100000773889=java.lang.NullPointerException, 100001231045=java.lang.NullPointerException, 100001233862=java.lang.NullPointerException, 8760430=java.lang.NullPointerException, 34205026825=java.lang.NullPointerException, 34205026824=java.lang.NullPointerException, 6784743=java.lang.NullPointerException, 29174630677=java.lang.NullPointerException, 39659065194=java.lang.NullPointerException, 7920226=java.lang.NullPointerException, 29174630678=java.lang.NullPointerException, 39659065193=java.lang.NullPointerException, 34205026823=java.lang.NullPointerException, 100000988335=java.lang.NullPointerException, 37597861535=java.lang.NullPointerException, 37597861534=java.lang.NullPointerException, 100001333150=java.lang.NullPointerException, 29244302722=java.lang.NullPointerException, 37597861533=java.lang.NullPointerException, 29244302721=java.lang.NullPointerException, 37597861532=java.lang.NullPointerException, 29244302720=java.lang.NullPointerException, 6729013=java.lang.NullPointerException, 32503644193=java.lang.NullPointerException, 37597861537=java.lang.NullPointerException, 37597861536=java.lang.NullPointerException, 100000911710=java.lang.NullPointerException, 100001485560=java.lang.NullPointerException, 28299389670=java.lang.NullPointerException, 100000911712=java.lang.NullPointerException, 100001595964=java.lang.NullPointerException, 37597861531=java.lang.NullPointerException, 8929561=java.lang.NullPointerException, 37597861530=java.lang.NullPointerException, 100001054621=java.lang.NullPointerException, 28298251327=java.lang.NullPointerException, 100001233856=java.lang.NullPointerException, 28298251326=java.lang.NullPointerException, 100001231555=java.lang.NullPointerException, 28298251328=java.lang.NullPointerException, 29175021859=java.lang.NullPointerException, 8895275=java.lang.NullPointerException, 100001142569=java.lang.NullPointerException, 28299389671=java.lang.NullPointerException, 100001233850=java.lang.NullPointerException, 7429498=java.lang.NullPointerException, 100000022652=java.lang.NullPointerException, 100001319136=java.lang.NullPointerException, 37597861529=java.lang.NullPointerException, 7429496=java.lang.NullPointerException, 28299389669=java.lang.NullPointerException, 31932181907=java.lang.NullPointerException, 34375682100=java.lang.NullPointerException, 36106257175=java.lang.NullPointerException, 100001319134=java.lang.NullPointerException, 100000911700=java.lang.NullPointerException, 100000117055=java.lang.NullPointerException, 34136834280=java.lang.NullPointerException, 100000117057=java.lang.NullPointerException, 34136834281=java.lang.NullPointerException, 31932181906=java.lang.NullPointerException, 31798976361=java.lang.NullPointerException, 29712264630=java.lang.NullPointerException, 6708229=java.lang.NullPointerException, 8760654=java.lang.NullPointerException, 33164693575=java.lang.NullPointerException, 100000117053=java.lang.NullPointerException}] at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.checkForBulkUpdateFailure(ElasticsearchTemplate.java:642) at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.bulkIndex(ElasticsearchTemplate.java:623) at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.saveAll(AbstractElasticsearchRepository.java:185) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy98.saveAll(Unknown Source) at com.changgou.search.service.impl.ESManagerServiceImpl.importAll(ESManagerServiceImpl.java:58) at com.changgou.search.controller.ESManagerController.importAll(ESManagerController.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
<div><p>Hi,</p> <p>I am trying to start apiman on a local machine and here is what I got:</p> <pre><code> apiman_1 | 11:08:24,675 INFO [stdout] (MSC service thread 1-2) ----------------------------- apiman_1 | 11:08:24,675 INFO [stdout] (MSC service thread 1-2) apiman-es started! apiman_1 | 11:08:24,675 INFO [stdout] (MSC service thread 1-2) ----------------------------- apiman_1 | 11:08:24,679 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017534: Registered web context: /apiman-es apiman_1 | 11:08:24,710 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "apimanui.war" (runtime-name : "apimanui.war") apiman_1 | 11:08:24,710 INFO [org.jboss.as.server] (ServerService Thread Pool -- 51) JBAS018559: Deployed "main-auth-server.war" (runtime-name : "main-auth-server.war") apiman_1 | 11:08:24,711 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "apiman-gateway-api.war" (runtime-name : "apiman-gateway-api.war") apiman_1 | 11:08:24,711 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "apiman-gateway.war" (runtime-name : "apiman-gateway.war") apiman_1 | 11:08:24,711 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "apiman-es.war" (runtime-name : "apiman-es.war") apiman_1 | 11:08:24,711 INFO [org.jboss.as.server] (ServerService Thread Pool -- 29) JBAS018559: Deployed "apiman.war" (runtime-name : "apiman.war") apiman_1 | 11:08:24,720 INFO [org.elasticsearch.gateway] (elasticsearch[SuperPro][clusterService#updateTask][T#1]) [SuperPro] recovered [1] indices into cluster_state apiman_1 | 11:08:24,750 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management apiman_1 | 11:08:24,751 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990 apiman_1 | 11:08:24,751 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 11219ms - Started 722 of 815 services (158 services are lazy, passive or on-demand) apiman_1 | 11:08:33,597 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Using multi thread/connection supporting pooling connection manager apiman_1 | 11:08:33,608 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Using multi thread/connection supporting pooling connection manager apiman_1 | 11:08:33,627 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Using default GSON instance apiman_1 | 11:08:33,628 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Node Discovery disabled... apiman_1 | 11:08:33,628 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Idle connection reaping disabled... apiman_1 | 11:08:33,639 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Using default GSON instance apiman_1 | 11:08:33,640 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Node Discovery disabled... apiman_1 | 11:08:33,640 INFO [io.searchbox.client.JestClientFactory] (PollCachingESInvalidator) Idle connection reaping disabled... apiman_1 | 11:08:33,834 INFO [org.elasticsearch.cluster.metadata] (elasticsearch[SuperPro][clusterService#updateTask][T#1]) [SuperPro] [apiman_gateway] creating index, cause [api], templates [], shards [5]/[1], mappings [application, service, serviceContract] apiman_1 | 11:08:33,965 ERROR [stderr] (PollCachingESInvalidator) Exception in thread "PollCachingESInvalidator" java.lang.RuntimeException: java.lang.Exception: Failed to create index: apiman_gateway apiman_1 | 11:08:33,965 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.initializeClient(ESClientFactory.java:200) apiman_1 | 11:08:33,965 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.createJestClient(ESClientFactory.java:140) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.createJestClient(ESClientFactory.java:101) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.createClient(ESClientFactory.java:66) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.AbstractESComponent.getClient(AbstractESComponent.java:45) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.PollCachingESRegistry.checkCacheVersion(PollCachingESRegistry.java:195) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.PollCachingESRegistry$6.run(PollCachingESRegistry.java:168) apiman_1 | 11:08:33,966 ERROR [stderr] (PollCachingESInvalidator) at java.lang.Thread.run(Thread.java:745) apiman_1 | 11:08:33,967 ERROR [stderr] (PollCachingESInvalidator) Caused by: java.lang.Exception: Failed to create index: apiman_gateway apiman_1 | 11:08:33,967 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.createIndex(ESClientFactory.java:216) apiman_1 | 11:08:33,967 ERROR [stderr] (PollCachingESInvalidator) at io.apiman.gateway.engine.es.ESClientFactory.initializeClient(ESClientFactory.java:197) apiman_1 | 11:08:33,967 ERROR [stderr] (PollCachingESInvalidator) ... 7 more </code></pre> <p>Any ideas what's wrong?</p> <p><strong>apiman.properties</strong></p> <pre><code> # Remote maven repositories to use when looking for plugins. Comma separated # list of URLs. apiman.plugins.repositories=https://repo1.maven.org/maven2/,http://repository.jboss.org/nexus/content/groups/public/ apiman-manager.plugins.registries=http://rawgit.com/apiman/apiman-plugin-registry/master/registry.json # Apiman Manager logging. standard, json or a FQDN implementing IApimanLogger apiman-manager.config.logger=standard # --------------------------------------------------------------------- # The following are settings for using elasticsearch for various # apiman components. # --------------------------------------------------------------------- apiman.es.protocol=http apiman.es.host=localhost apiman.es.port=19200 apiman.es.username= apiman.es.password= apiman.es.timeout=10000 # --------------------------------------------------------------------- # Some hibernate settings only useful when JPA is the storage.type. # --------------------------------------------------------------------- apiman.hibernate.connection.datasource=java:jboss/datasources/apiman-manager apiman.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect apiman.hibernate.hbm2ddl.auto=update # How the API Manager UI authenticates to the API Manager REST services apiman-manager-ui.api.authentication.type=bearerToken apiman-manager-ui.api.authentication.token.generator=io.apiman.manager.ui.server.wildfly8.KeyCloakBearerTokenGenerator # Security context settings. apiman-manager.security-context.type=keycloak # API Manager storage settings. apiman-manager.storage.type=jpa #apiman-manager.storage.es.protocol=${apiman.es.protocol} #apiman-manager.storage.es.host=${apiman.es.host} #apiman-manager.storage.es.port=${apiman.es.port} #apiman-manager.storage.es.username=${apiman.es.username} #apiman-manager.storage.es.password=${apiman.es.password} #apiman-manager.storage.es.timeout=${apiman.es.timeout} #apiman-manager.storage.es.initialize=true # API Manager metrics settings. apiman-manager.metrics.type=es apiman-manager.metrics.es.protocol=${apiman.es.protocol} apiman-manager.metrics.es.host=${apiman.es.host} apiman-manager.metrics.es.port=${apiman.es.port} apiman-manager.metrics.es.username=${apiman.es.username} apiman-manager.metrics.es.password=${apiman.es.password} apiman-manager.metrics.es.timeout=${apiman.es.timeout} # API Manager Service Catalog apiman-manager.service-catalog.type=io.apiman.manager.api.core.catalog.JsonServiceCatalog apiman-manager.service-catalog.catalog-url=http://rawgit.com/apiman/apiman-service-catalog/master/catalog.json # API Gateway components apiman-gateway.plugin-registry=io.apiman.gateway.engine.impl.DefaultPluginRegistry apiman-gateway.plugin-registry.pluginsDir=${jboss.server.data.dir}/apiman/plugins apiman-gateway.plugin-registry.pluginRepositories=${apiman.plugins.repositories} apiman-gateway.connector-factory=io.apiman.gateway.platforms.servlet.connectors.HttpConnectorFactory apiman-gateway.policy-factory=io.apiman.gateway.engine.policy.PolicyFactoryImpl apiman-gateway.components.IPolicyFailureFactoryComponent=io.apiman.gateway.platforms.servlet.PolicyFailureFactoryComponent apiman-gateway.components.IBufferFactoryComponent=io.apiman.gateway.engine.impl.ByteBufferFactoryComponent apiman-gateway.public-endpoint=https://localhost/apiman-gateway/ # --------------------------------------------------------------------- # Connector factory options # --------------------------------------------------------------------- apiman-gateway.connector-factory.http.timeouts.read=30 apiman-gateway.connector-factory.http.timeouts.write=30 apiman-gateway.connector-factory.http.timeouts.connect=10 # --------------------------------------------------------------------- # Elasticsearch Metrics Settings # --------------------------------------------------------------------- apiman-gateway.metrics=io.apiman.gateway.engine.es.ESMetrics apiman-gateway.metrics.client.type=jest apiman-gateway.metrics.client.protocol=${apiman.es.protocol} apiman-gateway.metrics.client.host=${apiman.es.host} apiman-gateway.metrics.client.port=${apiman.es.port} apiman-gateway.metrics.client.initialize=true apiman-gateway.metrics.client.username=${apiman.es.username} apiman-gateway.metrics.client.password=${apiman.es.password} apiman-gateway.metrics.client.timeout=${apiman.es.timeout} # --------------------------------------------------------------------- # SSL/TLS settings for the gateway connector(s). # --------------------------------------------------------------------- # Enable devMode for HTTPS connections (gateway trusts any certificate). # This should *NOT* be used in production mode. *Use with great care.* apiman-gateway.connector-factory.tls.devMode=false # Trust store contains certificate(s) trusted by gateway. #apiman-gateway.connector-factory.tls.trustStore=<path_to_trust_store> #apiman-gateway.connector-factory.tls.trustStorePassword=<password_if_any> # Key store contains gateway's keys (including private components: keep it safe). apiman-gateway.connector-factory.tls.keyStore=apiman_gateway.jks apiman-gateway.connector-factory.tls.keyStorePassword=secret apiman-gateway.connector-factory.tls.keyPassword=secret # By default all keys can be used (will try all). If alias list provided, will only attempt to use listed keys. apiman-gateway.connector-factory.tls.keyAliases=apiman_gateway_cert # Allowed TLS/SSL protocols and ciphers suites as CSV. Availability will vary depending on your JVM impl. # Uses JVM defaults depending if not explicitly provided. # See: https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html # You may wish to consider global JVM settings by modifying java.security #apiman-gateway.connector-factory.tls.allowedProtocols=TLSv1.2,TLSv1.1 #apiman-gateway.connector-factory.tls.disallowedProtocols=SSLv1,SSLv2 #apiman-gateway.connector-factory.tls.allowedCiphers=TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA #apiman-gateway.connector-factory.tls.disallowedCiphers=RC4 # Whether certificate host checks should be bypassed. *Use with great care.* apiman-gateway.connector-factory.tls.allowAnyHost=false # Whether self-signed certificates should be automatically trusted. *Use with great care.* apiman-gateway.connector-factory.tls.allowSelfSigned=false # --------------------------------------------------------------------- # Registry Settings # --------------------------------------------------------------------- apiman-gateway.registry=io.apiman.gateway.engine.es.PollCachingESRegistry apiman-gateway.registry.client.type=jest apiman-gateway.registry.client.protocol=${apiman.es.protocol} apiman-gateway.registry.client.host=${apiman.es.host} apiman-gateway.registry.client.port=${apiman.es.port} apiman-gateway.registry.client.initialize=true apiman-gateway.registry.client.username=${apiman.es.username} apiman-gateway.registry.client.password=${apiman.es.password} apiman-gateway.registry.client.timeout=${apiman.es.timeout} apiman-gateway.registry.cache-polling-interval=15 # --------------------------------------------------------------------- # Shared State Component Settings # --------------------------------------------------------------------- apiman-gateway.components.ISharedStateComponent=io.apiman.gateway.engine.es.ESSharedStateComponent apiman-gateway.components.ISharedStateComponent.client.type=jest apiman-gateway.components.ISharedStateComponent.client.protocol=${apiman.es.protocol} apiman-gateway.components.ISharedStateComponent.client.host=${apiman.es.host} apiman-gateway.components.ISharedStateComponent.client.port=${apiman.es.port} apiman-gateway.components.ISharedStateComponent.client.initialize=true apiman-gateway.components.ISharedStateComponent.client.username=${apiman.es.username} apiman-gateway.components.ISharedStateComponent.client.password=${apiman.es.password} apiman-gateway.components.ISharedStateComponent.client.timeout=${apiman.es.timeout} # --------------------------------------------------------------------- # Rate Limiter Component Settings # --------------------------------------------------------------------- apiman-gateway.components.IRateLimiterComponent=io.apiman.gateway.engine.es.ESRateLimiterComponent apiman-gateway.components.IRateLimiterComponent.client.type=jest apiman-gateway.components.IRateLimiterComponent.client.protocol=${apiman.es.protocol} apiman-gateway.components.IRateLimiterComponent.client.host=${apiman.es.host} apiman-gateway.components.IRateLimiterComponent.client.port=${apiman.es.port} apiman-gateway.components.IRateLimiterComponent.client.initialize=true apiman-gateway.components.IRateLimiterComponent.client.username=${apiman.es.username} apiman-gateway.components.IRateLimiterComponent.client.password=${apiman.es.password} apiman-gateway.components.IRateLimiterComponent.client.timeout=${apiman.es.timeout} # --------------------------------------------------------------------- # Cache Store Component Settings # --------------------------------------------------------------------- apiman-gateway.components.ICacheStoreComponent=io.apiman.gateway.engine.es.ESCacheStoreComponent apiman-gateway.components.ICacheStoreComponent.client.type=jest apiman-gateway.components.ICacheStoreComponent.client.protocol=${apiman.es.protocol} apiman-gateway.components.ICacheStoreComponent.client.host=${apiman.es.host} apiman-gateway.components.ICacheStoreComponent.client.port=${apiman.es.port} apiman-gateway.components.ICacheStoreComponent.client.initialize=true apiman-gateway.components.ICacheStoreComponent.client.username=${apiman.es.username} apiman-gateway.components.ICacheStoreComponent.client.password=${apiman.es.password} apiman-gateway.components.ICacheStoreComponent.client.timeout=${apiman.es.timeout} # --------------------------------------------------------------------- # JDBC Component Settings # --------------------------------------------------------------------- apiman-gateway.components.IJdbcComponent=io.apiman.gateway.engine.impl.DefaultJdbcComponent </password_if_any></path_to_trust_store></code></pre><p>该提问来源于开源项目:apiman/apiman</p></div>
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页