原 docker下安装elasticsearch 7.6.2
版权声明:本文为博主原创文章,请尊重他人的劳动成果,转载请附上原文出处链接和本声明。
本文链接:https://www.91mszl.com/zhangwuji/article/details/1235
docker pull elasticsearch:7.6.2
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0">>/mydata/elasticsearch/config/elasticsearch.yml
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.6.2
启动后我们用docker ps查看发现elasticsearch没有启动起来。
我们查看下elasticsearch的启动日志。
docker ps -a
执行命令:
docker logs b133f3714be4
错误信息:
ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];
Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
at java.base/java.nio.file.Files.createDirectory(Files.java:693)
at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:800)
at java.base/java.nio.file.Files.createDirectories(Files.java:786)
at org.elasticsearch.env.NodeEnvironment.lambda$new$0(NodeEnvironment.java:274)
at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:211)
at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:271)
at org.elasticsearch.node.Node.<init>(Node.java:277)
at org.elasticsearch.node.Node.<init>(Node.java:257)
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:221)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /usr/share/elasticsearch/logs/elasticsearch.log
错误原因是data目录下权限不够。
我们切换到/mydata/elasticsearch目录下
cd /mydata/elasticsearch/
目前的权限如下所示。
我们为/mydata/elasticsearch目录下的所有文件赋予777的权限。
chmod -R 777 /mydata/elasticsearch
docker start b133f3714be4
再次用docker ps查看
设置elasticsearch开机自启动。
docker update --restart=always elasticsearch
我们使用浏览器访问:http://ip:9200,如果访问不了,需要防火墙开放9200端口。
2020-05-31 17:22:43 阅读(1172)
名师出品,必属精品 https://www.91mszl.com
博主信息