当前位置: 首页 > article >正文

KubeSphere部署Elastisearch

docker启动命令

# 创建数据目录
mkdir -p /mydata/es-01 && chmod 777 -R /mydata/es-01

# 容器启动
docker run --restart=always -d -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v es-config:/usr/share/elasticsearch/config \
-v /mydata/es-01/data:/usr/share/elasticsearch/data \
--name es-01 \
elasticsearch:7.13.4

根据上述命令分析,“discovery.type=single-node"相当于环境变量,ES_JAVA_OPTS=”-Xms512m -Xmx512m"相当于Java设置项,es-config:/usr/share/elasticsearch/config需要进行卷挂载,而/mydata/es-01/data:/usr/share/elasticsearch/data需要进行外部挂载
在这里插入图片描述

1.设置配置文件

先启动一个es

mkdir -p /mydata/es-01 && chmod 777 -R /mydata/es-01

# 容器启动
docker run --restart=always -d -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v es-config:/usr/share/elasticsearch/config \
-v /mydata/es-01/data:/usr/share/elasticsearch/data \
--name es-01 \
elasticsearch:7.13.4

然后进入es内部查看

docker exec -it 37444173ac5e /bin/bash
cd /usr/share/elasticsearch/config
ls

在这里插入图片描述
将jvm.options和elasticsearch.yml配置为配置文件
在这里插入图片描述
elasticsearch.yml

cluster.name: "docker-cluster"
network.host: 0.0.0.0

jvm.options

################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

2.创建有状态应用

名为his-es,最多2核CPU,2G内存,设置环境变量并同步主机时区
在这里插入图片描述
存储卷设置
在这里插入图片描述
配置文件挂载
在这里插入图片描述
启动成功
在这里插入图片描述

3.配置服务

删除自动生成的服务,创建名为his-es集群内访问的服务
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
创建名为his-es-node集群外访问的服务,配置9200和9300端口,如果是云服务器的话需要开放服务分配的端口
在这里插入图片描述


http://www.kler.cn/a/568883.html

相关文章:

  • Linux下线程的同步与互斥
  • 深入浅出:从零开始掌握 Autofac 的依赖注入技巧
  • Java 8 到 Java 17 主要新特性
  • 《OpenCV》—— dlib库
  • Windows 上通过 VScode 配置 Docker
  • Uppy - 免费开源、功能强大的新一代 web 文件上传组件,支持集成到 Vue 项目
  • Git 搭建及项目分支设置教程
  • 评估自动驾驶(AD)策略性能的关键指标
  • 【Azure 架构师学习笔记】- Terraform创建Azure 资源
  • ChatGPT与DeepSeek:开源与闭源的AI模型之争
  • 飞书考勤Excel导入到自己系统
  • 相机引导2_两个固定相机引导机器人把芯片装入外壳
  • 基于决策树和随机森林的鸢尾花种类预测
  • CCF-CSP认证 202104-1灰度直方图
  • 【星云 Orbit-STM32F4】06. 串口密码:USART 数据传递
  • 大模型技术:重塑未来的力量
  • 【Android】类加载器热修复-随记(二)
  • SwiftUI之状态管理全解析
  • 大语言模型学习--LangChain
  • webpack5在生产环境屏蔽掉控制台打印 失效处理