以后就专门准备一个bug分类来记录遇到的bug

安装ik分词器的时候, 明明已经安装成功了, 但是却没有生效

那么来一步步的排查问题

docker exec -it elasticsearch /bin/bash进入容器内部

cd /bin进入bin目录

elasticsearch-plugin list显示插件列表

这个时候发现突然就报错了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
java.lang.IllegalStateException: Could not load plugin descriptor for plugin directory [elasticsearch-analysis-ik-7.6.2]
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/plugins/elasticsearch-analysis-ik-7.6.2/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:374)
at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:159)
at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:156)
at org.elasticsearch.plugins.PluginsService.readPluginBundle(PluginsService.java:398)
at org.elasticsearch.plugins.PluginsService.findBundles(PluginsService.java:386)
at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:379)
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:151)
at org.elasticsearch.node.Node.<init>(Node.java:313)
at org.elasticsearch.node.Node.<init>(Node.java:257)
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:221)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
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:125)
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/share/elasticsearch/logs/elasticsearch.log

大概意思就是 缺少了这个plugin-descriptor.properties文件 , 我tm从官网下载的文件还能不保真???

搞了半天. , 反反复复重新创建了很多个容器, 还有修改文件权限(chmod -R 777 /elasticsearch, 我都777了总不可能是文件权限的问题了吧)

然后反手就是一个docker restart elasticsearch , 这个时候明明也是跟正常的启动时一样的, (控制台显示containername)

这不是启动成功了吗 ??

然后docker ps 发现找不到容器

image-20230124224955028

???再来!

我反手就是熟练的敲出 docker ps -a docker ps docker start elasticsearch

结果不出所料, 还是不管用. 然后我灵机一动 docker logs elasticsearch查看日志

发现还是之前的那个报错 , 这个时候就感觉到有点不对劲了, 我官网下载的代码还真能是假的???

然后我在win上面打开了下载的压缩包

。。。。。

然后我又对比了一下zip格式的压缩包

倒腾了半天原来是下载错压缩包了 , 不得不说真的很难绷得住

由于已经下载好了两个压缩包 , 但是我又突然想不起来zip 的解压命令了 , 这个时候耍了个小聪明吧zip在win解压然后又压缩成tar格式

然后反手就是一个熟练的tar -zxvf elasticsearch-analysis-ik-7.6.2.tar

结果他叕叕叕叕出问题了

1
2
3
4
5
[root@192 plugins]# tar -zxvf elasticsearch-analysis-ik-7.6.2.tar 

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

果然是祸不单行 , 然后在Stack Overflow上面找到了类似的问题

linux - gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now - Stack Overflow

这意味着该文件实际上不是一个gzip tar文件——或者任何类型的gzip文件——尽管命名类似于一个。

大概就是我在win里面压缩的tar格式的压缩包, 知识后缀相同, 实际上不是linux里面的tar格式的压缩包

那还是乖乖的用zip来解压吧

(顺便复习一下unzip命令 )

注意不能直接unzip elasticsearch-analysis-ik-7.6.2.zip

因为这样会会提取 zip 文件中所有的内容到现在的文件夹, 也就是这样。。。。

真的是一点点的踩坑啊有木有

正确的做法是 unzip -d

也就是 unzip elasticsearch-analysis-ik-7.6.2.zip -d elasticsearch-analysis-ik-7.6.2

接着启动docker start elasticsearch

1
2
3
4
5
6
7
8
[root@192 plugins]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2845cb5b4e57 elasticsearch:7.6.2 "/usr/local/bin/dock…" About a minute ago Up 2 seconds 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp elasticsearch
8fa8bc50a435 kibana:7.6.2 "/usr/local/bin/dumb…" 26 hours ago Up 43 minutes 0.0.0.0:5601->5601/tcp, :::5601->5601/tcp kibana
5084f671576a redis:6.2.6 "docker-entrypoint.s…" 4 weeks ago Up 43 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
c423f72d0cc0 mysql:5.7 "docker-entrypoint.s…" 4 weeks ago Up 43 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
[root@192 plugins]#

然后我们进入容器内部docker exec -it elasticsearch /bin/bash

接着查看分词器是否安装成功

image-20230124231107329

可以看到已经成功安装上了ik分词器

贴一个docker run elasticsearch

1
2
3
4
5
6
7
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.6.2

再贴一个完整的安装过程

快速方法

  1. 打开官网地址 , 找到对应版本的压缩包
  2. 直接下载.zip文件
  3. 进入与docker容器挂载的目录
  4. 将下载的压缩包传输的虚拟机中
  5. unzip ****.zip -d ****解压
    • ****代表文件的名称
  6. chmod -R ** 改变文件的执行权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[root@192 plugins]# ll
total 4400
-rw-r--r--. 1 root root 4504473 Jan 24 06:05 elasticsearch-analysis-ik-7.6.2.zip
[root@192 plugins]# unzip elasticsearch-analysis-ik-7.6.2.zip -d elasticsearch-analysis-ik-7.6.2
Archive: elasticsearch-analysis-ik-7.6.2.zip
creating: elasticsearch-analysis-ik-7.6.2/config/
inflating: elasticsearch-analysis-ik-7.6.2/config/main.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/quantifier.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/extra_single_word_full.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/IKAnalyzer.cfg.xml
inflating: elasticsearch-analysis-ik-7.6.2/config/surname.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/suffix.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/stopword.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/extra_main.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/extra_stopword.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/preposition.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/extra_single_word_low_freq.dic
inflating: elasticsearch-analysis-ik-7.6.2/config/extra_single_word.dic
inflating: elasticsearch-analysis-ik-7.6.2/elasticsearch-analysis-ik-7.6.2.jar
inflating: elasticsearch-analysis-ik-7.6.2/httpclient-4.5.2.jar
inflating: elasticsearch-analysis-ik-7.6.2/httpcore-4.4.4.jar
inflating: elasticsearch-analysis-ik-7.6.2/commons-logging-1.2.jar
inflating: elasticsearch-analysis-ik-7.6.2/commons-codec-1.9.jar
inflating: elasticsearch-analysis-ik-7.6.2/plugin-descriptor.properties
inflating: elasticsearch-analysis-ik-7.6.2/plugin-security.policy
[root@192 plugins]# ll
total 4400
drwxr-xr-x. 3 root root 243 Jan 24 07:05 elasticsearch-analysis-ik-7.6.2
-rw-r--r--. 1 root root 4504473 Jan 24 06:05 elasticsearch-analysis-ik-7.6.2.zip

接着我们可以进入到容器内部再次确认是否安装成功

1
2
3
4
5
6
7
8
[root@192 plugins]# docker exec -it elasticsearch /bin/bash
[root@2845cb5b4e57 elasticsearch]# cd bin
[root@2845cb5b4e57 bin]# elasticsearch-plugin list
elasticsearch-analysis-ik-7.6.2
[root@2845cb5b4e57 bin]# exit
exit
[root@192 plugins]# docker exec -it elasticsearch /bin/bash

贴一个以前记录的安装方法单机安装ES | dhx_'blog