使用Docker安装ElasticSearch 以及我遇到的问题
使用Docker安装ElasticSearch 以及我遇到的问题
-
第一步先准备好需要挂载到docker里面的目录和文件
例如:mkdir -p /usr/local/esdata/config mkdir -p /usr/local/esdata/data mkdir -p /usr/local/esdata/plugins vi /usr/local/esdata/config/elasticsearch.yml #文本输入如下 http.host: 0.0.0.0
2.第二步下载并启动es容器
docker run
--name elasticsearch
-p 9200:9200
-p 9300:9300 -e "discovery.type=single-node"
-e ES_JAVA_OPTS="-Xms64m -Xmx128m"
-v /usr/local/esdata/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
-v /usr/local/esdata/data:/usr/share/es/data
-v /usr/local/esdata/plugins:/usr/share/elasticsearch/plugins
-d elasticsearch:7.7.0
直接docker run Docker会自动pull
记录一下我安装时遇到的问题:
Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/usr/local/mydata/config/elasticsearch.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/c4fc8e876eb44269911cd4ddb18c9039df0bd26c93a6d26642a8a6c2b17510c5/merged\\\" at \\\"/var/lib/docker/overlay2/c4fc8e876eb44269911cd4ddb18c9039df0bd26c93a6d26642a8a6c2b17510c5/merged/usr/share/elasticsearch/config/elasticsearch.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Error: failed to start containers: elasticsearch
这句报错的重点是这一句:
mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
意思是说挂载的 elasticsearch.yml 是一个目录而不是文件,粗心将路径写错了,修改了之后成功启动es容器
值得一提的是kibana和es版本要一致否则就会kibana连接就会失败
--为自己而努力