Docker 安装 ElasticSearch 和 Kibana

Docker 安装 ElasticSearch 和 Kibana

1 下载 ElasticSearch

root@ubuntu:~# docker pull elasticsearch:7.12.0
7.12.0: Pulling from library/elasticsearch
7a0437f04f83: Pull complete 
2b674c951ca3: Pull complete 
06baeb69f25f: Pull complete 
eeff01d19ce5: Pull complete 
a994306398ca: Pull complete 
2c002d76c1f6: Pull complete 
6286f2196f9b: Pull complete 
Digest: sha256:383e9fb572f3ca2fdef5ba2edb0dae2c467736af96aba2c193722aa0c08ca7ec
Status: Downloaded newer image for elasticsearch:7.12.0
docker.io/library/elasticsearch:7.12.0

root@ubuntu:~# docker images
REPOSITORY      TAG       IMAGE ID       CREATED       SIZE
elasticsearch   7.12.0    9337ed510a0c   5 weeks ago   830MB

2 安装 ElasticSearch

root@ubuntu:~# docker images
REPOSITORY      TAG       IMAGE ID       CREATED       SIZE
elasticsearch   7.12.0    9337ed510a0c   5 weeks ago   830MB

root@ubuntu:~# docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:7.12.0
48bc98672d66e9bf6b18bb44e846c1a4d51de9391919891f42ae1df725151c61

root@ubuntu:~# docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS                                                                                  NAMES
48bc98672d66   elasticsearch:7.12.0   "/bin/tini -- /usr/l…"   5 seconds ago   Up 4 seconds   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp   elasticsearch
root@ubuntu:~# 

root@ubuntu:~# docker container ls -a
CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS          PORTS                                                                                  NAMES
48bc98672d66   elasticsearch:7.12.0   "/bin/tini -- /usr/l…"   42 seconds ago   Up 42 seconds   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp   elasticsearch

3 修改 ElasticSearch 配置

3.1 修改配置

在elasticsearch.yml的文件末尾加上

http.cors.enabled: true
http.cors.allow-origin: "*"
root@ubuntu:~# docker exec -it elasticsearch /bin/bash
[root@486bf4758d2d elasticsearch]# cd /usr/share/elasticsearch/config/
[root@486bf4758d2d config]# vi elasticsearch.yml
[root@486bf4758d2d config]# exit
exit

3.1 重启 ElasticSearch

root@ubuntu:~# docker restart elasticsearch 
elasticsearch

4 修改 ElasticSearch 安装ik分词器

elasticsearch的版本和ik分词器的版本需要保持一致,不然在重启的时候会失败

5 查看 ElasticSearch 运行

{
  "name" : "48bc98672d66",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "FADMviDcTNCcacHfsixY5g",
  "version" : {
    "number" : "7.12.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
    "build_date" : "2021-03-18T06:17:15.410153305Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Docker 安装 ElasticSearch 和 Kibana

上一篇:ELK 最详细安装及介绍


下一篇:docker stack部署elfk