欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

docker下遷移elasticsearch問(wèn)題以及解決方案

 更新時(shí)間:2024年11月12日 11:05:33   作者:一只牛博  
文章描述了如何將Elasticsearch數(shù)據(jù)從一個(gè)服務(wù)器遷移到另一個(gè)服務(wù)器,包括數(shù)據(jù)掛載、版本一致性、啟動(dòng)命令的匹配以及可能遇到的權(quán)限和節(jié)點(diǎn)故障問(wèn)題的解決方法

docker下遷移elasticsearch問(wèn)題及解決

直接上圖,大致就是這樣的操作

數(shù)據(jù)掛載

對(duì)于服務(wù)器A下的es如果你沒(méi)有在啟動(dòng)容器的時(shí)候?qū)?shù)據(jù)掛載出來(lái),就需要先進(jìn)行docker cp,將容器中的數(shù)據(jù)拷貝到服務(wù)器中,/usr/share/elasticsearch/data

將取出的數(shù)據(jù),或者說(shuō)掛載的數(shù)據(jù),傳輸?shù)搅硗庖粋€(gè)服務(wù)器中,執(zhí)行啟動(dòng)命令

警告:這里最好版本不要變動(dòng),以及啟動(dòng)時(shí)候的命令也和原服務(wù)器一致

至此遷移差不多就完成了。

報(bào)錯(cuò)解決

權(quán)限問(wèn)題

java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/data/nodes/0/node.lock
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixPath.toRealPath(UnixPath.java:825)
        at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:108)
        at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41)
        at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45)
        at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:229)
        at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:298)
        at org.elasticsearch.node.Node.<init>(Node.java:427)
        at org.elasticsearch.node.Node.<init>(Node.java:309)
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:234)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:234)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
        at org.elasticsearch.cli.Command.main(Command.java:77)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
For complete error details, refer to the log at /usr/share/elasticsearch/logs/docker-cluster.log

1. 節(jié)點(diǎn)鎖文件丟失:/usr/share/elasticsearch/data/nodes/0/node.lock 文件不存在??赡苁且?yàn)槲募幢徽_創(chuàng)建,或者數(shù)據(jù)目錄的權(quán)限不足,導(dǎo)致 Elasticsearch 無(wú)法寫(xiě)入。

2.  **目錄或文件權(quán)限問(wèn)題**:Elasticsearch 容器可能沒(méi)有足夠的權(quán)限訪問(wèn)或修改 /usr/share/elasticsearch/data 目錄下的文件。

解決如下:

執(zhí)行以下命令,重新啟動(dòng)即可

sudo chown -R 1000:1000 /acowbo/es   # 假設(shè)你將 /acowbo/es 掛載到 /usr/share/elasticsearch/data
sudo chmod -R 775 /acowbo/es

節(jié)點(diǎn)故障

2024-10-29 02:15:31.912 ERROR 1 --- [io-11919-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]] with root cause

根據(jù)錯(cuò)誤日志中的信息,Elasticsearch 報(bào)告了 all shards failed 和 no_shard_available_action_exception 錯(cuò)誤。

這通常表示 Elasticsearch 集群中有一個(gè)或多個(gè)分片不可用

1.執(zhí)行

curl -X GET "http://127.0.0.1:9200/_cluster/health?pretty"

這里你換為自己的ip和端口

{
  "cluster_name" : "docker-cluster",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 17,
  "active_shards" : 17,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 2,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 89.47368421052632
}

Elasticsearch 集群的 status 為 red,這表示集群中有一些分片處于未分配狀態(tài),導(dǎo)致集群不能正常工作。

特別是,你的集群中有 2 個(gè)未分配的分片(unassigned shards),這可能導(dǎo)致你遇到的 all shards failed 錯(cuò)誤。

2.執(zhí)行

curl -X GET "http://156.224.28.178:9200/_cat/shards?v&pretty"

獲取詳細(xì)信息

3.查看分片未分配的原因

curl -X GET "http://156.224.28.178:9200/_cluster/allocation/explain?pretty" -H 'Content-Type: application/json' -d '{
  "index": "acowbo_new",
  "shard": 0,
  "primary": true
}'

4.結(jié)果如下

{
  "index" : "acowbo_new",
  "shard" : 0,
  "primary" : true,
  "current_state" : "unassigned",
  "unassigned_info" : {
    "reason" : "ALLOCATION_FAILED",
    "at" : "2024-10-29T02:26:16.215Z",
    "failed_allocation_attempts" : 5,
    "details" : "failed shard on node [GoDPmTuqSBavpUAHkq6yHQ]: failed to create index, failure IllegalArgumentException[Custom Analyzer [ik_analyzer] failed to find tokenizer under name [ik_smart]]",
    "last_allocation_status" : "no"
  },
  "can_allocate" : "yes",
  "allocate_explanation" : "can allocate the shard",
  "target_node" : {
    "id" : "GoDPmTuqSBavpUAHkq6yHQ",
    "name" : "47d6ff15662f",
    "transport_address" : "172.20.0.8:9300",
    "attributes" : {
      "ml.machine_memory" : "3973206016",
      "xpack.installed" : "true",
      "transform.node" : "true",
      "ml.max_open_jobs" : "512",
      "ml.max_jvm_size" : "268435456"
    }
  },
  "allocation_id" : "kGCNR2E2SjuOTRow7OtUEA",
  "node_allocation_decisions" : [
    {
      "node_id" : "GoDPmTuqSBavpUAHkq6yHQ",
      "node_name" : "47d6ff15662f",
      "transport_address" : "172.20.0.8:9300",
      "node_attributes" : {
        "ml.machine_memory" : "3973206016",
        "xpack.installed" : "true",
        "transform.node" : "true",
        "ml.max_open_jobs" : "512",
        "ml.max_jvm_size" : "268435456"
      },
      "node_decision" : "yes",
      "store" : {
        "in_sync" : true,
        "allocation_id" : "kGCNR2E2SjuOTRow7OtUEA"
      }
    }
  ]
}

從錯(cuò)誤信息來(lái)看,分片未能分配的原因是由于自定義分析器 ik_analyzer 未能找到名為 ik_smart 的分詞器。

這通常意味著在 Elasticsearch 的設(shè)置中配置的 ik_analyzer 依賴(lài)于一個(gè)未安裝或未正確配置的分詞器。

解決如下:

  • 進(jìn)入容器
docker exec -it 容器名/容器id /bin/bash
  • 執(zhí)行
bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.16.2/elasticsearch-analysis-ik-7.16.2.zip

這里需要看你的es是什么版本的,就安裝什么版本的插件

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Docker進(jìn)階之構(gòu)建自定義鏡像實(shí)戰(zhàn)指南

    Docker進(jìn)階之構(gòu)建自定義鏡像實(shí)戰(zhàn)指南

    從docker鏡像倉(cāng)庫(kù)中下載的鏡像不能滿足我們的需求時(shí),可以對(duì)鏡像進(jìn)行更改,下面這篇文章主要給大家介紹了關(guān)于Docker進(jìn)階之構(gòu)建自定義鏡像實(shí)戰(zhàn)的相關(guān)資料,需要的朋友可以參考下
    2022-07-07
  • Docker Swarm集群管理的使用及原理解析

    Docker Swarm集群管理的使用及原理解析

    這篇文章主要介紹了Docker Swarm集群管理的使用及原理解析,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-12-12
  • Docker?compose啟動(dòng)服務(wù)遇到的問(wèn)題小結(jié)

    Docker?compose啟動(dòng)服務(wù)遇到的問(wèn)題小結(jié)

    這篇文章主要介紹了Docker?compose啟動(dòng)服務(wù)遇到的問(wèn)題小結(jié),這個(gè)是檢驗(yàn)我們的docker?compose掌握程度,因此里面的鏡像沒(méi)有提前拉取,掛載數(shù)據(jù)卷的目錄也沒(méi)有提前創(chuàng)建,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-11-11
  • 國(guó)內(nèi)服務(wù)器配置Docker國(guó)內(nèi)源(極限加速)

    國(guó)內(nèi)服務(wù)器配置Docker國(guó)內(nèi)源(極限加速)

    本文主要介紹了國(guó)內(nèi)服務(wù)器配置Docker國(guó)內(nèi)源,用戶(hù)可以在CentOS服務(wù)器上成功安裝并使用國(guó)內(nèi)鏡像加速器來(lái)提升Docker的使用,感興趣的可以了解一下
    2025-02-02
  • 記 -bash: docker-compose: command not found 的問(wèn)題解決方法

    記 -bash: docker-compose: command not&nbs

    這篇文章主要介紹了記 -bash: docker-compose: command not found 的問(wèn)題解決方法,本文給大家介紹的非常詳細(xì)對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2024-01-01
  • 如何Docker化Python Django應(yīng)用程序

    如何Docker化Python Django應(yīng)用程序

    今天小編就為大家分享一篇關(guān)于如何Docker化Python Django應(yīng)用程序的文章,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-09-09
  • Docker 網(wǎng)絡(luò)命令詳解

    Docker 網(wǎng)絡(luò)命令詳解

    這篇文章主要詳細(xì)介紹了Docker 網(wǎng)絡(luò)命令的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • docker-compose配置并部署redis服務(wù)的實(shí)現(xiàn)

    docker-compose配置并部署redis服務(wù)的實(shí)現(xiàn)

    本文主要介紹了docker-compose配置并部署redis服務(wù)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • 詳解docker compose搭建lnmpr環(huán)境實(shí)現(xiàn)

    詳解docker compose搭建lnmpr環(huán)境實(shí)現(xiàn)

    這篇文章主要為大家介紹了使用docker compose搭建lnmpr環(huán)境實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • 在Dockerfile中copy和add的區(qū)別及說(shuō)明

    在Dockerfile中copy和add的區(qū)別及說(shuō)明

    COPY和ADD都是Dockerfile中用于文件復(fù)制的命令,但COPY僅用于本地文件或目錄的復(fù)制,不支持自動(dòng)解壓縮;而ADD除了復(fù)制本地文件或目錄外,還支持解壓縮和從URL下載文件,在一般情況下,建議使用COPY命令
    2025-03-03

最新評(píng)論