前言

  Elasticsearch是一个基于Apache Lucene(TM)的开源搜索引擎。无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进、性能最好的、功能最全的搜索引擎库。但是,Lucene只是一个库。想要使用它,你必须使用Java来作为开发语言并将其直接集成到你的应用中,更糟糕的是,Lucene非常复杂,你需要深入了解检索的相关知识来理解它是如何工作的。Elasticsearch也使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。

  不过,Elasticsearch不仅仅是Lucene和全文搜索,我们还能这样去描述它:

  -分布式的实时文件存储,每个字段都被索引并可被搜索
  -分布式的实时分析搜索引擎
  -可以扩展到上百台服务器,处理PB级结构化或非结构化数据

  而且,所有的这些功能被集成到一个服务里面,你的应用可以通过简单的RESTful API、各种语言的客户端甚至命令行与之交互。

  ElasticSearch-head 是一个web端的ElasticSearch管理工具。

安装

一、docker安装Elasticsearch

1.docker拉取Elasticsearch镜像

https://www.docker.elastic.co/ 选择适用的版本。这里选择6.3.2

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2

如果docker pull error,请添加国内镜像加速源,参考:https://www.cnblogs.com/jxd283465/p/11571943.html

 # 拉取镜像
[root@localhost ~]# docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2
6.3.2: Pulling from elasticsearch/elasticsearch
7dc0dca2b151: Pull complete
72d60ff53590: Pull complete
ca55c9f7cc1f: Pull complete
822d6592a660: Pull complete
22eceb1ece84: Pull complete
30e73cf19e42: Pull complete
f05e800ca884: Pull complete
3e6ee2f75301: Pull complete
Digest: sha256:8f06aecf7227dbc67ee62d8d05db680f8a29d0296ecd74c60d21f1fe665e04b0
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:6.3.2
# 查看镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
17 docker.elastic.co/elasticsearch/elasticsearch 6.3.2 96dd1575de0f 14 months ago 826MB

2.运行容器

docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2

-p 9200 9300:映射虚拟机端口到宿主机端口

  9200 http协议,为elasticsearch默认端口,用于外部通讯。

  9300 tcp协议,用于集群之间通信。.

-e 设置elasticsearch为单节点启动

 # 启动容器
[root@localhost ~]# docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2
af895f4ddc62a981c72217f547a2a67fea9695b5b113c4317a1965cc76153bd4
# 查看容器
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
af895f4ddc62 docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 4 seconds ago Up 3 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp es

3.设置跨域

 # 进入es容器,es为容器的name,bash为命令行
[root@localhost ~]# docker exec -it es bash
# 查看文件
[root@af895f4ddc62 elasticsearch]# ls
LICENSE.txt README.textile config lib modules
NOTICE.txt bin data logs plugins
# 进入elasticsearch的配置文件夹
[root@af895f4ddc62 elasticsearch]# cd config
[root@af895f4ddc62 config]# ls
elasticsearch.keystore ingest-geoip log4j2.properties roles.yml users_roles
elasticsearch.yml jvm.options role_mapping.yml users
# 修改elasticsearch的配置文件
[root@af895f4ddc62 config]# vi elasticsearch.yml
# 增加跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
# :wq保存
# exit退出容器
[root@af895f4ddc62 config]# exit
exit
# 重启es容器
[root@localhost ~]# docker restart es
es
# curl "http://localhost:9200"

{
"name" : "rSLhlFi",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "QTLXwiz_Sx-udJAofc2RIQ",
"version" : {
"number" : "6.3.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "053779d",
"build_date" : "2018-07-20T05:20:23.451332Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

二、docker安装Elasticsearch-head

1.docker search elasticsearch-head搜索镜像

  • docker search elasticsearch-head

2.拉取 mobz/elasticsearch-head 镜像

  • docker pull mobz/elasticsearch-head:5

3.运行容器

  • docker run -d --name es_admin -p 9000:9100 mobz/elasticsearch-head:5

由于我宿主机9100端口被占用,所以这里将容器的9100端口映射到宿主机的9000端口

4.访问elasticsearch-head

浏览器打开http://192.168.8.10:9000/

最新文章

  1. #Deep Learning回顾#之LeNet、AlexNet、GoogLeNet、VGG、ResNet
  2. 如何设置div高度为100%
  3. Java数据结构——哈希表
  4. MongoDB的介绍和使用场景(1)
  5. hdu1203
  6. Hibernate4.x之映射关系--一对一映射
  7. Dubbo架构设计详解--转载
  8. hdu 4712 Hamming Distance ( 随机算法混过了 )
  9. 使用svn控制系统的优缺点和注意事项
  10. Python之mysql数据库更新表数据接口实现
  11. 自动化部署必备技能—部署yum仓库、定制rpm包
  12. C# 在RichTextBox中滚动鼠标时滚动的是父窗口的滚动条
  13. AngularJS进阶(二)AngularJS路由问题解决
  14. Linux常用命令-文本查看篇
  15. [LeetCode] Best Time to Buy and Sell Stock 6道合集【DP】
  16. excel 设置的函数在打开的时候不会自动执行
  17. arcface和Dlib人脸识别算法对比
  18. JFrame添加组件
  19. POJ2061 Subsequence 2017-05-25 19:49 83人阅读 评论(0) 收藏
  20. LeetCode 8 有效的括号

热门文章

  1. NMS的python实现
  2. deepin 15.11 成功安装 jupyter notebook
  3. docker An error occurred 虚拟化错误解决
  4. C#开发BIMFACE系列12 服务端API之文件转换
  5. 堆、栈、内存分配、==、equals、hashcode详解(转载)
  6. WebApi使用OAuth2认证
  7. Badboy中创建Suite, test, step和Template
  8. lightoj 1028 - Trailing Zeroes (I)(素数筛)
  9. XML的相关基础知识分享
  10. 【LeetCode】56-合并区间