最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

elasticsearch?組件基于單機(jī)的多實(shí)例集群部署方法

 更新時(shí)間:2024年03月26日 10:34:37   作者:終點(diǎn)就在前方  
es 作為搜索引擎,應(yīng)用場(chǎng)景不乏日志分析、網(wǎng)絡(luò)安全、搜索引擎等,有時(shí)也會(huì)用作日志數(shù)據(jù)庫(kù)使用,畢竟其出色的搜索查詢性能,不是同等量級(jí) 關(guān)系型數(shù)據(jù)庫(kù)可以比擬的,這篇文章主要介紹了elasticsearch?組件基于單機(jī)的多實(shí)例集群,需要的朋友可以參考下

聲明:
本示例主要作為測(cè)試用,生產(chǎn)請(qǐng)慎重。

最近公司突發(fā)奇想,想讓我們搞個(gè)單機(jī)多實(shí)例的 es 的集群,看看其性能咋樣。通常來(lái)說(shuō),es 作為搜索引擎,應(yīng)用場(chǎng)景不乏日志分析、網(wǎng)絡(luò)安全、搜索引擎等,有時(shí)也會(huì)用作日志數(shù)據(jù)庫(kù)使用,畢竟其出色的搜索查詢性能,不是同等量級(jí) 關(guān)系型數(shù)據(jù)庫(kù)可以比擬的,主要還是因?yàn)槠?倒排索引 的特殊性,這里不討論 倒排索引 與 B+ Tree 的性能,我們主要看看這種集群怎么組建的。

環(huán)境準(zhǔn)備:

  • ubuntu,24核,64G
  • docker 20.10.2

因?yàn)槭?es 集群,我們準(zhǔn)備通過(guò) docker 來(lái)創(chuàng)建實(shí)例,所以之前你還得先 pull es、kibana 的 image:

docker pull elasticsearch:6.8.23
docker pull kibana:6.8.23

如果你的容器有限,可以直接通過(guò)腳本運(yùn)行 docker run,但是如果容器數(shù)量多還有相關(guān)依賴,建議通過(guò) 容器編排 起容器,當(dāng)然數(shù)量更大的情況下,建議通過(guò) k8s 部署。

我們的集群主要包含 3 個(gè) es 節(jié)點(diǎn),外加一個(gè) kibana 作為觀測(cè),所以通過(guò) docker-compose 作為容器編排,相對(duì)合適。

接下來(lái)是我們的編排定義:
docker-compose.yml

version: "2.3"
services:
  es-0:
    image: elasticsearch:6.8.23
    hostname: es-0
    container_name: es-0
    environment:
      - bootstrap.memory_lock=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    cap_add:
      - IPC_LOCK
    volumes:
      - /var/xxx/es_cluster/es-0:/usr/share/elasticsearch/data # 容器數(shù)據(jù)映射
      - ./es_cluster/es-0/elasticsearch:/etc/default/elasticsearch # elasticsearch 文件映射
      - ./es_cluster/es-0/config:/usr/share/elasticsearch/config # 配置映射,主要是 elasticsearch.yaml 和 jvm.options
      - /var/log/es_cluster/es-0/logs:/usr/share/elasticsearch/logs # 日志映射
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime # 時(shí)間
      - /etc/timezone:/etc/timezone
      #- ./elasticsearch/jvm.options:/etc/elasticsearch/jvm.options
    ports:
      - "9200:9200" # 端口映射
    command: elasticsearch
    logging:
      options:
        max-size: "200M"
        max-file: "5"
    networks:
      app_net:
        ipv4_address: 172.238.238.219
    healthcheck:
        test: ["CMD", "curl", "-f", "-s", "http://172.238.238.219:9200/_cluster/health?wait_for_status=yellow&timeout=50s"]
        interval: 30s
        timeout: 10s
        retries: 20
    restart: always
  es-1:
    image: elasticsearch:6.8.23
    hostname: es-1
    container_name: es-1
    environment:
      - bootstrap.memory_lock=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    cap_add:
      - IPC_LOCK
    volumes:
      - /var/xxx/es_cluster/es-1:/usr/share/elasticsearch/data
      - ./es_cluster/es-1/elasticsearch:/etc/default/elasticsearch
      - ./es_cluster/es-1/config:/usr/share/elasticsearch/config
      - /var/log/es_cluster/es-1/logs:/usr/share/elasticsearch/logs
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
      - /etc/timezone:/etc/timezone
      #- ./elasticsearch/jvm.options:/etc/elasticsearch/jvm.options
    ports:
      - "9201:9201"
    command: elasticsearch
    logging:
      options:
        max-size: "200M"
        max-file: "5"
    networks:
      app_net:
        ipv4_address: 172.238.238.229
    healthcheck:
      test: ["CMD", "curl", "-f", "-s", "http://172.238.238.229:9200/_cluster/health?wait_for_status=yellow&timeout=50s"]
      interval: 30s
      timeout: 10s
      retries: 20
    restart: always
  es-2:
    image: elasticsearch:6.8.23
    hostname: es-2
    container_name: es-2
    environment:
      - bootstrap.memory_lock=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    cap_add:
      - IPC_LOCK
    volumes:
      - /var/xxx/es_cluster/es-2:/usr/share/elasticsearch/data
      - ./es_cluster/es-2/elasticsearch:/etc/default/elasticsearch
      - ./es_cluster/es-2/config:/usr/share/elasticsearch/config
      - /var/log/es_cluster/es-2/logs:/usr/share/elasticsearch/logs
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
      - /etc/timezone:/etc/timezone
      #- ./elasticsearch/jvm.options:/etc/elasticsearch/jvm.options
    ports:
      - "9202:9202"
    command: elasticsearch
    logging:
      options:
        max-size: "200M"
        max-file: "5"
    networks:
      app_net:
        ipv4_address: 172.238.238.239
    healthcheck:
      test: ["CMD", "curl", "-f", "-s", "http://172.238.238.239:9200/_cluster/health?wait_for_status=yellow&timeout=50s"]
      interval: 30s
      timeout: 10s
      retries: 20
    restart: always
  kibana:
    image: kibana:6.8.23
    hostname: kibana
    container_name: kibana
    volumes:
      - ./kibana/kibana.yml:/usr/share/kibana/config/kibana.yml
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
      - /etc/timezone:/etc/timezone
      - ./kibana/kibana.keystore:/usr/share/kibana/data/kibana.keystore
    ports:
      - "5601:5601"
    networks:
      app_net:
        ipv4_address: 172.238.238.242
    restart: always
    logging:
      options:
        max-size: "200M"
        max-file: "5"
networks:
  app_net:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 172.238.238.0/24

這里限定 docker 的網(wǎng)絡(luò)網(wǎng)段。

然后我們要看看對(duì)應(yīng)的其他準(zhǔn)備。

主要看我們的對(duì)應(yīng)到主機(jī)中的 data 目錄,所以參考 yml 中的相關(guān)映射,注意創(chuàng)建相關(guān)目錄。

這里我們主要看看相關(guān)的 elasticsearch.yaml 和 jvm.options。

elasticsearch.yml

cluster:
  name: logserver
#################
node.name: es-0 # 其他節(jié)點(diǎn)類似,修改 node name
discovery.zen.ping.unicast.hosts: ["es-0", "es-1", "es-2"]
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
http.port: 9200
transport.tcp.port: 9300
node.master: true
node.data: true
http.host: 0.0.0.0
http:
  enabled: true
  compression: true
  cors:
    enabled: true
    allow-origin: "*"
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
path.data: /usr/share/elasticsearch/data
#cluster.routing.allocation.disk.threshold_enabled: true
#cluster.routing.allocation.disk.watermark.flood_stage: 80gb
#cluster.routing.allocation.disk.watermark.high: 100gb
#cluster.routing.allocation.disk.watermark.low: 120gb
##Lock memory, do not write swap
#bootstrap.mlockall: true
##The cache type is set to Soft Reference,
##and is reclaimed only if there is not enough memory
#index.cache.field.max_size: 50000
#index.cache.field.expire: 10m
#index.cache.field.type: soft
##Weighing the performance of the index and the timeliness of retrieval
#index.translog.flush_threshold_ops: 10000
#index.refresh_interval: 1
#number_of_replicas: 0
#indices.lifecycle.poll_interval: 5m
xpack.ml.enabled: false

jvm.options

...
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms16g # 主機(jī)內(nèi)存64G,每個(gè)實(shí)例分配16G
-Xmx16g
################################################################
## Expert settings
################################################################
##
...

這兩個(gè)文件按照上面內(nèi)容修改。

接下來(lái)是 kibana.yml:

...
elasticsearch.url: "http://172.xxx.xxx.xxx:9200" # 根據(jù)實(shí)際情況,填入自己的主機(jī)ip
...

接下來(lái)通過(guò) docker-compose 命令就可以起容器了。

docker-compsoe up -d # 后臺(tái)運(yùn)行容器
docker-compose ps # 查看容器運(yùn)行狀態(tài)
docker-compose down # 停掉容器

接下來(lái)看看容器狀態(tài):

# docker-compose ps
 Name               Command                  State                         Ports
---------------------------------------------------------------------------------------------------
es-0     /usr/local/bin/docker-entr ...   Up (healthy)   0.0.0.0:9200->9200/tcp, 9300/tcp
es-1     /usr/local/bin/docker-entr ...   Up (healthy)   9200/tcp, 0.0.0.0:9201->9201/tcp, 9300/tcp
es-2     /usr/local/bin/docker-entr ...   Up (healthy)   9200/tcp, 0.0.0.0:9202->9202/tcp, 9300/tcp
kibana   /usr/local/bin/kibana-docker     Up             0.0.0.0:5601->5601/tcp

通過(guò) kibana 查看容器狀態(tài):

其他看板:

可以看到,es 集群已經(jīng)順利起來(lái)了,集群實(shí)例就演示到這里,希望對(duì)你有用。

到此這篇關(guān)于elasticsearch 組件基于單機(jī)的多實(shí)例集群的文章就介紹到這了,更多相關(guān)elasticsearch 單機(jī)多實(shí)例集群內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Docker數(shù)據(jù)備份恢復(fù)實(shí)現(xiàn)過(guò)程詳解

    Docker數(shù)據(jù)備份恢復(fù)實(shí)現(xiàn)過(guò)程詳解

    這篇文章主要介紹了Docker數(shù)據(jù)備份恢復(fù)實(shí)現(xiàn)過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • docker import 命令的使用

    docker import 命令的使用

    本文主要介紹了docker import 命令的使用,與 docker load 不同,docker import 可以從容器快照中創(chuàng)建新的鏡像,而不需要保留鏡像的歷史和元數(shù)據(jù),下面就來(lái)了解一下
    2025-04-04
  • docker容器commit打包越來(lái)越大的原因分析及解決

    docker容器commit打包越來(lái)越大的原因分析及解決

    文章介紹了Docker容器打包變大的原因,并提供了解決方法,具體步驟包括使用export命令導(dǎo)出容器,然后使用import命令導(dǎo)入鏡像,最后將鏡像展開成容器,這種方法可以有效減少鏡像文件的大小,避免因Docker鏡像層的概念導(dǎo)致的文件膨脹問(wèn)題
    2025-03-03
  • docker容器中無(wú)法獲取宿主機(jī)hostname的解決方案

    docker容器中無(wú)法獲取宿主機(jī)hostname的解決方案

    這篇文章主要介紹了docker容器中無(wú)法獲取宿主機(jī)hostname的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-03-03
  • 使用DockerFile構(gòu)建鏡像與鏡像上傳的實(shí)現(xiàn)步驟

    使用DockerFile構(gòu)建鏡像與鏡像上傳的實(shí)現(xiàn)步驟

    本文主要介紹了使用DockerFile構(gòu)建鏡像與鏡像上傳的實(shí)現(xiàn)步驟,使用Dockerfile好處是自動(dòng)化構(gòu)建,確保環(huán)境的一致性和可重復(fù)性,跟蹤構(gòu)建過(guò)程的演化等,文中通過(guò)圖文講解的非常詳細(xì),需要的朋友可以參考下
    2024-02-02
  • CentOS?8安裝Docker的詳細(xì)教程

    CentOS?8安裝Docker的詳細(xì)教程

    本文詳細(xì)講解了CentOS?8安裝Docker的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-12-12
  • Docker搭建 Nginx+PHP+MySQL 環(huán)境并部署WordPress實(shí)踐

    Docker搭建 Nginx+PHP+MySQL 環(huán)境并部署WordPress實(shí)踐

    本文給大家分享的是作者基于Docker搭建 Nginx+PHP+MySQL 環(huán)境并部署WordPress的詳細(xì)過(guò)程,非常的全面,有需要的小伙伴可以參考下
    2017-02-02
  • 手把手教你實(shí)現(xiàn)給Docker開啟IPv6網(wǎng)絡(luò)支持

    手把手教你實(shí)現(xiàn)給Docker開啟IPv6網(wǎng)絡(luò)支持

    這篇文章主要為大家介紹了Docker開啟IPv6網(wǎng)絡(luò)支持實(shí)現(xiàn)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • docker compose安裝etcd的詳細(xì)過(guò)程

    docker compose安裝etcd的詳細(xì)過(guò)程

    這篇文章主要介紹了docker compose安裝etcd的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • docker構(gòu)建的鏡像的三種方式小結(jié)

    docker構(gòu)建的鏡像的三種方式小結(jié)

    這篇文章主要為大家詳細(xì)介紹了docker中構(gòu)建的鏡像的三種方式,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,有需要的小伙伴可以參考一下
    2024-04-04

最新評(píng)論

泰来县| 安吉县| 澄城县| 武夷山市| 当雄县| 海淀区| 乌拉特后旗| 方城县| 开化县| 桑日县| 阿克陶县| 文化| 松潘县| 小金县| 光山县| 应用必备| 清流县| 湾仔区| 嘉鱼县| 喀什市| 雅江县| 开封市| 遂平县| 桦川县| 远安县| 三河市| 嘉祥县| 承德县| 济阳县| 潼关县| 明光市| 赤峰市| 双峰县| 诸暨市| 武功县| 贵溪市| 南川市| 繁峙县| 临泉县| 云浮市| 襄垣县|