1. 拉取镜像

docker pull elasticsearch:7.14.0

#查看一下镜像拉取是否成功
docker images   

2. 创建映射目录

sudo mkdir -p /data/docker/elasticsearch/config
sudo mkdir -p /data/docker/elasticsearch/data
sudo mkdir -p /data/docker/elasticsearch/plugins

# 设置文件夹权限
sudo chmod -R 777 /data/dockerelasticsearch

#设置虚拟机内存
sudo sysctl -w vm.max_map_count=262144

3. 配置 elasticsearch.yml

cd /data/docker/elasticsearch/config
vim elasticsearch.yml

# 主机名,通过 hostname 命令查询到
cluster.initial_master_nodes: ["LIZTEST01"]
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"

4. 运行

docker run \
--name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
-v /data/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /data/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-v /data/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.14.0

5. 访问

http://120.24.204.216:9200/
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐