【Docker】之安装 ElasticSearch
下载 ElasticSearch
和 Kibana
镜像
以 7.17.3
版本为例,elasticsearch
和 kibana
的版本要对应:
docker pull elasticsearch:7.17.3
docker pull kibana:7.17.3
更多版本的镜像可以访问 Docker 官网:https://hub.docker.com/_/elasticsearch?tab=tags
创建并运行 ElasticSearch
容器
配置相关映射文件:
# 创建挂载目录
mkdir -p /root/.docker/voldata/elasticsearch/{config,data,logs,plugins}
# 创建配置文件
echo "http.host: 0.0.0.0" > /root/.docker/voldata/elasticsearch/config/elasticsearch.yml
# 给挂载目录添加权限
chmod -R 777 /root/.docker/voldata/elasticsearch/
启动容器:
docker run -d -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /root/.docker/voldata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /root/.docker/voldata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /root/.docker/voldata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /root/.docker/voldata/elasticsearch/logs:/usr/share/elasticsearch/logs \
--name elasticsearch \
elasticsearch:7.17.3
查看启动情况:
docker ps -l
设置 docker
启动时自动运行:
docker update elasticsearch --restart=always
创建并运行启动 Kibana
容器
启动命令:
docker run -d -p 5601:5601 \
-e ELASTICSEARCH_HOSTS=http://10.211.55.81:9200 \
--name kibana \
kibana:7.17.3
查看启动情况:
docker ps -l
设置 docker 启动时自动运行:
docker update kibana --restart=always
访问 ElasticSearch
和 Kibana
1)查看 elasticsearch
版本信息:浏览器输入地址 http://10.211.55.81:9200
{
"name" : "57eae3752c89",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "qiyzlDQ7Sb69Kmh9uW9bYQ",
"version" : {
"number" : "7.17.3",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "5ad023604c8d7416c9eb6c0eadb62b14e766caff",
"build_date" : "2022-04-19T08:11:19.070913226Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
2)显示 elasticsearch
节点信息:浏览器输入地址 http://10.211.55.81:9200/_cat/nodes
127.0.0.1 19 97 5 0.09 0.24 0.24 cdfhilmrstw * 57eae3752c89
3)访问 Kibana
:浏览器输入地址 http://10.211.55.81:5601/app/kibana