elasticsearch Docker启动Device or resource busy异常

发布于:2024-04-28 ⋅ 阅读:(19) ⋅ 点赞:(0)

问题

在基于Docker进行elasticsearch部署启动时,指定了elasticsearch.yml配置文件,但在启动时报如下异常:

Exception in thread "main" java.nio.file.FileSystemException: /usr/share/elasticsearch/config/elasticsearch.yml.cvrM1wfsRz-M7StPG7vFHw.tmp -> /usr/share/elasticsearch/config/elasticsearch.yml: Device or resource busy

at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)

at java.base/sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:416)

at java.base/sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:266)

at java.base/java.nio.file.Files.move(Files.java:1432)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.fullyWriteFile(AutoConfigureNode.java:1136)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.fullyWriteFile(AutoConfigureNode.java:1148)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.execute(AutoConfigureNode.java:687)

at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:81)

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)

at org.elasticsearch.cli.Command.main(Command.java:77)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.main(AutoConfigureNode.java:157)

对应的elasticsearch版本为elasticsearch:8.13.0。

解决方案

方案一:采用默认的elasticsearch.yml,不自行进行指定。

启动命令如下:

docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /Users/ershixiong/work/develop/soft/es/data:/usr/share/elasticsearch/data \
-v /Users/ershixiong/work/develop/soft/es/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:8.13.0

方案二:有可能是elasticsearch.yml中配置错误。

常见错误一:elasticsearch.yml中配置格式错误,比如:

http.host:0.0.0.0

上述配置中,冒号后面缺少空格,标准的格式是应该有空格的。

常见错误二:参数配置错误。

还以上述为例:

http.host: 0.0.0.0

上述配置虽然格式挣钱,但貌似在该版本中并不支持该配置项目,而需要改为:

network.host: 0.0.0.0

改为上述配置便可正常启动。同时需要注意的是,在该版本中,上述配置是默认的配置,所以可以不用进行指定配置。

方案三:设置bootstrap.memory_lock参数为true

在启动命令时,设置bootstrap.memory_lock参数为true:

-e "bootstrap.memory_lock=true"

网站公告

今日签到

点亮在社区的每一天
去签到