cluster_block_exception

https://stackoverflow.com/questions/50609417/elasticsearch-error-cluster-block-exception-forbidden-12-index-read-only-all

在向index插入数据的时候报错

Request

PUT http://localhost:9200/customer/_doc/1?pretty

PUT data:
{
"name": "John Doe"
}

Response

{
"error" : {
"root_cause" : [
{
"type" : "cluster_block_exception",
"reason" : "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
}
],
"type" : "cluster_block_exception",
"reason" : "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
},
"status" : 403
}

https://stackoverflow.com/questions/50609417/elasticsearch-error-cluster-block-exception-forbidden-12-index-read-only-all

This happens when Elasticsearch thinks the disk is running low on space so it puts itself into read-only mode.

By default Elasticsearch's decision is based on the percentage of disk space that's free, so on big disks this can happen even if you have many gigabytes of free space.

The flood stage watermark is 95% by default, so on a 1TB drive you need at least 50GB of free space or Elasticsearch will put itself into read-only mode.

For docs about the flood stage watermark see https://www.elastic.co/guide/en/elasticsearch/reference/6.2/disk-allocator.html.

The right solution depends on the context - for example a production environment vs a development environment.

Solution 1: free up disk space

Freeing up enough disk space so that more than 5% of the disk is free will solve this problem.

Elasticsearch won't automatically take itself out of read-only mode once enough disk is free though, you'll have to do something like this to unlock the indices:

$ curl -XPUT -H "Content-Type: application/json" https://[YOUR_ELASTICSEARCH_ENDPOINT]:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

https://curl.haxx.se/docs/manpage.html

-d参数是数据的意思

设置完成之后,

{
"acknowledged": true
}

Solution 2: change the flood stage watermark setting

Change the "cluster.routing.allocation.disk.watermark.flood_stage" setting to something else.

It can either be set to a lower percentage or to an absolute value.

Here's an example of how to change the setting from the docs:

PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "100gb",
"cluster.routing.allocation.disk.watermark.high": "50gb",
"cluster.routing.allocation.disk.watermark.flood_stage": "10gb",
"cluster.info.update.interval": "1m"
}
}

Again, after doing this you'll have to use the curl command above to unlock the indices, but after that they should not go into read-only mode again.

The bulk request must be terminated by a newline

{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
},
"status" : 400
}

在批量导入数据的时候出错

https://stackoverflow.com/questions/48579980/bulk-request-throws-error-in-elasticsearch-6-1-1

Add empty line at the end of the JSON file and save the file and then try to run the below command

curl -XPOST localhost:9200/subscribers/ppl/_bulk?pretty --data-binary @customers_full.json -H 'Content-Type: application/json'

I hope it works fine for you.

Elasticsearch 异常处理的更多相关文章

  1. ElasticSearch Index操作源码分析

    ElasticSearch Index操作源码分析 本文记录ElasticSearch创建索引执行源码流程.从执行流程角度看一下创建索引会涉及到哪些服务(比如AllocationService.Mas ...

  2. 探究ElasticSearch中的线程池实现

    探究ElasticSearch中的线程池实现 ElasticSearch里面各种操作都是基于线程池+回调实现的,所以这篇文章记录一下java.util.concurrent涉及线程池实现和Elasti ...

  3. Elasticsearch Java API的基本使用

    说明 在明确了ES的基本概念和使用方法后,我们来学习如何使用ES的Java API. 本文假设你已经对ES的基本概念已经有了一个比较全面的认识. 客户端 你可以用Java客户端做很多事情: 执行标准的 ...

  4. Elastic-search在linux上的安装

    今天是我装第四次 ES ,之前装好用了一段时间,后面莫名其妙爆炸了,炸出一堆异常... 安装环境: JDK1.8   centos    ElasticSearch-6.2.4 jdk1.8以上,所以 ...

  5. Elasticsearch 系列1 --- Windows10安装Elasticsearch

    在Windows环境下,ES提供了两种安装方式,一种是通过MSI,特点是简单方便:另一种是绿色安装,解压zip包.本文选择第二种方式. 1. 准备工作 (1) Windows 10 (2) JDK 1 ...

  6. Filebeat 导入 Elasticsearch 的方法

    Filebeat 导入 Elastaticsearch 的方法 1. 什么是Filebeat?到底是干什么的? Filebeat说实话,就是一个日志监控分发器,类似tail -f这样去监控某个日志,或 ...

  7. SpringBoot优雅的全局异常处理

    前言 本篇文章主要介绍的是SpringBoot项目进行全局异常的处理. SpringBoot全局异常准备 说明:如果想直接获取工程那么可以直接跳到底部,通过链接下载工程代码. 开发准备 环境要求 JD ...

  8. elasticsearch indices.recovery 流程分析(索引的_open操作也会触发recovery)——主分片recovery主要是从translog里恢复之前未写完的index,副分片recovery主要是从主分片copy segment和translog来进行恢复

    摘自:https://www.easyice.cn/archives/231 elasticsearch indices.recovery 流程分析与速度优化 目录 [隐藏] 主分片恢复流程 副本分片 ...

  9. mysql数据实时同步到Elasticsearch

    业务需要把mysql的数据实时同步到ES,实现低延迟的检索到ES中的数据或者进行其它数据分析处理.本文给出以同步mysql binlog的方式实时同步数据到ES的思路, 实践并验证该方式的可行性,以供 ...

随机推荐

  1. wordpress学习(三)-----add_action动作钩子和add_filter()过滤器钩子

    <?php echo "<h2>高级教程add_action动作和add_filter()过滤器</h2><br/>"; //1.学会使用 ...

  2. Thread(26)

    1.进程:进程指正在运行的程序.确切的来说,当一个程序进入内存运行,即变成一个进程,进程是处于运行过程中的程序,并且具有一定独立功能. 2.线程:线程是进程中的一个执行单元,负责当前进程中程序的执行, ...

  3. tensorflow--variable_scope

    1.with tf.variable_scope(name , reuse = reuse) (1)创建variable scope with tf.variable_scope("foo& ...

  4. PHP HTML混写,PHP中把大块HTML文本直接赋值给字符串变量的方法

    PHP HTML混写,PHP中把大块HTML文本直接赋值给字符串变量的方法 使用HEREDOC/NOWDOCHEREDOC和NOWDOC是PHP5.3开始支持的一种新特性,它允许在程序中使用一种自定义 ...

  5. Installing Android Studio

    To set up Android Studio on Windows: Launch the .exe file you just downloaded. Follow the setup wiza ...

  6. python之运算符与基本数据类型

    1.开发工具:IDE pycharm(推荐).eclipse 2.运算符 结果是值 算数运算 a = 10 * 10 赋值运算 a = a + 1    a+=1 结果是布尔值 比较运算 a = 1 ...

  7. CentOS7安装MySQL冲突和问题解决小结

    摘自:https://blog.csdn.net/typa01_kk/article/details/49059729 问题1: [root@localhost install-files]# rpm ...

  8. 跨域的根本原因:JavaScript 的同源策略

    摘自:https://blog.csdn.net/liubo2012/article/details/43148705 同源策略限制了一个源(origin)中加载文本或脚本与来自其它源(origin) ...

  9. jq如何获取服务器的时间

    $.ajax({type:"OPTIONS",url:"/",complete:function(x){alert(x.getResponseHeader(&q ...

  10. Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源

    Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源 在项目启动的时候需要做一些初始化的操作,比如初始化线程池,提前加载好加密证书等.今天就给大家介绍一个 Spri ...