Error log
{
"@timestamp":"2024-03-19T14:25:08.633Z",
"log.level":"ERROR",
"message":"fatal exception while booting Elasticsearch",
"ecs.version":"1.2.0",
"service.name":"ES_ECS",
"event.dataset":"elasticsearch.server",
"process.thread.name":"main",
"log.logger":"org.elasticsearch.bootstrap.Elasticsearch",
"elasticsearch.node.name":"ella",
"elasticsearch.cluster.name":"es",
"error.type":"java.lang.IllegalStateException",
"error.message":"failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?",
"error.stack_trace":"java.lang.IllegalStateException: failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?ntat [email protected]/org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:296)ntat [email protected]/org.elasticsearch.node.NodeConstruction.validateSettings(NodeConstruction.java:484)ntat [email protected]/org.elasticsearch.node.NodeConstruction.prepareConstruction(NodeConstruction.java:246)ntat [email protected]/org.elasticsearch.node.Node.<init>(Node.java:181)ntat [email protected]/org.elasticsearch.bootstrap.Elasticsearch$2.<init>(Elasticsearch.java:236)ntat [email protected]/org.elasticsearch.bootstrap.Elasticsearch.initPhase3(Elasticsearch.java:236)ntat [email protected]/org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73)nCaused by: java.io.IOException: failed to obtain lock on /usr/share/elasticsearch/datantat [email protected]/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:241)ntat [email protected]/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:209)ntat [email protected]/org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:288)nt... 6 moren Caused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/data/node.lockntat java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)ntat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)ntat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)ntat java.base/sun.nio.fs.UnixPath.toRealPath(UnixPath.java:834)ntat [email protected]/org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:94)ntat [email protected]/org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:43)ntat [email protected]/org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:44)ntat [email protected]/org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:234)nt... 8 morent Suppressed: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/node.locknttat java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)nttat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)nttat java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)nttat java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:261)nttat java.base/java.nio.file.Files.newByteChannel(Files.java:379)nttat java.base/java.nio.file.Files.createFile(Files.java:657)nttat [email protected]/org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:84)ntt... 11 moren"
}
Note
I use docker compose, and below the yaml file.
Docker-compose.yml
version: "3.8"
networks:
netwrk:
driver: bridge
services:
elastic:
container_name: elastic_db
build: ./elastic
environment:
LC_ALL: C.UTF-8
node.name: ella
discovery.type: single-node
cluster.name: es
ES_JAVA_OPTS: -Xms512m -Xmx512m
ELASITC_USERNAME: elastic
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD}
bootstrap.memory_lock: true
xpack.security.enabled: false
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ~/Docker/volume/elastic:/usr/share/elasticsearch/data
healthcheck:
test: curl -u elastic:${ELASTIC_PASSWORD} http://localhost:9200/_cluster/health
interval: 5s
timeout: 5s
retries: 30
start_period: 30s
expose:
- 9200
- 9300
networks:
- netwrk
(and other containers)
- Docker compose works well on my local desktop.
- I run command
sudo docker compose up --build -d
on EC2 ubuntu, but error invoked.
Docker, docker-compose version
- Local:
- Docker: 25.0.3
- docker-compose: 2.24.6
- EC2 Ubuntu:
- Docker: 26.0.0
- docker-compose: 2.25.0
PS
The volume file ~/Docker/volume/...
is not on /home/ubuntu/Docker/volume...
.
They are created on /root/Docker/volume/...
.
Why it happens? (I guess because docker-compose run by sudo…)
And Is there any solution to make volume file on /home/ubuntu/
(~
of host) directory?
I wish Elastic goes to work well
2
Answers
sudo chmod -R 777 /root/Docker/
works.But It could be too insecure.
Is there any other solution?
Try this
sudo usermod -aG docker $USER
sudo chmod -R u+w /home/ubuntu/Docker/