自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

近期,幾個(gè)典型 Elasticsearch 8.X 問(wèn)題及方案探討

開(kāi)發(fā) 前端
各位大佬,同版本的es集群間數(shù)據(jù)遷移,假設(shè)兩個(gè)集群節(jié)點(diǎn)數(shù)相同,是不是可以通過(guò)直接拷貝數(shù)據(jù)文件來(lái)進(jìn)行?。?/div>

問(wèn)題1:max_expansions 設(shè)置大了會(huì)報(bào)錯(cuò),什么原因?

大佬們問(wèn)個(gè)問(wèn)題,我在使用match_phrase_prefix時(shí)候,設(shè)置了一個(gè)比較大的max_expansions,比如10000。

這個(gè)時(shí)候會(huì)報(bào)錯(cuò):too_many_clauses: maxClauseCount is set to 1024。我搜了下 maxClauseCount 這是控制搜索條件數(shù)量的,但我這只是改了個(gè) max_expansions 就這樣了,這2者有什么聯(lián)系呀?

根本原因:

如果你設(shè)置了一個(gè)很高的值( 10000),Elasticsearch 會(huì)嘗試生成所有可能的匹配項(xiàng),直到達(dá)到這個(gè)限制。

而進(jìn)行 match_phrase_prefix 查詢時(shí),每個(gè)可能的匹配項(xiàng)都會(huì)被視為一個(gè)子句。

如果生成的匹配項(xiàng)數(shù)量超過(guò) maxClauseCount 的限制,就會(huì)出現(xiàn) too_many_clauses 錯(cuò)誤。

可行的解決方案:

選擇一個(gè)更合理的 max_expansions 值,以保持生成的查詢子句數(shù)量在 maxClauseCount 的限制范圍內(nèi)。

問(wèn)題2:集群數(shù)據(jù)遷移能不能直接拷貝文件?

各位大佬,同版本的es集群間數(shù)據(jù)遷移,假設(shè)兩個(gè)集群節(jié)點(diǎn)數(shù)相同,是不是可以通過(guò)直接拷貝數(shù)據(jù)文件來(lái)進(jìn)行???

去年年底咱們就討論過(guò):臘月27日凌晨的一個(gè)緊急 Elasticsearch 線上問(wèn)題復(fù)盤(pán)

一句話,非必要不要直接拷貝文件。

官方文檔在集群備份部分有過(guò)強(qiáng)調(diào)如下:

you cannot back up an Elasticsearch cluster by making copies of the data directories of its nodes. There are no supported methods to restore any data from a filesystem-level backup. If you try to restore a cluster from such a backup, it may fail with reports of corruption or missing files or other data inconsistencies, or it may appear to have succeeded having silently lost some of your data.

中文釋義:

  • 你無(wú)法通過(guò)復(fù)制其節(jié)點(diǎn)的數(shù)據(jù)目錄來(lái)備份 Elasticsearch 集群。
  • 不支持從文件系統(tǒng)級(jí)備份恢復(fù)任何數(shù)據(jù)的方法。
  • 如果你嘗試從此類備份恢復(fù)集群,則可能會(huì)失敗,并報(bào)告損壞或丟失文件或其他數(shù)據(jù)不一致的情況,或者可能看似已成功,但悄無(wú)聲息地丟失了一些數(shù)據(jù)。

https://discuss.elastic.co/t/why-are-we-told-to-copy-the-data-folder-when-upgrading/168951

https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshot-restore.html

問(wèn)題3:全局超時(shí)如何設(shè)置?

除了每個(gè)search可以配置自己的timeout,集群有沒(méi)有參數(shù)可以配置一個(gè)統(tǒng)一的timeout,針對(duì)所有search都生效額?

建議:看看這個(gè)參數(shù): search.default_search_timeout。

To set a cluster-wide default timeout for all search requests, configure search.default_search_timeout using the cluster settings API. This global timeout duration is used if no timeout argument is passed in the request. If the global search timeout expires before the search request finishes, the request is cancelled using task cancellation. The search.default_search_timeout setting defaults to -1 (no timeout).

圖片

集群層面設(shè)置解決方案如下:

圖片圖片

PUT /_cluster/settings
{
  "persistent": {
    "search.default_search_timeout": "30s"
  }
}

要為所有搜索請(qǐng)求設(shè)置集群范圍內(nèi)的默認(rèn)超時(shí)時(shí)間,可以使用集群設(shè)置 API 配置 search.default_search_timeout。

如果請(qǐng)求中沒(méi)有傳遞超時(shí)參數(shù),則使用這個(gè)全局超時(shí)持續(xù)時(shí)間。

如果全局搜索超時(shí)在搜索請(qǐng)求完成之前到期,請(qǐng)求將通過(guò)任務(wù)取消被取消。

search.default_search_timeout 設(shè)置的默認(rèn)值為 -1(無(wú)超時(shí))。

https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-your-data.html#search-timeout

問(wèn)題4:自定義ID如何自動(dòng)設(shè)置為 MD5呢?

銘毅老師你好,想請(qǐng)問(wèn)一下,往es索引里面插入文檔分為指定文檔id和自動(dòng)生成文檔id,目前有一個(gè)需求在插入文檔的時(shí)候,將文檔的id值取插入的文檔中的一個(gè)字段。

比如我插入的是一個(gè)關(guān)于文件的相關(guān)信息的文檔,字段有md5值,大小,文件類型等等信息,此時(shí)我希望插入的這個(gè)文檔的ID是這個(gè)文件的md5值, 不太明白怎么設(shè)置這樣的關(guān)系,謝謝!

題目來(lái)源:https://t.zsxq.com/16mobA3PV

實(shí)踐參考:

Elasticsearch “指紋”去重機(jī)制,你實(shí)踐中用到了嗎?

方案:

使用 fingerprint 預(yù)處理器,借助已有的多個(gè)字段構(gòu)建 MD5值,然后將目標(biāo)字段設(shè)置為 _id 即可。

圖片圖片

PUT _ingest/pipeline/id-fingerprint
{
  "processors": [
    {
      "fingerprint": {
        "fields": ["file_name", "file_size"],
        "target_field": "_id",
        "method": "MD5"
      }
    }
  ]
}


DELETE test_01128
PUT test_01128
{
  "settings": {
    "default_pipeline": "id-fingerprint"
  },
  "mappings": {
    "properties": {
      "file_name": {
        "type": "keyword"
      },
      "id-fingerprint": {
        "type": "keyword"
      }
    }
  }
}


POST test_01128/_bulk
{"index":{}}
{"file_name":"abc","file_size":"3kb"}
{"index":{}}
{"file_name":"bcd","file_size":"1kb"}
{"index":{}}
{"file_name":"abc","file_size":"3kb"}

小結(jié)

以上都是實(shí)戰(zhàn)環(huán)境遇到的典型問(wèn)題,如果你也有類似問(wèn)題,歡迎發(fā)出來(lái),咱們一起討論解決!

責(zé)任編輯:武曉燕 來(lái)源: 銘毅天下Elasticsearch
相關(guān)推薦

2023-08-02 07:21:30

工具搜索排序

2024-01-04 07:59:07

Painless腳本數(shù)據(jù)

2015-05-12 16:31:22

Elasticsear開(kāi)源分布式搜索引擎

2024-07-02 11:30:00

存儲(chǔ)壓縮算法

2014-07-04 10:37:44

Windows 8.xwindows

2014-09-05 14:32:24

操作系統(tǒng)Linux

2024-08-06 09:54:20

2023-07-17 08:21:52

漏洞版本項(xiàng)目

2011-03-16 09:55:25

2017-06-23 07:15:52

庫(kù)存ABACAS

2017-05-18 11:04:59

AIX LVM鏡像IO調(diào)優(yōu)

2012-08-27 13:25:41

面試

2012-09-04 13:53:40

面試總結(jié)面試經(jīng)歷

2018-09-11 14:45:48

云計(jì)算存儲(chǔ)安全方案

2010-09-26 15:38:33

JVM內(nèi)存泄漏

2019-10-08 16:05:19

Redis數(shù)據(jù)庫(kù)系統(tǒng)

2021-01-13 10:56:37

MybatisAPIMybatis 架構(gòu)

2014-08-26 09:40:54

圖數(shù)據(jù)數(shù)據(jù)挖掘

2009-03-19 09:53:00

IPTV多媒體網(wǎng)絡(luò)

2016-09-19 00:22:11

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)