KubeSphere部署Elastisearch

docker启动命令

cpp 复制代码
# 创建数据目录
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

cpp 复制代码
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内部查看

cpp 复制代码
docker exec -it 37444173ac5e /bin/bash
cd /usr/share/elasticsearch/config
ls

将jvm.options和elasticsearch.yml配置为配置文件

elasticsearch.yml

cpp 复制代码
cluster.name: "docker-cluster"
network.host: 0.0.0.0

jvm.options

cpp 复制代码
################################################################
##
## 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端口,如果是云服务器的话需要开放服务分配的端口

相关推荐
杭州泽沃电子科技有限公司2 小时前
煤化工精炼与加工环节的监测:智能平台如何保障最终产品价值与环保合规?
运维·科技
可可苏饼干3 小时前
Ruo-Yi 前后端分离
运维·学习
SUPER52663 小时前
运维hbase服务重启,导致应用查询异常 hbase:meta
运维·数据库·hbase
_w_z_j_3 小时前
Linux----信号(产生、保存、处理)
linux·运维·服务器
专家大圣3 小时前
远程调式不复杂!内网服务器调试用对工具很简单
运维·服务器·网络·内网穿透·cpolar
gs801403 小时前
Ascend 服务器是什么?(Ascend Server / 昇腾服务器)
运维·服务器·人工智能
飞飞传输4 小时前
选对国产FTP服务器,筑牢数据传输安全防线,合规高效双达标
大数据·运维·安全
西格电力科技4 小时前
光伏策略控制服务器的核心价值与应用必要性
运维·服务器
i橡皮擦5 小时前
使用gamedig 查询恐龙岛TheIsle游戏服务器
运维·服务器·游戏·steam·恐龙岛·the isle
White-Legend5 小时前
支持docker一键部署了
运维·docker·容器