Docker安装ElasticSearch
一、安装ES
1、搜索镜像
搜索命令:
docker search elasticsearch
得到如下结果:
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/elasticsearch Elasticsearch is a powerful open source se... 3874 [OK]
docker.io docker.io/nshou/elasticsearch-kibana Elasticsearch-7.1.1 Kibana-7.1.1 105 [OK]
docker.io docker.io/itzg/elasticsearch Provides an easily configurable Elasticsea... 68 [OK]
docker.io docker.io/mobz/elasticsearch-head elasticsearch-head front-end and standalon... 49
docker.io docker.io/elastichq/elasticsearch-hq Official Docker image for ElasticHQ: Elast... 38 [OK]
docker.io docker.io/elastic/elasticsearch The Elasticsearch Docker image maintained ... 22
docker.io docker.io/bitnami/elasticsearch Bitnami Docker Image for Elasticsearch 18 [OK]
docker.io docker.io/lmenezes/elasticsearch-kopf elasticsearch kopf 18 [OK]
docker.io docker.io/taskrabbit/elasticsearch-dump Import and export tools for elasticsearch 18 [OK]
docker.io docker.io/barnybug/elasticsearch Latest Elasticsearch 1.7.2 and previous re... 17 [OK]
2、拉取镜像
选择一个版本拉取镜像
docker pull elasticsearch:2.4.4
3、查看镜像
docker images
docker.io/elasticsearch 2.4.4 2232dfa6321a 2 years ago 345 MB
4、运行镜像
映射端口,后台运行,起个名字ES01
docker run -d -p 9200:9200 -p 9300:9300 --name ES01 2232dfa6321a
如果内存不够,可以设置ES占用内存大小,如下
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name ES01 2232dfa6321a
5、测试
此时访问9200端口,如果出现以下JSON响应,说明已经安装完毕。
{
"name" : "Fight-Man",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "8KGgfdPDTV2EjxdaC1TbbQ",
"version" : {
"number" : "2.4.4",
"build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
"build_timestamp" : "2017-01-03T11:33:16Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}
二、插件
我们可以安装一个插件,使数据可视化。
1、进入容器
docker exec -it ES01 /bin/bash
2、进入bin目录,安装插件
cd bin
plugin install mobz/elasticsearch-head
3、访问页面
访问:
your url:9200/_plugin/head/
进入插件界面。