1. 阿里加速
在阿里云控制台获取加速地址,并编辑daemon.json /etc/docker/daemon.json
{
"registry-mirrors": ["https://jplphtbp.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
2. 拉取镜像
选择自己所需的版本
docker pull mobz/elasticsearch-head:5 docker pull elasticsearch:6.8.1 docker pull kibana:6.8.1
3. 启动容器
启动 elasticsearch
docker run -itd —name 容器名字 -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” 镜像id
启动 elasticsearch-head:5
docker run -itd -p 9100:9100 —name ES-head 镜像id
启动kibana
docker run -itd —name kibana -e ELASTICSEARCH_URL=http://ip:9200 -p 5601:5601 kibana:6.8.1
浏览器访问ip+9100 判断 elasticsearch-head是否成功
浏览器访问ip+5601 判断 kibana 是否成功
4. 常见问题
elasticsearch jvm 分配太小
jvm 参数配置启动时加入ES_JAVA_OPTS
docker run -itd —name ES -p 9200:9200 -p 9300:9300 -e “ES_JAVA_OPTS=-Xms256m -Xmx256m” -e “discovery.type=single-node” 镜像id
- elasticsearch-head请求elasticsearch服务需要跨域
docker exec -it elasticsearch的容器名字 /bin/bash
进入容器内部/usr/share/elasticsearch/config ,修改文件elasticsearch.yml
http.cors.enabled: true http.cors.allow-origin: “*”
重启服务
docker restart elasticsearch的容器名字
- 406 Not Acceptable .ES-head 无法操作数据
修改/usr/src/app/_site/vendor.js 。不同版本此文件存放位置不一致
6886行:contentType: “application/x-www-form-urlencoded 修 改成 contentType: “application/json;charset=UTF-8”
7573行: var inspectData = s.contentType === “application/x-www-form-urlencoded” && 修改成 var inspectData = s.contentType === “application/json;charset=UTF-8” &&
- low disk watermark [85%] exceeded on [xF5] 磁盘空间不足
config/elasticsearch.yml添加 cluster.routing.allocation.disk.threshold_enabled: false