elasticsearch error when providing persistence:
First of all thank you
I've tried all with no persistence and it worked perfecly, but I'm getting an error into making elasticsearch persistent.
I've also chmod the folder to 777 (to prevent eventual write permission issues)
here the main script
docker-compose.yml
version: '2'
services:
elasticsearch:
build: elasticsearch/
ports:
- "9200:9200"
- "9300:9300"
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
# disable X-Pack
# see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html
# https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-enabling
xpack.security.enabled: "false"
xpack.monitoring.enabled: "false"
xpack.graph.enabled: "false"
xpack.watcher.enabled: "false"
networks:
- elk
volumes:
- /elasticsearch/data:/usr/share/elasticsearch/data
logstash:
build: logstash/
volumes:
- ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./logstash/pipeline:/usr/share/logstash/pipeline
ports:
- "5000:5000"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- elk
depends_on:
- elasticsearch
kibana:
build: kibana/
volumes:
- ./kibana/config/:/usr/share/kibana/config
ports:
- "5601:5601"
networks:
- elk
depends_on:
- elasticsearch
networks:
elk:
driver: bridge
and here the result:
Creating network "dockerelkmaster_elk" with driver "bridge"
Creating dockerelkmaster_elasticsearch_1
Creating dockerelkmaster_kibana_1
Creating dockerelkmaster_logstash_1
Attaching to dockerelkmaster_elasticsearch_1, dockerelkmaster_kibana_1, dockerelkmaster_logstash_1
elasticsearch_1 | [2017-04-24T21:38:55,088][INFO ][o.e.n.Node ] [] initializing ...
elasticsearch_1 | [2017-04-24T21:38:55,250][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
elasticsearch_1 | org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to created node environment
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | Caused by: java.lang.IllegalStateException: Failed to created node environment
elasticsearch_1 | at org.elasticsearch.node.Node.<init>(Node.java:261) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.node.Node.<init>(Node.java:238) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap$6.<init>(Bootstrap.java:242) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:242) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | ... 6 more
elasticsearch_1 | Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
elasticsearch_1 | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
elasticsearch_1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
elasticsearch_1 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
elasticsearch_1 | at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:?]
elasticsearch_1 | at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_92-internal]
elasticsearch_1 | at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_92-internal]
elasticsearch_1 | at java.nio.file.Files.createDirectories(Files.java:767) ~[?:1.8.0_92-internal]
elasticsearch_1 | at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:221) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.node.Node.<init>(Node.java:258) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.node.Node.<init>(Node.java:238) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap$6.<init>(Bootstrap.java:242) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:242) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.3.0.jar:5.3.0]
elasticsearch_1 | ... 6 more
dockerelkmaster_elasticsearch_1 exited with code 1
Any idea?
thank you again
chown -R 1000:1000 [your hosted directory] should solve the problem, see more details https://discuss.elastic.co/t/elastic-elasticsearch-docker-not-assigning-permissions-to-data-directory-on-run/65812/2
First you need create the directory
use mkdir -p ~/docker-elk/elasticsearch/data
chown -R 1000:1000 worked... but I'm I'm thinking about why chmod -R 777 does not...
Thank you!
Did you create the /elasticsearch/data directory yourself or did you let Docker create it for you? I think the latter will do the right thing for you. Could you reproduce with a data directory which doesn't exist on your filesystem yet?
@antoineco I created directory first as suggested by @DavidRBarcelo .
Without creating the folder i got the same problem...
I think that maybe the problem was related to the position of the folder: a subdirecory of the user home folder (just for testing purpose):
/home/<user>/
normally I create first the folders to have a clear "visualization" of the folder's tree that I'll use.
Do you think that the problem is related to the path?
@matteo-bombelli I started the stack on Docker for Mac with:
volumes:
- ./elasticsearch/storage:/usr/share/elasticsearch/data
and the directory permissions are correctly mapped on my machine:
# docker exec elkfail_elasticsearch_1 ls -l data/
drwxr-xr-x 3 elasticsearch elasticsearch 102 May 8 14:59 nodes
# ls -ln elasticsearch/storage/
drwxr-xr-x@ 4 antoineco antoineco 102 May 8 16:59 nodes
...
On Linux you have to set the owner of the data directory to 1000:1000 exactly like @leon-wu mentioned. This is because the default elasticsearch user within the image is using this uid:gid combination.
Feel free to reopen if you hit this problem again!
chown -R 1000:1000 worked. Thank you!
Actually, I just change the entryponit file:/usr/local/bin/docker-entrypoint as follow: change "umask 0002" to "umask 0022" add chown -R 1000:1000 /usr/share/elasticsearch It works!