在使用Docker安装Elasticsearch的IK-Analyzer中文分词器时出现以下错误
错误信息:Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/plugins/ik-analyzer/plugin-descriptor.properties
错误原因:在拷贝IK-analzyer中文分词器插件到elasticsearch中后,重启Docker容器报以下错误:
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/plugins/ik-analyzer/plugin-descriptor.properties at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:1.8.0_181] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:1.8.0_181] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:1.8.0_181] at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:1.8.0_181] at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_181] at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_181] at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[?:1.8.0_181] at java.nio.file.Files.newInputStream(Files.java:152) ~[?:1.8.0_181] at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:114) ~[elasticsearch-5.6.12.jar:5.6.12] at org.elasticsearch.bootstrap.Spawner.spawnNativePluginControllers(Spawner.java:80) ~[elasticsearch-5.6.12.jar:5.6.12] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:168) ~[elasticsearch-5.6.12.jar:5.6.12] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.12.jar:5.6.12] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.12.jar:5.6.12] ... 6 more
原因:目标容器内目录权限不足
解决方法:可以先将宿主机插件目录赋予777权限,再进行复制
$ sudo chmod -R 777 /Users/yans/Downloads/ik-analyzer(插件目录) $ sudo docker cp /Users/yans/Downloads/ik-analyzer 容器ID:/usr/share/elasticsearch/plugins/ik-analyzer
之后再启动容器
$ docker start 容器ID