Docker安装ElasticSearch

Docker安装ElasticSearch

微信搜索 zze_coding 或扫描 👉 二维码关注我的微信公众号获取更多资源推送:

1、拉取 ElasticSearch 镜像:

[root@localhost ~]# docker pull elasticsearch
Using default tag: latest
Trying to pull repository docker.io/library/elasticsearch ... 
latest: Pulling from docker.io/library/elasticsearch
05d1a5232b46: Pull complete 
5cee356eda6b: Pull complete 
89d3385f0fd3: Pull complete 
65dd87f6620b: Pull complete 
78a183a01190: Pull complete 
1a4499c85f97: Pull complete 
2c9d39b4bfc1: Pull complete 
1b1cec2222c9: Pull complete 
59ff4ce9df68: Pull complete 
1976bc3ee432: Pull complete 
5af49e8af381: Pull complete 
42c8b75ff7af: Pull complete 
7e6902915254: Pull complete 
99853874fa54: Pull complete 
596fbad6fcff: Pull complete 
Digest: sha256:a8081d995ef3443dc6d077093172a5931e02cdb8ffddbf05c67e01d348a9770e
Status: Downloaded newer image for docker.io/elasticsearch:latest

2、创建并运行一个容器:

[root@localhost ~]# docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --name myES elasticsearch
5e6541d7c18f2467f40a22c58242ac76c6ce5a5311f0de6b6ca2842e26719f24
  • ElasticSearch 服务默认会占用 2g 的堆内存空间,测试时可以通过指定 -e ES_JAVA_OPTS="-Xms256m -Xmx256m" 来分别限制 ElasticSearch 初始堆内存大小为 256m,最大使用内存为 256m

  • ElasticSearch 默认通信使用 9200 端口,而在分布式情况下它各个节点的通信使用 9300 端口。

3、测试连接,浏览器访问 9200 端口如下则运行成功:

image.png

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可

Links: https://www.zze.xyz/archives/docker-elasticsearch.html

Buy me a cup of coffee ☕.