Upgrade Elasticsearch7.5.0

  1. Elasticsearch7.5.0安裝

    切換到root用戶

    sudo su -

    配置elasticsearch用戶

    usermod -s /bin/bash elasticsearch

    創(chuàng)建數(shù)據(jù)和日志目錄

    mkdir /var/log/elasticsearch7.5.0
    mkdir /data/elasticsearch7.5.0

    分配給elasticsearch用戶

    chown -R elasticsearch:elasticsearch /var/log/elasticsearch7.5.0
    chown -R elasticsearch:elasticsearch /data/elasticsearch7.5.0

    下載安裝

    cd /opt
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz
    tar zxvf elasticsearch-7.5.0-linux-x86_64.tar.gz
    chown -R elasticsearch elasticsearch-7.5.0

  2. 修改配置文件

    1. GIS單節(jié)點(diǎn) /opt/elasticsearch-7.5.0/config/elasticsearch.yml 供參考

      cluster.name: gis_es
      node.name: gis-es-1.novalocal
      node.attr.rack: rc-1
      path.data: /data/elasticsearch7.5.0
      path.logs: /var/log/elasticsearch7.5.0
      bootstrap.memory_lock: true
      network.host: ...
      http.port: 9201
      transport.tcp.port: 9301
      cluster.initial_master_nodes: ["gis_es"]
      reindex.remote.whitelist: ...:9200

    2. Trip 集群es-traffic-mgmt-1節(jié)點(diǎn) /opt/elasticsearch-7.5.0/config/elasticsearch.yml 供參考

      cluster.name: trip-traffic_es
      node.name: es-traffic-mgmt-1.novalocal
      node.attr.rack: rc-1
      path.data: /data/elasticsearch7.5.0
      path.logs: /var/log/elasticsearch7.5.0
      bootstrap.memory_lock: true
      network.host: ...
      http.port: 9201
      transport.tcp.port: 9301
      discovery.seed_hosts: ["...:9301", "...:9301"]
      cluster.initial_master_nodes: ["es-traffic-mgmt-1", "es-trip-mgmt-1"]
      reindex.remote.whitelist: ...:9200

    3. Trip 集群es-trip-mgmt-1節(jié)點(diǎn) /opt/elasticsearch-7.5.0/config/elasticsearch.yml 供參考

      cluster.name: trip-traffic_es
      node.name: es-trip-mgmt-1.novalocal
      node.attr.rack: rc-1
      path.data: /data/elasticsearch7.5.0
      path.logs: /var/log/elasticsearch7.5.0
      bootstrap.memory_lock: true
      network.host: ...
      http.port: 9201
      transport.tcp.port: 9301
      discovery.seed_hosts: ["...:9301", "...:9301"]
      cluster.initial_master_nodes: ["es-traffic-mgmt-1", "es-trip-mgmt-1"]
      reindex.remote.whitelist: ...:9200

  3. 啟動

    1. 切換到elasticsearch啟動
      su - elasticsearch
      /opt/elasticsearch-7.5.0/bin/elasticsearch -d

      如果報(bào)錯(cuò):
      ERROR: [2] bootstrap checks failed
      [1]: max number of threads [2048] for user [elasticsearch] is too low, increase to at least [4096]
      cp /etc/security/limits.d/elsearch-limit.conf /etc/security/limits.d/elsearch-limit.conf.bak
      則修改配置文件:vi /etc/security/limits.d/elsearch-limit.conf
      elasticsearch soft nproc 2048 改為 4096
      elasticsearch hard nproc 2048改為 4096

    2. 重啟命令
      找到進(jìn)程kill ps -ef |grep elasticsearch-7.5.0
      啟動 /opt/elasticsearch-7.5.0/bin/elasticsearch -d

  4. 數(shù)據(jù)遷移

    1. 主要使用官方自帶的Reindex from a remote cluster
      參考:https://www.elastic.co/guide/en/elasticsearch/reference/7.5/reindex-upgrade-remote.html

    2. 但是遷移數(shù)據(jù)前需要手工在es7.5創(chuàng)建好索引,所以新建python3腳本來創(chuàng)建索引和遷移數(shù)據(jù)

    3. 運(yùn)行腳本時(shí)候,很有可能報(bào)錯(cuò)”maximum shards open“則修改max_shards_per_node

    4. |

      curl -X PUT ``"127.0.0.1:9201/_cluster/settings" -H ``'Content-Type: application/json' -d'

      {

      "persistent" : {

      "cluster.max_shards_per_node" : ``"2000"

      }

      }

      '

      |

    5. 修改腳本中的3行,替換腳本中的127.0.0.1 為具體的ip

      reindex_py3.py 展開源碼

      <pre style="margin: 0px; padding: 0px; font-family: ConfluenceInstalledFont, monospace;">es_old ip port 必須與 /opt/elasticsearch-7.5.0/config/elasticsearch.yml 中的 reindex.remote.whitelist: <address>:<port> 保持一致,如必須同為 127.0.0.1:9200 或者localhost:9200, 不能一個(gè)用localhost 另一個(gè)用127.0.0.1</pre>

      ES7.5.0 默認(rèn)內(nèi)存是1G, 導(dǎo)入可能報(bào)錯(cuò), 需要修改 /opt/elasticsearch-7.5.0/config/jvm.options, 根據(jù)vm 內(nèi)存進(jìn)行調(diào)整,內(nèi)存過大可能導(dǎo)致機(jī)器無法使用

      |

      -Xms3g

      -Xmx3g

      |

      Error log

      |

      elasticsearch.exceptions.TransportError: TransportError(``429``, ``'circuit_breaking_exception'``, ``'[parent] Data too large, data for [<http_request>] would be [1023885146/976.4mb], which is larger than the limit of [1003493785/957mb], real usage: [1023865048/976.4mb], new bytes reserved: [20098/19.6kb], usages [request=0/0b, fielddata=0/0b, in_flight_requests=20098/19.6kb, accounting=20440594/19.4mb]'``)

      |

  5. 驗(yàn)證結(jié)果

    1. 打開es7.5.0 查看索引“.tasks“數(shù)據(jù),記錄了Reindex 的結(jié)果。
  6. 配置為系統(tǒng)服務(wù)

    1. 待補(bǔ)充
  7. 停止舊版本ES服務(wù)

    1. root用戶 systemctl stop elasticsearch
  8. 多類型索引更新
    因?yàn)榕f版本支持一個(gè)索引包含多個(gè)type,而新版本一個(gè)索引建議只包含一個(gè)type,所以舊版本包含多個(gè)type的所以需要拆分多個(gè)新索引再同步數(shù)據(jù)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容