Likely root cause: java.nio.file.NoSuchFileException: /usr/local/es/plugins/ik/plugin-descriptor(踩坑)
1. 安装ik分词器(本人下载的是第三个.tar.gz的源码包)
下载地址:https://github.com/medcl/elasticsearch-analysis-ik/
2. 安装报错
下载对应版本的ik分词器(java项目),将ik分词器放在es/plugins目录下,重启es导致报错
java.lang.IllegalStateException: Could not load plugin descriptor for plugin directory [ik] Likely root cause: java.nio.file.NoSuchFileException: /usr/local/es/plugins/ik/plugin-descriptor.properties at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) 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.newByteChannel(UnixFileSystemProvider.java:219) at java.base/java.nio.file.Files.newByteChannel(Files.java:371) at java.base/java.nio.file.Files.newByteChannel(Files.java:422) at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) at java.base/java.nio.file.Files.newInputStream(Files.java:156) at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:156) at org.elasticsearch.plugins.PluginsService.readPluginBundle(PluginsService.java:404) at org.elasticsearch.plugins.PluginsService.findBundles(PluginsService.java:392) at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:385) at org.elasticsearch.plugins.PluginsService.(PluginsService.java:156) at org.elasticsearch.node.Node.(Node.java:346) at org.elasticsearch.node.Node.(Node.java:289) at org.elasticsearch.bootstrap.Bootstrap$5.(Bootstrap.java:227) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:227) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) 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:127) 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/local/es/logs/my-application.log
3. 解决方案
查阅官方文档内容可以知道
git clone https://github.com/medcl/elasticsearch-analysis-ik
cd elasticsearch-analysis-ik
git checkout tags/{version}
mvn clean
mvn compile
mvn package
拷贝和解压release下的文件: #{project_path}/elasticsearch-analysis-ik/target/releases/elasticsearch-analysis-ik-*.zip 到你的 elasticsearch 插件目录, 如: plugins/ik 重启elasticsearch
所以需要我们把项目克隆到idea里面,然后用上面三个命令打包,然后在target/releases/目录下找到.zip文件;
4. windows系统直接解压缩就好了,macos可以用The Uncharvier解压缩,很方便!最后可以利用一个很高效的linux连接工具,把文件传输自定义的es目录下的plugins目录下即可!最后重启,后面又报下面的错误
5. 报错信息: failed to load plugins analysis-ik due to jar hell
6. 最后发现问题在于我下载的它的源码包是.tar.gz结尾的;
而实际应该下载.zip的包就可以了
7. 最后将.zip的包下载下来,解压缩,把压缩包放进es/plugins/目录下,重启es就解决了!(过程曲折,亲测有效)