侧边栏壁纸
博主头像
福福不服博主等级

孩子会穿过大雨,去懂人间的道理。

  • 累计撰写 93 篇文章
  • 累计创建 101 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Docker部署Elasticsearch集群

Monster
2023-07-15 / 0 评论 / 5 点赞 / 80 阅读 / 4780 字 / 正在检测是否收录...
温馨提示:
请确保在评论和互动中保持礼貌和尊重。避免使用侮辱性、歧视性或攻击性语言。我们鼓励建设性的讨论和意见交流。

Docker部署Elasticsearch集群

docker-compose.yml方式

编写docker-compose,vi /data/es/docker-compose.yml

version: "3.7"
services:
  es01:
    image: "elasticsearch:7.10.1"
    container_name: es01
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      node.name: es01
      discovery.seed_hosts: es01,es02,es03
      cluster.initial_master_nodes: es01,es02,es03
      cluster.name: mycluster
      ES_JAVA_OPTS: -Xms512m -Xmx512m
    volumes:
      - "es01:/usr/share/elasticsearch/data"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  es02:
    image: "elasticsearch:7.10.1"
    container_name: es02
    ports:
      - "9201:9200"
      - "9301:9300"
    environment:
      node.name: es02
      discovery.seed_hosts: es01,es02,es03
      cluster.initial_master_nodes: es01,es02,es03
      cluster.name: mycluster
      ES_JAVA_OPTS: -Xms512m -Xmx512m
    volumes:
      - "es02:/usr/share/elasticsearch/data"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  es03:
    image: "elasticsearch:7.10.1"
    container_name: es03
    ports:
      - "9202:9200"
      - "9302:9300"
    environment:
      node.name: es03
      discovery.seed_hosts: es01,es02,es03
      cluster.initial_master_nodes: es01,es02,es03
      cluster.name: mycluster
      ES_JAVA_OPTS: -Xms512m -Xmx512m
    volumes:
      - "es03:/usr/share/elasticsearch/data"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  kibana:
    image: kibana:7.10.1
    container_name: kibana
    depends_on:
      - es01
      - es02
      - es03
    ports:
      - "5601:5601"
      - "9600:9600"
    environment:
      SERVERNAME: kibana
      ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]'
      ES_JAVA_OPTS: -Xmx512m -Xms512m
volumes:
  es01: {}
  es02: {}
  es03: {}

启动docker compose -f docker-compose2.yml up -d

[root@postgresql es]# docker compose -f docker-compose2.yml up -d
[+] Building 0.0s (0/0)                                                                                                                                             
[+] Running 7/7
 ✔ Volume "es_es01"  Created                                                                                                                                   0.0s 
 ✔ Volume "es_es02"  Created                                                                                                                                   0.0s 
 ✔ Volume "es_es03"  Created                                                                                                                                   0.0s 
 ✔ Container es03    Started                                                                                                                                   0.6s 
 ✔ Container es01    Started                                                                                                                                   0.6s 
 ✔ Container es02    Started                                                                                                                                   0.6s 
 ✔ Container kibana  Started                                                                                                                                   1.1s 
[root@postgresql es]# 

更改kibana显示语言

和上篇文章一样的,不演示操作了

Elasticsearch安装分词器

和上篇文章一样的,不演示操作了

查看集群状态

查看集群健康状态,绿色,节点有3个

es01为主节点

把es01节点停止

 docker stop es01

es01节点挂了,es02变成了主节点

创建索引

PUT mosnter

查看索引

查看分片情况

pri和rep是不会被分配在一个节点上的

如下可以看到在es01和es03节点上

我们将es03停止运行,模拟挂了

docker stop es03

再来查看啊分片情况

被分配到es01和es02节点上了

5
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin
  3. QQ打赏

    qrcode qq

评论区