Docker安装部署Elasticsearch+Kibana

Docker安装部署Elasticsearch+Kibana

确保本机已安装了docker与docker-compose

1.1 如果没有安装docker-compose的话先安装docker-compose:

sudo curl -L https://github.com/docker/compose/releases/download/1.28.3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

1.2 首先创建依次创建目录:

mkdir -p /home/elk/elasticsearch/config/
mkdir -p /home/elk/elasticsearch/data/
mkdir -p /home/elk/elasticsearch/logs/
mkdir -p /home/elk/elasticsearch/plugins/
mkdir -p /home/elk/kibana/config/

1.3 创建 Elasticsearch的配置文件:

vim /home/elk/elasticsearch/config/elasticsearch.yml

文件内容为:

cluster.name: "docker-cluster"
discovery.type: "single-node"
network.host: 0.0.0.0

1.4 创建JVM配置文件:

vim /home/elk/elasticsearch/config/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/7.16/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/7.16/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

# exit right after heap dump on out of memory error. Recommended to also use
# on java 8 for supported versions (8u92+).
9-:-XX:+ExitOnOutOfMemoryError

# 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.1 创建KIbana配置文件

vim /home/elk/kibana/config/kibana.yml

文件内容:

server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://192.168.2.246:9200" ]
monitoring.ui.container.elasticsearch.enabled: true

 将IP地址部分改成本机的内网IP

2.2 创建docker-compose的yaml文件:

vim /home/elk/elk.yml

文件内容:

version: "3"
services:
  elasticsearch:
    container_name: elasticsearch
    image: elasticsearch:7.16.3
    ports:
      - 9200:9200
      - 9300:9300
    volumes:
      - /home/elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /home/elk/elasticsearch/config/jvm.options:/usr/share/elasticsearch/config/jvm.options
      - /home/elk/elasticsearch/data:/usr/share/elasticsearch/data/
      - /home/elk/elasticsearch/logs:/usr/share/elasticsearch/logs/
      - /home/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins/
    restart: always

  kibana:
    container_name: kibana
    image: kibana:7.16.3
    ports:
      - 5601:5601
    volumes:
      - /home/elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    restart: always

3.1 开启EK服务:
docker-compose -f /home/elk/elk.yml up -d

3.2 访问 http://ip:9200和http://ip:5601 没问题的话说明Elasticsearch和Kibana的服务已成功启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值