docker启动ES(elasticsearch:7.17.23)

docker直接启动es,报如下错误

复制代码
2024-08-22 10:52:27 ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
2024-08-22 10:52:27 bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

遂寻找如何正确使用docker启动es容器

  1. 创建docker容器挂载目录(替换成自己的目录)
bash 复制代码
mkdir -p ~/Documents/DevApp/config/elasticsearch/config
mkdir -p ~/Documents/DevApp/config/elasticsearch/data
echo "http.host: 0.0.0.0">>~/Documents/DevApp/config/elasticsearch/config/elasticsearch.yml

注意⚠️:chmod -R 777 /mydata/elasticsearch 要有访问权限

  1. 创建实例并启动ES
bash 复制代码
sudo docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e ES_JAVA_OPS="-Xms256m -Xmx256m" \
-v ~/Documents/DevApp/config/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v ~/Documents/DevApp/config/elasticsearch/data:/usr/share/elasticsearch/data \
-v ~/Documents/DevApp/config/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.17.23

参数说明:

-p 9200:9200 将容器的9200端口映射到主机的9200端口;

--name elasticsearch 给当前启动的容器取名叫 elasticsearch

-v ~/Documents/DevApp/config/elasticsearch/data:/usr/share/elasticsearch/data 将数据文件夹挂载到主机;

-v ~/Documents/DevApp/config/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 将配置文件挂载到主机;

-d 以后台方式运行(daemon)

-e ES_JAVA_OPS="-Xms256m -Xmx256m" 测试时限定内存小一点

  1. 查看ES启动状态 命令 :docker ps
  2. 访问elasticsearch 访问地址:http://127.0.0.1:9200/
相关推荐
Elasticsearch6 小时前
Elastic 的托管 OTLP 端点:为 SRE 提供更简单、可扩展的 OpenTelemetry
elasticsearch
天上掉下来个程小白8 小时前
Docker-14.项目部署-DockerCompose
运维·docker·微服务·容器
Yusei_05239 小时前
迅速掌握Git通用指令
大数据·git·elasticsearch
星霜笔记12 小时前
Docker 部署 MariaDB+phpMyAdmin+Nextcloud 完整教程
运维·数据库·docker·容器·mariadb
数据知道15 小时前
容器化部署:用Docker封装机器翻译模型与服务详解
docker·容器·机器翻译
敲上瘾21 小时前
Linux系统cgroups资源精细化控制基础
linux·测试工具·docker·压力测试·cgroups
伊成1 天前
Docker 部署 Nginx 完整指南
nginx·docker·容器
落日漫游1 天前
K8s核心组件全解析
运维·docker·运维开发
水无痕simon1 天前
5 索引的操作
数据库·elasticsearch
江湖有缘1 天前
【Docker项目实战】使用Docker部署Notepad轻量级记事本
docker·容器·notepad++