Docker安装Elasticsearch 7.6.1 + /Easticsearch-Head 5

一、Docker 安装 ElasticSearch

1、从仓库中查找所有ElasticSearch的镜像

[root@localhost ~]# docker search elasticsearch
NAME                                 DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
elasticsearch                        Elasticsearch is a powerful open source sear…   4434                [OK]                
nshou/elasticsearch-kibana           Elasticsearch-7.7.0 Kibana-7.7.0                119                                     [OK]
itzg/elasticsearch                   Provides an easily configurable Elasticsearc…   70                                      [OK]
mobz/elasticsearch-head              elasticsearch-head front-end and standalone …   62                                      
elastichq/elasticsearch-hq           Official Docker image for ElasticHQ: Elastic…   55                                      [OK]
elastic/elasticsearch                The Elasticsearch Docker image maintained by…   35                                      
bitnami/elasticsearch                Bitnami Docker Image for Elasticsearch          32                                      [OK]
taskrabbit/elasticsearch-dump        Import and export tools for elasticsearch       22                                      [OK]
lmenezes/elasticsearch-kopf          elasticsearch kopf                              18                                      [OK]
barnybug/elasticsearch               Latest Elasticsearch 1.7.2 and previous rele…   17                                      [OK]
justwatch/elasticsearch_exporter     Elasticsearch stats exporter for Prometheus     15                                      
esystemstech/elasticsearch           Debian based Elasticsearch packing for Lifer…   15                                      
blacktop/elasticsearch               Alpine Linux based Elasticsearch Docker Image   12                                      [OK]
monsantoco/elasticsearch             ElasticSearch Docker image                      11                                      [OK]
mesoscloud/elasticsearch             [UNMAINTAINED] Elasticsearch                    9                                       [OK]
centerforopenscience/elasticsearch   Elasticsearch                                   4                                       [OK]
barchart/elasticsearch-aws           Elasticsearch AWS node                          3                                       
dtagdevsec/elasticsearch             elasticsearch                                   3                                       [OK]
bitnami/elasticsearch-exporter       Bitnami Elasticsearch Exporter Docker Image     2                                       [OK]
jetstack/elasticsearch-pet           An elasticsearch image for kubernetes PetSets   1                                       [OK]
axway/elasticsearch-docker-beat      "Beat" extension to read logs of containers …   1                                       [OK]
phenompeople/elasticsearch           Elasticsearch is a powerful open source sear…   1                                       [OK]
wreulicke/elasticsearch              elasticsearch                                   0                                       [OK]
18fgsa/elasticsearch-ha              Built from https://github.com/18F/kubernetes…   0                                       
18fgsa/elasticsearch                 Built from https://github.com/docker-library…   0                                       

2、选择一个版本镜像进行拉取

[root@localhost ~]# docker pull elasticsearch:7.6.1

3、查看镜像

[root@localhost ~]# docker images

4、通过镜像,启动一个容器,并将9200和9300端口映射到本机

[root@localhost ~]# docker network create somenetwork

[root@localhost ~]# docker run -d --name es --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.1

5、 配置跨域,进入容器内部,修改elasticsearch.yml

[root@localhost ~]# docker exec -it es /bin/bash

[root@localhost elasticsearch]# ls
LICENSE.txt  NOTICE.txt  README.textile  bin  config  data  lib  logs  modules  plugins
[root@localhost elasticsearch]# cd config/
[root@localhost config]# ls
elasticsearch.keystore  ingest-geoip  log4j2.properties  roles.yml  users_roles
elasticsearch.yml       jvm.options   role_mapping.yml   users
[root@localhost config]# vi elasticsearch.yml

新增跨域配置

cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
  
# minimum_master_nodes need to be explicitly set when bound on a public IP
# set to 1 to allow single node clusters
# Details: https://github.com/elastic/elasticsearch/pull/17288
discovery.zen.minimum_master_nodes: 1

6、重启ElasticSearch容器

[root@localhost ~]# docker restart es

7、 浏览器访问ip:9200

{
	name: "1f5a9f949292",
	cluster_name: "docker-cluster",
	cluster_uuid: "TlppYOEORbK1PvcFDTTZbQ",
	version: {
	number: "7.6.1",
	build_flavor: "default",
	build_type: "docker",
	build_hash: "aa751e09be0a5072e8570670309b1f12348f023b",
	build_date: "2020-02-29T00:15:25.529771Z",
	build_snapshot: false,
	lucene_version: "8.4.0",
	minimum_wire_compatibility_version: "6.8.0",
	minimum_index_compatibility_version: "6.0.0-beta1"
	},
	tagline: "You Know, for Search"
}

二、Docker 部署 ElasticSearch-Head

ElasticSearch-Head是一个管理界面,可以查看ElasticSearch相关信息
1、拉取ElasticSearch-Head镜像

[root@localhost ~]# docker pull mobz/elasticsearch-head:5
5: Pulling from mobz/elasticsearch-head
75a822cd7888: Pull complete 
57de64c72267: Pull complete 
4306be1e8943: Pull complete 
871436ab7225: Pull complete 
0110c26a367a: Pull complete 
1f04fe713f1b: Pull complete 
723bac39028e: Pull complete 
7d8cb47f1c60: Pull complete 
7328dcf65c42: Pull complete 
b451f2ccfb9a: Pull complete 
304d5c28a4cf: Pull complete 
4cf804850db1: Pull complete

2、 运行ElasticSearch-Head容器

[root@localhost ~]# docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
a8affb38d3ad7f66b2bb5f7a9a28363bfc48309143b7e9892fe2f9c40ba1f4b4

3、浏览器访问 ip:9100
在这里插入图片描述

三、Docker部署ik中文分词插件

1、进入es容器内部,/plugins下新建ik文件夹

[root@localhost ~]# docker exec -it es /bin/bash
[root@1f5a9f949292 elasticsearch]# ls
LICENSE.txt  NOTICE.txt  README.asciidoc  bin  config  data  jdk  lib  logs  modules  plugins
[root@1f5a9f949292 elasticsearch]# cd plugins/
[root@1f5a9f949292 plugins]# mkdir ik
[root@1f5a9f949292 plugins]# ls
ik

2、下载与es对应版本的ik压缩包,并解压

下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

[root@1f5a9f949292 ik]# wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.0/elasticsearch-analysis-ik-7.6.1.zip

[root@1f5a9f949292 ik]# unzip elasticsearch-analysis-ik-7.6.1.zip

[root@1f5a9f949292 ik]# ls
commons-codec-1.9.jar    config                               elasticsearch-analysis-ik-7.6.0.zip  httpcore-4.4.4.jar            plugin-security.policy
commons-logging-1.2.jar  elasticsearch-analysis-ik-7.6.0.jar  httpclient-4.5.2.jar                 plugin-descriptor.properties

下载不了直接从GitHub下载zip包并解压传到Linux中,在使用docker命令传到容器中

docker cp /usr/local/docker/temp/ 6d7e7b8c9433:/usr/share/elasticsearch/plugins/ik	

3、退出容器,重启es容器

[root@1f5a9f949292 ik]# exit
[root@localhost ~]# docker restart es
es

4、测试ik分词插件,postman请求以下参数

ip:9200/_analyze?pretty=true

{
	"analyzer": "ik_max_word",
	"text": "随便打测试一下分词器"
}

注意analyzer这个单词上下是不一样的
在这里插入图片描述
至此Docker安装 Elasticsearch已基本完成

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值