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

docker部署ES集群的實現(xiàn)

 更新時間:2024年10月13日 10:39:06   作者:阿額火熱  
本文介紹了如何在Ubuntu20.04.2 LTS環(huán)境下通過Docker部署Elasticsearch7.10.1集群,詳細(xì)步驟包括從Docker鏡像倉庫拉取Elasticsearch鏡像,創(chuàng)建文件映射目錄,運行Docker容器,配置Elasticsearch的端口和權(quán)限,以及集群的相關(guān)設(shè)置,感興趣的可以了解一下

一. 安裝環(huán)境說明

Ubuntu 20.04.2 LTS

elasticsearch 7.10.1

二. 從docker鏡像倉庫拉取es鏡像

docker pull elasticsearch:7.10.1

若鏡像拉取不到可以使用騰訊云的docker鏡像源https://mirror.ccs.tencentyun.com

三. 創(chuàng)建文件映射目錄

# 在當(dāng)前用戶下創(chuàng)建es集群文件夾
mkdir ./elasticsearch
# 該集群共創(chuàng)建三個節(jié)點 分別是es-master、es-node01、es-node02
# 為這三個節(jié)點分別創(chuàng)建數(shù)據(jù)和插件映射文件夾
cd elasticsearch
mkdir ./es-{master,node01,node02} ./es-{master,node01,node02}/data ./es-{master,node01,node02}/plugins
# 授予文件夾訪問權(quán)限
chmod 777 ./es-{master,node01,node02}/data ./es-{master,node01,node02}/plugins

四. 運行docker容器

#master
docker run -d \
    --name=es-master \
    --restart=always \
    -e "http.host=0.0.0.0" \
    -e "ES_JAVA_OPTS=-Xms4g -Xmx4g" \
    -e "cluster.name=es-cluster" \
    -e "cluster.initial_master_nodes=es-master" \
    -v /etc/localtime:/etc/localtime \
    -v /home/ubuntu/elasticsearch/es-master/data:/usr/share/elasticsearch/data \
    -v /home/ubuntu/elasticsearch/es-master/plugins:/usr/share/elasticsearch/plugins \
    -p 9200:9200 \
    -p 9300:9300 \
    elasticsearch:7.10.1
    
#01
docker run -d \
    --name=es-node01 \
    --restart=always \
    -e "http.host=0.0.0.0" \
    -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" \
    -e "cluster.name=es-cluster" \
    -e "cluster.initial_master_nodes=es-master" \
    -v /etc/localtime:/etc/localtime \
    -v /home/ubuntu/elasticsearch/es-node01/data:/usr/share/elasticsearch/data \
    -v /home/ubuntu/elasticsearch/es-node01/plugins:/usr/share/elasticsearch/plugins \
    -p 9201:9201 \
    -p 9301:9301 \
    elasticsearch:7.10.1
    
#02
docker run -d \
    --name=es-node02 \
    --restart=always \
    -e "http.host=0.0.0.0" \
    -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" \
    -e "cluster.name=es-cluster" \
    -e "cluster.initial_master_nodes=es-master" \
    -v /etc/localtime:/etc/localtime \
    -v /home/ubuntu/elasticsearch/es-node02/data:/usr/share/elasticsearch/data \
    -v /home/ubuntu/elasticsearch/es-node02/plugins:/usr/share/elasticsearch/plugins \
    -p 9202:9202 \
    -p 9302:9302 \
    elasticsearch:7.10.1

docker ps 查看啟動狀態(tài)

Elasticsearch 的 9200 端口和 9300 端口分別承擔(dān)著不同的職責(zé):

9200 端口

  • 用途:9200 端口主要用于 HTTP 協(xié)議的 RESTful 接口,允許客戶端通過 HTTP 協(xié)議與 Elasticsearch 進(jìn)行交互。
  • 功能:
    • 提供了一個 RESTful API,用于執(zhí)行 CRUD(創(chuàng)建、讀取、更新、刪除)操作。
    • 支持查詢、索引管理和集群管理等功能。
    • 通常用于客戶端應(yīng)用、Web 界面(如 Kibana)或任何希望與 Elasticsearch 交互的應(yīng)用程序。

9300 端口

  • 用途:9300 端口主要用于節(jié)點間的 TCP 通信,是 Elasticsearch 集群內(nèi)部通信的基礎(chǔ)。
  • 功能:
    • 用于 Elasticsearch 節(jié)點之間的通信,包括數(shù)據(jù)傳輸、心跳檢測等。
    • 支持集群發(fā)現(xiàn)和節(jié)點加入集群的過程。
    • 通常用于集群內(nèi)部節(jié)點之間的通信,而不是客戶端直接使用。

啟動出現(xiàn)的問題及解決方案

AccessDeniedException[/usr/share/elasticsearch/data/nodes]

映射文件夾沒有權(quán)限,通過chmod授予文件夾權(quán)限即可

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
虛擬內(nèi)存限制:vm.max_map_count 的值太低,需要增加到至少 262144。

1). 修改系統(tǒng)參數(shù):

2). 使更改生效:

3). 驗證設(shè)置:

在宿主機(jī)上編輯 /etc/sysctl.conf 文件,添加以下行:

vm.max_map_count=262144

運行以下命令使更改立即生效:

sysctl -p

查看當(dāng)前的 vm.max_map_count 設(shè)置:

cat /proc/sys/vm/max_map_count

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

發(fā)現(xiàn)設(shè)置:默認(rèn)的發(fā)現(xiàn)設(shè)置不適合生產(chǎn)使用,需要配置至少一個 discovery.seed_hostsdiscovery.seed_providers 或 cluster.initial_master_nodes。

配置 cluster.initial_master_nodes

為 es-master 節(jié)點配置 cluster.initial_master_nodes,使其知道哪些節(jié)點可以成為主節(jié)點。

五. 生成證書

# 進(jìn)入master容器
docker exec -it es-master bash
# 進(jìn)入bin目錄
cd bin
# 執(zhí)行生成證書命令并一路回車
elasticsearch-certutil cert
# 生成的證書 elastic-certificates.p12 默認(rèn)會放在當(dāng)前目錄下 即/usr/share/elasticsearch
# 將證書拷貝到config文件夾下
mv elastic-certificates.p12 ./config
# 修改證書所有者
chown elasticsearch:elasticsearch elastic-certificates.p12

將證書拷貝到另外兩個服務(wù)的容器中

# 先將證書從當(dāng)前容器中拷貝出來
docker cp es-master:/usr/share/elasticsearch/config/elastic-certificates.p12 ./
# 將證書拷貝到目標(biāo)容器中并修改所有者(需進(jìn)入容器修改,命令略)
docker cp ./elastic-certificates.p12 es-node01:/usr/share/elasticsearch/config
docker cp ./elastic-certificates.p12 es-node02:/usr/share/elasticsearch/config

六. 修改 elasticsearch.yml文件

進(jìn)入es容器,編輯elasticsearch.yml文件

docker exec -it es-master bash
vi /usr/share/elasticsearch/config/elasticsearch.yml

三個容器的配置分別為(根據(jù)實際情況修改ip地址):

master

cluster.name: "es-cluster"
network.host: 0.0.0.0
network.publish_host: 127.0.0.1
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.name: es-master
node.master: true
node.data: false
node.ingest: false

indices.queries.cache.size: 5%
indices.fielddata.cache.size: 5%
indices.breaker.fielddata.limit: 70%
indices.breaker.request.limit: 60%
indices.breaker.total.limit: 90%

http.max_content_length: 200m

discovery.zen.ping_timeout: 10s
discovery.zen.fd.ping_timeout: 10000s
discovery.zen.fd.ping_retries: 10
discovery.zen.minimum_master_nodes: 1

discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9302","127.0.0.1:9303"]
cluster.initial_master_nodes: ["es-master"]

# 添加xpack證書配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.client_authentication: required
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

node01

cluster.name: "es-cluster"
network.host: 0.0.0.0
network.publish_host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.name: es-node01
node.master: false
node.data: true
node.ingest: true

indices.queries.cache.size: 5%
indices.fielddata.cache.size: 5%
indices.breaker.fielddata.limit: 70%
indices.breaker.request.limit: 60%
indices.breaker.total.limit: 90%

http.max_content_length: 200m

discovery.zen.ping_timeout: 10s
discovery.zen.fd.ping_timeout: 10000s
discovery.zen.fd.ping_retries: 10
discovery.zen.minimum_master_nodes: 1

discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"]
cluster.initial_master_nodes: ["es-master"]

# 添加xpack證書配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.client_authentication: required
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

node02

cluster.name: "es-cluster"
network.host: 0.0.0.0
network.publish_host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.name: es-node02
node.master: false
node.data: true
node.ingest: true

indices.queries.cache.size: 5%
indices.fielddata.cache.size: 5%
indices.breaker.fielddata.limit: 70%
indices.breaker.request.limit: 60%
indices.breaker.total.limit: 90%

http.max_content_length: 200m

discovery.zen.ping_timeout: 10s
discovery.zen.fd.ping_timeout: 10000s
discovery.zen.fd.ping_retries: 10
discovery.zen.minimum_master_nodes: 1

discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"]
cluster.initial_master_nodes: ["es-master"]

# 添加xpack證書配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.client_authentication: required
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

七. 重啟服務(wù)

docker restart es-master
docker restart es-node01
docker restart es-node02

八. 修改默認(rèn)密碼

# 進(jìn)入es-master容器
docker exec -it es-master bash
# 執(zhí)行修改密碼命令并一次輸入密碼和確認(rèn)密碼
./bin/elasticsearch-setup-passwords interactive

在這里插入圖片描述

九. 查看集群狀態(tài)

訪問http://127.0.0.1:9200/_cluster/health?pretty 或者 http://127.0.0.1:9200/_cluster/state?pretty 查看集群狀態(tài)

{
  "cluster_name" : "es-cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 1,
  "active_shards" : 2,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}

到此這篇關(guān)于docker部署ES集群的實現(xiàn)的文章就介紹到這了,更多相關(guān)docker部署ES集群內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Docker-swarm快速搭建redis集群的方法步驟

    Docker-swarm快速搭建redis集群的方法步驟

    本文主要介紹了Docker-swarm快速搭建redis集群的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-05-05
  • docker安裝Elasticsearch7.6集群并設(shè)置密碼的方法步驟

    docker安裝Elasticsearch7.6集群并設(shè)置密碼的方法步驟

    本文主要介紹了docker安裝Elasticsearch7.6集群并設(shè)置密碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • docker 如何修改mysql的root密碼

    docker 如何修改mysql的root密碼

    這篇文章主要介紹了docker 修改mysql的root密碼操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • docker之MySQL同步數(shù)據(jù)的實現(xiàn)

    docker之MySQL同步數(shù)據(jù)的實現(xiàn)

    本文主要介紹了docker之MySQL同步數(shù)據(jù)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • 使用docker部署若依前后端分離項目全過程

    使用docker部署若依前后端分離項目全過程

    部署前端項目Docker變得越來越流行,它可以輕便靈活地隔離環(huán)境,進(jìn)行擴(kuò)容,運維管理,這篇文章主要介紹了使用docker部署若依前后端分離項目的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-12-12
  • docker?部署Flink和傳統(tǒng)部署的詳細(xì)過程

    docker?部署Flink和傳統(tǒng)部署的詳細(xì)過程

    Flink是一個開源的分布式流處理框架,支持狀態(tài)管理、事件時間、窗口模型等特性,可以通過下載、解壓、配置和啟動來使用,提供了多種運行方式,包括Docker和SQLClient,本文介紹docker部署Flink和傳統(tǒng)部署的詳細(xì)過程,感興趣的朋友跟隨小編一起看看吧
    2025-11-11
  • docker 復(fù)制容器的項目實踐

    docker 復(fù)制容器的項目實踐

    本文主要介紹了docker 復(fù)制容器的項目實踐,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-11-11
  • 為docker中的nginx配置https的方法步驟

    為docker中的nginx配置https的方法步驟

    這篇文章主要介紹了為docker中的nginx配置https的方法步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • Docker 部署Django項目的方法示例

    Docker 部署Django項目的方法示例

    這篇文章主要介紹了Docker 部署Django項目的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • Docker & Docker Compose安裝教程

    Docker & Docker Compose安裝教程

    本文詳細(xì)介紹了在Ubuntu 22.04.1 LTS系統(tǒng)上安裝和配置Docker的步驟,包括選擇合適的存儲驅(qū)動和日志驅(qū)動,生產(chǎn)級配置以及用戶權(quán)限管理,通過一系列檢查步驟和常用命令,確保Docker安裝和配置的正確性
    2026-01-01

最新評論

娄底市| 日喀则市| 庄河市| 金门县| 乌苏市| 拉萨市| 贵阳市| 沁水县| 阜城县| 闽清县| 定远县| 讷河市| 余江县| 甘德县| 竹溪县| 康定县| 综艺| 九寨沟县| 乌拉特前旗| 丽水市| 和硕县| 民乐县| 珠海市| 泗洪县| 伊春市| 德令哈市| 德令哈市| 文安县| 龙南县| 芮城县| 宁波市| 星子县| 永仁县| 双峰县| 湛江市| 汶川县| 商都县| 建宁县| 张掖市| 乐至县| 涟源市|