一、安装
# 存储和检索数据 docker pull elasticsearch:7.4.2 # 可视化检索数据 docker pull kibana:7.4.2 # 创建自己的目录 mkdir -p /mydata/elasticsearch/config mkdir -p /mydata/elasticsearch/data echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml # /mydata/elasticsearch/config # -p 9200:9200 容器内部端口映射到linux的端口 9200是后端发送请求restAPI使用的 # -p 9300:9300 9300是es在分布式集群下节点间的通信端口 # -e "discovery.type = single-node" 指定单节点模式运行 # -e ES_JAVA_OPTS="-Xms64m -Xmx128m" 如果不指定会将整个内存全部占用 初始64m最大占用128 上线一般32G docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms64m -Xmx128m" \ -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \ -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \ -d elasticsearch:7.4.2
注意:
如果启动失败,可以调整ES_JAVA_OPTS="-Xms64m -Xmx128m"加大内存
如果加大内存后仍启动失败使用命令:docker logs kiki-es 查看日志
如果是ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];”,
使用 chmod -R 777 /mydata/elasticsearch 递归改变该文件夹下的所有文件
二、访问
输入http://ip:9200,回车后得到类似如下内容,则es配置成功
{ "name": "c88fdc87848e", "cluster_name": "elasticsearch", "cluster_uuid": "4yT0vwEHTr6EGFYJ66k6qg", "version": { "number": "7.4.2", "build_flavor": "default", "build_type": "docker", "build_hash": "2f90bbf7b93631e52bafb59b3b049cb44ec25e96", "build_date": "2019-10-28T20:40:44.881551Z", "build_snapshot": false, "lucene_version": "8.2.0", "minimum_wire_compatibility_version": "6.8.0", "minimum_index_compatibility_version": "6.0.0-beta1" }, "tagline": "You Know, for Search" }
原文链接:https://blog.csdn.net/qq_38616503/article/details/123993602
本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work
尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。