快速创建ES集群

news2024/11/14 16:36:22

win10 中docker 设置

image-20230709181646945

image-20230709181748560

快速创建集群

访问 官网

elasticsearch/docs/reference/setup/install/docker at main · elastic/elasticsearch · GitHub

负责上面2个文件,并修改,修改如下

.env文件

# Password for the 'elastic' user (at least 6 characters)
# 配置密码
ELASTIC_PASSWORD='elastic'

# Password for the 'kibana_system' user (at least 6 characters)
# 配置kibana密码
KIBANA_PASSWORD='elastic'

# Version of Elastic products
STACK_VERSION=8.3.3

# Set the cluster name
CLUSTER_NAME=docker-cluster

# Set to 'basic' or 'trial' to automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial

# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
#ES_PORT=127.0.0.1:9200

# Port to expose Kibana to the host
KIBANA_PORT=5601
#KIBANA_PORT=80

# Increase or decrease based on the available host memory (in bytes)
# 调整为512M
MEM_LIMIT=536870912

# Project namespace (defaults to the current folder name if not set)
#COMPOSE_PROJECT_NAME=myproject

docker-compose.yml 和官网一致

version: "2.2"

services:
  setup:
    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
    volumes:
      - certs:/usr/share/elasticsearch/config/certs
    user: "0"
    command: >
      bash -c '
        if [ x${ELASTIC_PASSWORD} == x ]; then
          echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
          exit 1;
        elif [ x${KIBANA_PASSWORD} == x ]; then
          echo "Set the KIBANA_PASSWORD environment variable in the .env file";
          exit 1;
        fi;
        if [ ! -f config/certs/ca.zip ]; then
          echo "Creating CA";
          bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip;
          unzip config/certs/ca.zip -d config/certs;
        fi;
        if [ ! -f config/certs/certs.zip ]; then
          echo "Creating certs";
          echo -ne \
          "instances:\n"\
          "  - name: es01\n"\
          "    dns:\n"\
          "      - es01\n"\
          "      - localhost\n"\
          "    ip:\n"\
          "      - 127.0.0.1\n"\
          "  - name: es02\n"\
          "    dns:\n"\
          "      - es02\n"\
          "      - localhost\n"\
          "    ip:\n"\
          "      - 127.0.0.1\n"\
          "  - name: es03\n"\
          "    dns:\n"\
          "      - es03\n"\
          "      - localhost\n"\
          "    ip:\n"\
          "      - 127.0.0.1\n"\
          > config/certs/instances.yml;
          bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
          unzip config/certs/certs.zip -d config/certs;
        fi;
        echo "Setting file permissions"
        chown -R root:root config/certs;
        find . -type d -exec chmod 750 \{\} \;;
        find . -type f -exec chmod 640 \{\} \;;
        echo "Waiting for Elasticsearch availability";
        until curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep -q "missing authentication credentials"; do sleep 30; done;
        echo "Setting kibana_system password";
        until curl -s -X POST --cacert config/certs/ca/ca.crt -u "elastic:${ELASTIC_PASSWORD}" -H "Content-Type: application/json" https://es01:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done;
        echo "All done!";
      '
    healthcheck:
      test: ["CMD-SHELL", "[ -f config/certs/es01/es01.crt ]"]
      interval: 1s
      timeout: 5s
      retries: 120

  es01:
    depends_on:
      setup:
        condition: service_healthy
    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
    volumes:
      - certs:/usr/share/elasticsearch/config/certs
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - ${ES_PORT}:9200
    environment:
      - node.name=es01
      - cluster.name=${CLUSTER_NAME}
      - cluster.initial_master_nodes=es01,es02,es03
      - discovery.seed_hosts=es02,es03
      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
      - bootstrap.memory_lock=true
      - xpack.security.enabled=true
      - xpack.security.http.ssl.enabled=true
      - xpack.security.http.ssl.key=certs/es01/es01.key
      - xpack.security.http.ssl.certificate=certs/es01/es01.crt
      - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.enabled=true
      - xpack.security.transport.ssl.key=certs/es01/es01.key
      - xpack.security.transport.ssl.certificate=certs/es01/es01.crt
      - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.verification_mode=certificate
      - xpack.license.self_generated.type=${LICENSE}
    mem_limit: ${MEM_LIMIT}
    ulimits:
      memlock:
        soft: -1
        hard: -1
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'",
        ]
      interval: 10s
      timeout: 10s
      retries: 120

  es02:
    depends_on:
      - es01
    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
    volumes:
      - certs:/usr/share/elasticsearch/config/certs
      - esdata02:/usr/share/elasticsearch/data
    environment:
      - node.name=es02
      - cluster.name=${CLUSTER_NAME}
      - cluster.initial_master_nodes=es01,es02,es03
      - discovery.seed_hosts=es01,es03
      - bootstrap.memory_lock=true
      - xpack.security.enabled=true
      - xpack.security.http.ssl.enabled=true
      - xpack.security.http.ssl.key=certs/es02/es02.key
      - xpack.security.http.ssl.certificate=certs/es02/es02.crt
      - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.enabled=true
      - xpack.security.transport.ssl.key=certs/es02/es02.key
      - xpack.security.transport.ssl.certificate=certs/es02/es02.crt
      - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.verification_mode=certificate
      - xpack.license.self_generated.type=${LICENSE}
    mem_limit: ${MEM_LIMIT}
    ulimits:
      memlock:
        soft: -1
        hard: -1
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'",
        ]
      interval: 10s
      timeout: 10s
      retries: 120

  es03:
    depends_on:
      - es02
    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
    volumes:
      - certs:/usr/share/elasticsearch/config/certs
      - esdata03:/usr/share/elasticsearch/data
    environment:
      - node.name=es03
      - cluster.name=${CLUSTER_NAME}
      - cluster.initial_master_nodes=es01,es02,es03
      - discovery.seed_hosts=es01,es02
      - bootstrap.memory_lock=true
      - xpack.security.enabled=true
      - xpack.security.http.ssl.enabled=true
      - xpack.security.http.ssl.key=certs/es03/es03.key
      - xpack.security.http.ssl.certificate=certs/es03/es03.crt
      - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.enabled=true
      - xpack.security.transport.ssl.key=certs/es03/es03.key
      - xpack.security.transport.ssl.certificate=certs/es03/es03.crt
      - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
      - xpack.security.transport.ssl.verification_mode=certificate
      - xpack.license.self_generated.type=${LICENSE}
    mem_limit: ${MEM_LIMIT}
    ulimits:
      memlock:
        soft: -1
        hard: -1
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'",
        ]
      interval: 10s
      timeout: 10s
      retries: 120

  kibana:
    depends_on:
      es01:
        condition: service_healthy
      es02:
        condition: service_healthy
      es03:
        condition: service_healthy
    image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
    volumes:
      - certs:/usr/share/kibana/config/certs
      - kibanadata:/usr/share/kibana/data
    ports:
      - ${KIBANA_PORT}:5601
    environment:
      - SERVERNAME=kibana
      - ELASTICSEARCH_HOSTS=https://es01:9200
      - ELASTICSEARCH_USERNAME=kibana_system
      - ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
      - ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt
    mem_limit: ${MEM_LIMIT}
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
        ]
      interval: 10s
      timeout: 10s
      retries: 120

volumes:
  certs:
    driver: local
  esdata01:
    driver: local
  esdata02:
    driver: local
  esdata03:
    driver: local
  kibanadata:
    driver: local

启动集群

docker compose up -d

访问es

https://localhost:9200/

访问kibana

http://localhost:5601?kibana_system

安装ik分词器

docker exec -it elasticsearch-es01-1 bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip

docker exec -it elasticsearch-es02-1 bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip

docker exec -it elasticsearch-es03-1 bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip

测试安装是否成功

POST  _analyze
{
    "analyzer":"ik_smart",
    "text":"我是中国人"
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/736090.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【私有云】网络虚拟化

前言 大家好,我是秋意零。 之前一直对 OpenStack 网络很陌生与神奇啊,不知道它是如何实现的,网络结构是怎样的。不过,今天介绍的是网络虚拟化,它在 OpenStack 中及云计算中是非常重要的概念,是理解 OpenS…

springboot整合websocket遇到的小问题

今天尝试了通过springboot整合websocket来初步学习使用websocket,然后发现启动的时候报错了,发这篇文章分享一下。 springboot整合websocket的步骤很简单: 第一步:创建一个springboot项目,在这里命名为websocket 在I…

day16 移除元素

题目描述 解题思路: 1.快慢指针,移除数组元素只能是下标操作;fast往前,不等于value的时候,赋给slow; 2.slow;返回的长度直接返回slow; int removeElement(int* nums, int numsSize, …

Rethinking the Role of Pre-ranking in Large-scale E-Commerce Searching system

来源: KDD’2023Taobao Search 文章目录 ASHASMOL训练样本训练目标蒸馏精排 总结 反思粗排在大规模电商搜索系统中的角色。 由于巨大的数据量以及对系统实时反馈的要求,一个典型的工业排序系统通常由这些模块组成:召回(matching&…

VTR编译问题

机器环境 vmware 16.0; ubuntu22.04.02; 问题描述 一、在build过程中会出现一些警告,但没有停止; 二、访问 **raw.githubsercontent.com/…/…**相关网站被拒绝,如下图: 之前在 /etc/hosts 仅仅是添加了raw.github…

JS数组解构赋值变量存在依赖关系

题目随便起的, 在刷力扣 41.缺失的第一个正数 这个题的时候,出现了解构赋值的问题, 对于[a,b] [1,2]和[b,a][2,1]按理说都是行的通的,和位置没有关系,本质上都是进行交换 可是当我在题目中 使用[nums[nums[i]-1], nu…

SpringMVC的高频面试题

2023最新版(持续更新) 一、SpringMVC的高频面试题1. SpringMVC的执行流程2. SpringMVC常见的注解有哪些? 一、SpringMVC的高频面试题 1. SpringMVC的执行流程 前置知识 视图阶段(JSP): 涉及到的重要组件:…

KubeSphere 社区双周报 | KubeSphere 多项更新 | 2023.06.23-07.06

KubeSphere 社区双周报主要整理展示新增的贡献者名单和证书、新增的讲师证书以及两周内提交过 commit 的贡献者,并对近期重要的 PR 进行解析,同时还包含了线上/线下活动和布道推广等一系列社区动态。 本次双周报涵盖时间为:2023.06.23-2023.…

管道设计专业版:Pipedata-Pro Crack

Pipedata-Pro 提高了管道设计的效率并减轻了查找管道信息的负担。它可以直观、轻松地检索最新的管道和设计数据。尺寸和重量单位可以设置为公制或美制单位。 Pipedata-Pro 于 1996 年由 Zeataline Projects 推出,现已遍布全球,Pipedata-Pro 管道表的映射…

怎么判断两个文档节点时候相同?判断两个DOM节点时候相等、相同的4种方法

方法1: document.querySelector(html) document.querySelector(html) //true 方法2:compareDocumentPosition document.querySelector(html).compareDocumentPosition(document.querySelector(html)) //0 返回0就代表相同 方法3:isEqualNode …

编译运行ContactDiscoveryService-Icelake

下载 git clone https://codeup.aliyun.com/6306306f95064d67d44656e5/lxr1907/ContactDiscoveryService-Icelake.git或github地址 git clone https://github.com/signalapp/ContactDiscoveryService-Icelake按照Readme安装 Building git submodule init git submodule update …

每次装完 homebrew,ohmyzsh 就会报错:Insecure completion-dependent directories detected:

参考:https://zhuanlan.zhihu.com/p/313037188 这是因为在big sur安装homebrew后,会在/usr/local/share/生成一个zsh文件夹,里面包含了 因此,zsh文件默认设置的权限是775,也就是group user有writer的权利,zsh认为这是…

python读写excel利器:xlwings从入门到精通

python读写excel利器:xlwings 从入门到精通 目录 安装和使用 基础操作 操作工作簿操作工作表读取单元格写入(单元格赋值)range的操作(range常用的api) 写入一行或一列Excel数据(函数式)使用range(\A1\).api.AddComment(\comments…

本质矩阵(Essential Matrix)E进行分解的过程

分解本质矩阵的过程遵循以下步骤: 使用奇异值分解(SVD)计算本质矩阵E的分解。SVD分解是一种将矩阵分解为三个矩阵的乘积的方法,它的形式为 E UΣV^T,其中U和V是正交矩阵,Σ是对角矩阵。此步骤的结果存储在…

Edge浏览器无法展示Stable Diffusion Control Net插件

Edge浏览器无法展示Stable Diffusion Control Net插件 最近在学习Stable Diffusion,需要使用到Control Net插件,结果通过各种方式安装成功插件后,浏览器页面没有展示ControlNet相关页面,最终换到Chorme浏览器后正常,猜…

【Python】绘图_pandas(1)

# -*- coding: utf-8 -*- #汉字处理 import matplotlib.pyplot as plt import numpy as np from numpy.random import randn import pandas as pd #import DataFrame from matplotlib.font_manager import FontPropertiesfont FontProperties(fnamer"c:\windows\fonts\si…

基于51单片机的电子密码锁设计

功能:本实例是基于51单片机的电子密码锁,主要硬件由51单片机最小系统,LCD1602液晶屏电路,继电器控制电路,AT24C02存储电路,LED指示灯电路,矩阵按键电路构成。 1.系统采用LCD1602液晶屏作为显示屏…

【软件设计原则】系统设计面试基础:CAP 与 PACELC

什么是 CAP 定理以及 PACELC 如何扩展它? 在分布式系统中,可能会发生不同类型的故障,例如,服务器可能会崩溃或永久故障,磁盘可能会损坏导致数据丢失,或者网络连接可能会丢失,导致系统的一部分无…

在openFoam中创建cellZone

简介 openFoam的cellZone概念十分重要,可以给一个区域的单元命名,广泛应用于设置初始场(如气、液两相流的初始VOF分布) 而cellZone通常由cellSet转化而来,本文将介绍使用cellSet定义cellZone的方法 方法 在项目的sy…

【JavaWeb】博客系统的前端页面设计

目录 前言 1、页面组成 2、实现博客列表页 🍂设置背景图片 🍂设置导航栏 🍂实现版心 🍃实现个人信息 🍃实现博客列表 3、实现博客详情页 4、编写博客的登录页 5、博客编辑页面 🍂实现标题的编辑区 …