EFK-2:ElasticSearch高性能高可用架構


轉載自:https://mp.weixin.qq.com/s?__biz=MzUyNzk0NTI4MQ==&mid=2247483811&idx=1&sn=a413dea65f8f64abb24d82feea55db5b&chksm=fa769a8dcd01139b1da8794914e10989c6a39a99971d8013e9d3b26766b80d5833e2fbaf0ab8&mpshare=1&scene=1&srcid=1125tjbylqn3EdoMtaX2p73J&sharer_sharetime=1574686271229&sharer_shareid=6ec87ec9a11a0c18d61cde7663a9ef87#rd

闡述了EFK的data/ingest/master角色的用途及分別部署三節點,在實現性能最大化的同時保障高可用

elasticsearch-data

安裝

3台均執行相同的安裝步驟

    tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

    mv elasticsearch-7.3.2 /opt/elasticsearch

    useradd elasticsearch -d /opt/elasticsearch -s /sbin/nologin

    mkdir -p /opt/logs/elasticsearch

    chown elasticsearch.elasticsearch /opt/elasticsearch -R

    chown elasticsearch.elasticsearch /opt/logs/elasticsearch -R

    # 數據盤需要elasticsearch寫權限

    chown elasticsearch.elasticsearch /data/SAS -R


    # 限制一個進程可以擁有的VMA(虛擬內存區域)的數量要超過262144,不然elasticsearch會報max virtual memory areas vm.max_map_count [65535] is too low, increase to at least [262144]

    echo "vm.max_map_count = 655350" >> /etc/sysctl.conf

    sysctl -p

elasticsearch-data配置

# 192.168.1.51 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.51

    # 數據盤位置,如果有多個硬盤位置,用","隔開

    path.data: /data/SAS

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.51


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 關閉ingest功能

    node.ingest: false

    # 開啟data功能

    node.data: true

# 192.168.1.52 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.52

    # 數據盤位置,如果有多個硬盤位置,用","隔開

    path.data: /data/SAS

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.52


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 關閉ingest功能

    node.ingest: false

    # 開啟data功能

    node.data: true

# 192.168.1.53 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.53

    # 數據盤位置,如果有多個硬盤位置,用","隔開

    path.data: /data/SAS

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.53


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 關閉ingest功能

    node.ingest: false

    # 開啟data功能

    node.data: true

elasticsearch-data啟動

    sudo -u elasticsearch /opt/elasticsearch/bin/elasticsearch

elasticsearch集群狀態

    curl "http://192.168.1.31:9200/_cat/health?v"

elasticsearch-data狀態

    curl "http://192.168.1.31:9200/_cat/nodes?v"

elasticsearch-data參數說明

    status: green  # 集群健康狀態

    node.total: 6  # 有6台機子組成集群

    node.data: 6  # 有6個節點的存儲

    node.role: d  # 只擁有data角色

    node.role: i  # 只擁有ingest角色

    node.role: m  # 只擁有master角色

    node.role: mid  # 擁master、ingest、data角色

elasticsearch-ingest

新增三台ingest節點加入集群,同時關閉master和data功能

elasticsearch-ingest安裝

3台es均執行相同的安裝步驟

    tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

    mv elasticsearch-7.3.2 /opt/elasticsearch

    useradd elasticsearch -d /opt/elasticsearch -s /sbin/nologin

    mkdir -p /opt/logs/elasticsearch

    chown elasticsearch.elasticsearch /opt/elasticsearch -R

    chown elasticsearch.elasticsearch /opt/logs/elasticsearch -R


    # 限制一個進程可以擁有的VMA(虛擬內存區域)的數量要超過262144,不然elasticsearch會報max virtual memory areas vm.max_map_count [65535] is too low, increase to at least [262144]

    echo "vm.max_map_count = 655350" >> /etc/sysctl.conf

    sysctl -p

elasticsearch-ingest配置

# 192.168.1.41 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.41

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.41


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 開啟ingest功能

    node.ingest: true

    # 關閉data功能

    node.data: false

# 192.168.1.42 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.42

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.42


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 開啟ingest功能

    node.ingest: true

    # 關閉data功能

    node.data: false

# 192.168.1.43 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.43

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.43


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    # 關閉master功能

    node.master: false

    # 開啟ingest功能

    node.ingest: true

    # 關閉data功能

    node.data: false

elasticsearch-ingest啟動

    sudo -u elasticsearch /opt/elasticsearch/bin/elasticsearch

elasticsearch集群狀態

    curl "http://192.168.1.31:9200/_cat/health?v"

elasticsearch-ingest狀態

    curl "http://192.168.1.31:9200/_cat/nodes?v"

elasticsearch-ingest參數說明

    status: green  # 集群健康狀態

    node.total: 9  # 有9台機子組成集群

    node.data: 6  # 有6個節點的存儲

    node.role: d  # 只擁有data角色

    node.role: i  # 只擁有ingest角色

    node.role: m  # 只擁有master角色

    node.role: mid  # 擁master、ingest、data角色

elasticsearch-master

首先,將上一篇《EFK-1》中部署的3台es(192.168.1.31、192.168.1.32、192.168.1.33)改成只有master的功能, 因此需要先將這3台上的索引數據遷移到本次所做的data節點中

索引遷移

一定要做這步,將之前的索引放到data節點上

    curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'
    {
      "index.routing.allocation.include._ip": "192.168.1.51,192.168.1.52,192.168.1.53"
    }'

確認當前索引存儲位置

確認所有索引不在192.168.1.31、192.168.1.32、192.168.1.33節點上

    curl "http://192.168.1.31:9200/_cat/shards?h=n"

elasticsearch-master配置

注意事項:修改配置,重啟進程,需要一台一台執行,要確保第一台成功后,再執行下一台。

# 192.168.1.31 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.31

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.31


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    #開啟master功能

    node.master: true

    #關閉ingest功能

    node.ingest: false

    #關閉data功能

    node.data: false

# 192.168.1.32 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.32

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.32


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    #開啟master功能

    node.master: true

    #關閉ingest功能

    node.ingest: false

    #關閉data功能

    node.data: false

# 192.168.1.33 /opt/elasticsearch/config/elasticsearch.yml
    cluster.name: my-application

    node.name: 192.168.1.33

    path.logs: /opt/logs/elasticsearch

    network.host: 192.168.1.33


    discovery.seed_hosts: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    cluster.initial_master_nodes: ["192.168.1.31","192.168.1.32","192.168.1.33"]

    http.cors.enabled: true

    http.cors.allow-origin: "*"


    #開啟master功能

    node.master: true

    #關閉ingest功能

    node.ingest: false

    #關閉data功能

    node.data: false

elasticsearch集群狀態

    curl "http://192.168.1.31:9200/_cat/health?v"

elasticsearch-master狀態

    curl "http://192.168.1.31:9200/_cat/nodes?v"

至此,當node.role里所有服務器都不再出現“mid”,則表示一切順利完成。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM