Docker installs elasticsearch & kibana to prevent installation startup errors!

Insert picture description here

01. Preface

Although it is not the first time to contact elasticsearch (hereafter referred to as es) at work, because the company environment was supported before, it was all official data, so I have not built a relevant environment locally.

This should be stored inside es to a large number of test data , in order not to affect the test environment using or take a local bar


02. Introduction to elasticsearch

es is developed on the basis of lucene , providing a set of distributed, high-scalability, high-real-time search and data analysis engine , developed in Java language

Its simple REST -style API, distributed nature , speed and scalability famous


03, elasticsearch advantage


3.1 Query performance & full text search

es query performance is very fast . Since es is built on the basis of lucene, it performs very well in full text search

es is also a near real-time search platform, which means that the index operation from the document to the document becomes searchable delay between the state is very short, usually only a second


3.2 Distributed features

es having essential features distributed . es documents stored in different containers, these containers called fragments, the data may be replicated to provide a redundant copy , prevent the occurrence of a hardware failure

The distributed nature of es allows it to scale to hundreds (or even thousands) of servers and process petabytes of data


3.3 Extensive functions

es contains a series of wide range of functions . In addition to the advantages of speed, scalability and flexibility, es also has a large number of powerful built-in functions (such as data aggregation and index lifecycle management), which can facilitate users to store and search data more efficiently


04, kibana

kibana is a suitable es of data visualization and management tools , we can provide real-time histograms, line graphs, pie charts and maps

Support user security permission system, support plugins of various latitudes, usually used with es and logstash


05, installation environment description

  • Docker version: v19.03.8
  • Elasticsearch version: 7.8.0
  • Kibana Edition: 7.8.0
  • docker elastic

06, elasticsearch installation


6.1 docker install elasticsearch

In order to save trouble, you can install elasticsearch directly using docker: 7.8.0 es

# 拉取 es 的 docker 镜像
# 这里拉取 7.8.0 版本, 也是最近新发布的
docker pull elasticsearch:7.8.0

After docker pulls the image successfully, use the command to check whether there is this image locally

# 查看 docker 中 es 镜像
docker images elasticsearch
# 发现镜像已经安安静静的在这了
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
elasticsearch       7.8.0               121454ddad72        5 weeks ago         810MB

Here is a recommended docker visual management tool, which provides functions such as containers, mirrors, logs, etc.

The most convenient installation of portainer


6.2 docker start elasticsearch

Next, just start the es image in docker directly

# -d : 后台运行
# -p : 指定宿主机与docker启动容器的端口映射
# --name : 为 elasticsearch 容器起个别名
# -e : 指定为单节点集群模式
# -v : 分别将 es 的数据以及插件挂载到宿主机
docker run -d --name elasticsearch \
-p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-v ~/docker/data/es:/usr/share/elasticsearch/data \
-v ~/docker/plugins/es:/usr/share/elasticsearch/plugins \
elasticsearch:7.8.0 

Enter http://localhost:9200/ in the browser or enter curl http://localhost:9200/ in the terminal to check whether es is installed successfully

{
    
    
    "name":"018ed28bad4d",
    "cluster_name":"docker-cluster",
    "cluster_uuid":"dBM2ktQ3TOu4_ivrDc0aBw",
    "version":{
    
    
        "number":"7.8.0",
        "build_flavor":"default",
        "build_type":"docker",
         ...
    },
    "tagline":"You Know, for Search"
}

07, kibana


7.1 docker cheap kibana

It should be noted that the version of kibana is best to be consistent with elasticsearch to avoid unnecessary errors.

# 直接和 es 保持一致
docker pull kibana:7.8.0
# 查看镜像是否拉取到本地
docker images kibana
# 版本与 es 也是一致的 7.8.0
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
kibana              7.8.0               df0a0da46dd1        5 weeks ago         1.29GB

You can see that the mirror of kibana has been pulled, then start kibana to try the page effect


7.2 docker start kibana

The 7.8.0 version of the kibana package is relatively large, slow to start, wait for half a minute

# -e : 指定环境变量配置, 提供汉化
# --like : 建立两个容器之间的关联, kibana 关联到 es
docker run -d --name kibana --link elasticsearch:elasticsearch -e "I18N_LOCALE=zh-CN" -p 5601:5601 kibana:7.8.0
# kibana 的汉化我感觉做的并不好
# 如果不习惯汉化, 可以把条件去除
docker run -d --name kibana --link elasticsearch:elasticsearch -p 5601:5601 kibana:7.8.0

You can view the container log according to portainer, or use the docker command

# 查看 kibana 的日志
docker logs kibana

The browser enters the address http://localhost:5601/ , the startup is successful


08, study summary

Installing es & kibana is also a lot of thunder, including single node startup abnormality, kibana cannot communicate with es, etc.

After lying with so many thunders, I once again understand the fact that I encountered a problem and read it on the official website

I also tried to use the combined image of nshou/elasticsearch-kibana . This image contains two images of es & kibana. After installation, I gave up, and I installed it myself

I will write a docker-compose installation method later , which will be placed in the basic operation article of writing es

Guess you like

Origin blog.csdn.net/qq_37781649/article/details/107539362