elasticsearch错误

0

错误日志:

[2021-01-11T10:44:40,184][WARN ][o.e.x.m.e.l.LocalExporter] [node-1] unexpected error while indexing monitoring document
org.elasticsearch.xpack.monitoring.exporter.ExportException: org.elasticsearch.common.ValidationException: Validation Failed: 1: this action would add [1] total shards, but this cluster currently has [3693]/[1000] maximum shards open;
	at org.elasticsearch.xpack.monitoring.exporter.local.LocalBulk.lambda$throwExportException$2(LocalBulk.java:125) ~[x-pack-monitoring-7.3.0.jar:7.3.0]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?]
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?]

临时修改:

curl -u user:password -XPUT localhost:9200/_cluster/settings -H 'content-Type:application/json' -d '{
  "transient": {
    "cluster": {
      "max_shards_per_node": 6000
    }
  }
}'

永久修改:

curl -u user:password -XPUT localhost:9200/_cluster/settings -H 'content-Type:application/json' -d '{
  "persistent": {
    "cluster": {
      "max_shards_per_node": 6000
    }
  }
}'

read_only_allow_delete

PUT /_setting

{
  "index.blocks.read_only_allow_delete": null
}

枚举索引

我还是喜欢直接使用枚举名称,但是也有部分喜欢使用索引的,记录一下。

    @Bean
	public ElasticsearchConverter elasticsearchEntityMapper(SimpleElasticsearchMappingContext simpleElasticsearchMappingContext) {
		final MappingElasticsearchConverter mappingElasticsearchConverter = new MappingElasticsearchConverter(simpleElasticsearchMappingContext);
		mappingElasticsearchConverter.setConversions(this.elasticsearchCustomConversions());
		return mappingElasticsearchConverter;
	}
	
	@Bean
	public ElasticsearchCustomConversions elasticsearchCustomConversions() {
	    return new ElasticsearchCustomConversions(List.of(
	    	Action.ActionToValueConverter.INSTANCE,
	    	Action.ValueToActionConverter.INSTANCE,
	    	Status.StatusToValueConverter.INSTANCE,
	    	Status.ValueToStatusConverter.INSTANCE,
	    	AlarmLevel.AlarmLevelToValueConverter.INSTANCE,
	    	AlarmLevel.ValueToAlarmLevelConverter.INSTANCE,
	    	AlarmObjType.AlarmObjTypeToValueConverter.INSTANCE,
	    	AlarmObjType.ValueToAlarmObjTypeConverter.INSTANCE
    	));
	}

	@WritingConverter
	public enum ActionToValueConverter implements Converter<Action, Integer> {
		INSTANCE;
		@Override
		public Integer convert(Action source) {
			return source.value;
		}
	}

	@ReadingConverter
	public enum ValueToActionConverter implements Converter<Integer, Action> {
		INSTANCE;
		@Override
		public Action convert(Integer source) {
			for (Action value : Action.values()) {
				if (value.value.equals(source)) {
					return value;
				}
			}
			return null;
		}
	}