Elasticserach 同步索引报错:ElasticSearch ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]

Welcome attention to personal micro-channel public number: Patricia learn the Java , the end of the text to share "Java Core Knowledge pick up & interview .pdf" link resource Ali P8 senior architect vomiting blood summary ! !

Website: https://www.exception.site/essay/elasticsearch-sync-index-read-only-allow-delete

Remember once in the station synchronous data transmission failure on the scene Elasticsearch

table of Contents

  • One, background
  • Second, digression
  • Third, start troubleshooting
  • Fourth, why the index is read-only state?
  • Fifth, how to solve

One, background

A few days ago Patricia receive feedback in the line of business in Chongqing nail the group, said that the station synchronous data transmission in the middleware Mysql incremental data to Elasticsearch always fail.

what

Second, digression

You said that data transmission and data transmission DTS Ali cloud provider is a thing?

Ali DTS data transmission

Not! The above said data transmission is in Taiwan where the R & D department Patricia middleware independent research and development, the purpose is to replace each line of business dependence on Ali DTS synchronization function!

Currently, the data transmission still have to rely on the open source Ali Canal, or Ali DTS, dependent on the purpose is to achieve Mysql database binlog incremental subscription.

Network architecture diagram above example, the data transmission units act as a binlog event consumers through custom rules mapping, data processing, distribution and final synchronization to the target source Elasticsearch in.

Third, start troubleshooting

Return to the topic, a problem, and quickly flew through the springboard machine connected to the server where the data transmission, start looking at the log:

See a lot of logs exist [FORBIDDEN/12/index read-only / allow delete (api)]errors! !

提示错误也很明显:ES 索引处于只读状态!!在和业务组沟通以后,发现需要同步的目标索引有两个,一个商品索引(充当主表),一个商品属性索引(充当商品从表),从表同步是 ok 的,也就是说商品属性索引非只读状态,写入正常,仅仅是商品索引处于只读状态,最终未能正常同步数据。

四、为什么索引处于只读状态呢?

什么原因导致的索引只读的?小哈开始翻阅 Elasticsearch 官方文档, 原文如下:

Elasticsearch considers the available disk space on a node before deciding whether to allocate new shards to that node or to actively relocate shards away from that node.

Elasticsearch 在决定是否分配新分片给该节点,或对该节点重新定位分片之前,会先判断该节点存储空间是否足够,如果说你的使用磁盘空间已经超过 95%,ES 会自动将索引 index 置为 read-only 状态。

于是,让运维看下 ES 机器的磁盘空间是否足够,运维反馈说:前两天就是因为磁盘不足告警,刚刚扩的容,肯定是够的!

真相大白了!

前两天磁盘空间不足,那个时候,商品索引刚好有写入的操作,由于 ES 的保护机制,将该索引置为了只读状态。

五、如何解决

原因找到了!要如何解决呢?

处于只读状态的索引,只能被查询或者删除。而 ES 还不会自动将索引状态切换回来,就需要我们手动切换了:

PUT /<yourindex>/_settings
{
  "index.blocks.read_only_allow_delete": null
}

对商品索引执行如上命令后。让业务组再次同步数据,一切正常了。

六、参考

Free Share | Interview & Learning welfare resources

Recently I found on the Internet a nice PDF resources "Java Core Knowledge & interview .pdf" for everyone to share, not just the interview, to learn, you deserve! ! !

Access: No public concern: Patricia learn the Java , background replies resources , both free without routine access to resources link , here are catalog as well as some screenshots:

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

Focus on micro-channel public number [Patricia] learn Java, reply [resources], you can receive a free resource links Oh no routine

The important thing to say it twice, public concern number: Patricia learn the Java , background replies resources , both free without routine access to resources links ! ! !

Guess you like

Origin www.cnblogs.com/quanxiaoha/p/10961920.html