ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。
我们建立一个网站或应用程序,并要添加搜索功能,但是想要完成搜索工作的创建是非常困难的。只看数据库的查找不仅极耗资源,而且速度不快。elasticsearch是一个不错的选择,不仅快,还具有实时性。
下面讲解安装步骤,分两种,一种是在线下载,另一种是离线本地下载。
bd@pyvip:~$docker search elasticsearch
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
elasticsearch Elasticsearch is a powerful open source sear… 3591 [OK]
nshou/elasticsearch-kibana Elasticsearch-6.5.4 Kibana-6.5.4 97 [OK]
itzg/elasticsearch Provides an easily configurable Elasticsearc… 67 [OK]
elastichq/elasticsearch-hq Official Docker image for ElasticHQ: Elastic… 28 [OK]
lmenezes/elasticsearch-kopf elasticsearch kopf 18 [OK]
bitnami/elasticsearch Bitnami Docker Image for Elasticsearch 16 [OK]
elastic/elasticsearch The Elasticsearch Docker image maintained by… 15
taskrabbit/elasticsearch-dump Import and export tools for elasticsearch 15 [OK]
esystemstech/elasticsearch Debian based Elasticsearch packing for Lifer… 14
monsantoco/elasticsearch ElasticSearch Docker image 11 [OK]
mesoscloud/elasticsearch [UNMAINTAINED] Elasticsearch 9 [OK]
justwatch/elasticsearch_exporter Elasticsearch stats exporter for Prometheus 8
blacktop/elasticsearch Alpine Linux based Elasticsearch Docker Image 8 [OK]
s12v/newrelic-elasticsearch New Relic plugin for elasticsearch monitorin… 5 [OK]
centerforopenscience/elasticsearch Elasticsearch 4 [OK]
docker pull elasticsearch:2.4.4
bd@pyvip:~$docker pull elasticsearch:2.4.4
2.4.4: Pulling from library/elasticsearch
cd0a524342ef: Pull complete
e39c3ffe4133: Pull complete
aac3320edf40: Pull complete
4d9e109682f7: Pull complete
0a59efcf9553: Pull complete
43a404e523e0: Pull complete
806f07b1dce8: Pull complete
97180523aa1a: Pull complete
aa1f5d9e6a71: Pull complete
edcadfd7f7d5: Pull complete
b06ed8306e19: Pull complete
f8477c7d1d2b: Pull complete
63b2dda3e739: Pull complete
40ce66d99c3d: Pull complete
Digest: sha256:3e8c3eca8868a44184966fd5c247cb4a9c23924e53d4f25aa244ea1f9c895129
Status: Downloaded newer image for elasticsearch:2.4.4
docker images
bd@pyvip:~$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 3 months ago 1.84kB
delron/elasticsearch-ik 2.4.6-1.0 095b6487fb77 12 months ago 689MB
elasticsearch 2.4.4 2232dfa6321a 2 years ago 345MB
docker run -d -p 9200:9200 -p 9300:9300 --name search elasticsearch:2.4.4
docker ps
curl 127.0.0.1:9200
显示如下图:
{
"name" : "David Cannon",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "wAssfOTuT-6UzYW4HQ0GqQ",
"version" : {
"number" : "2.4.6",
"build_hash" : "5376dca9f70f3abef96a77f4bb22720ace8240fd",
"build_timestamp" : "2017-07-18T12:17:44Z",
"build_snapshot" : false,
"lucene_version" : "5.5.4"
},
"tagline" : "You Know, for Search"
}
docker load -i elasticsearch-ik-2.4.6_docker.tar
unzip elasticsearch.zip
# network.host: 172.18.168.123
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 8002
docker run -dti --network=host --name=elasticsearch -v /home/bd/elasticsearch/config:/usr/share/elasticsearch/config delron/elasticsearch-ik:2.4.6-1.0
这里的代码不要直接复制, -v /home/bd/elasticsearch/config表示我配置文件的路径,你的路径需要自己对应。
docker container ls -a
curl 127.0.0.1:8002
docker exec -it c04e4bfa058e /bin/bash
cd bin
plugin install mobz/elasticsearch-head