elasticsearch7.5.1集群安裝elasticsearch-jieba-plugin 7.4.2 和analysis-kuromoji 日語分詞器 安裝插件需要在集群的其中一個節點安裝后重啟es程序,沒有問題后拷貝到其他節點重啟后生效 1.elasticsearch-jieba需要使用gradle進行編譯 # 安裝gradle 下載gradle的二進制文件 wget https://services.gradle.org/distributions/gradle-6.3-bin.zip cd /usr/local/elk # 修改環境變量將gradle加入環境變量中 # vim /etc/profile export GRADLE_HOME=/usr/local/elk/gradle-6.3/ export PATH=$GRADLE_HOME/bin:$PATH screen -S gradle # 編譯生成jieba分詞插件 [elasticsearch@sz_ms_influenex_es_dev01_17_19 elasticsearch-jieba-plugin-7.4.2]$ gradle pz Welcome to Gradle 6.3! Here are the highlights of this release: - Java 14 support - Improved error messages for unexpected failures For more details see https://docs.gradle.org/6.3/release-notes.html Starting a Gradle Daemon (subsequent builds will be faster) Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 3m 23s 4 actionable tasks: 4 executed # 將最終編譯生成的elasticsearch-jieba-plugin-7.4.2.zip拷貝到es插件目錄中 cp /usr/local/elk/elasticsearch-7.5.1/plugins/elasticsearch-jieba-plugin-7.4.2/build/distributions/elasticsearch-jieba-plugin-7.4.2.zip /usr/local/elk/elasticsearch-7.5.1/plugins/ cd /usr/local/elk/elasticsearch-7.5.1/plugins/ unzip -d jieba elasticsearch-jieba-plugin-7.4.2.zip # 修改jieba配置,因為沒有最新的 jieba 7.5.1 插件,直接修改配置即可 # cat /usr/local/elk/elasticsearch-7.5.1/plugins/jieba/plugin-descriptor.properties description=A jieba analysis of plugins for Elasticsearch version=7.5.1 name=jieba classname=org.elasticsearch.plugin.analysis.jieba.AnalysisJiebaPlugin java.version=8 elasticsearch.version=7.5.1 # 重新啟動elasticsearch [root@sz_ms_influenex_es_dev01_17_19 ~]# /usr/local/elk/elasticsearch-7.5.1/bin/elasticsearch-plugin list jieba # 測試 [root@sz_ms_influenex_es_dev02_17_20 elasticsearch-7.5.1]# curl -H "Content-Type: application/json" -u elastic:pass -XPOST http://10.10.17.19:9200/_analyze -d '{"analyzer" : "jieba_index", "text" : "你好,世界,很高興認識你!"}' {"tokens":[{"token":"你好","start_offset":0,"end_offset":2,"type":"word","position":0},{"token":",","start_offset":2,"end_offset":3,"type":"word","position":1},{"token":"世界","start_offset":3,"end_offset":5,"type":"word","position":2},{"token":",","start_offset":5,"end_offset":6,"type":"word","position":3},{"token":"很","start_offset":6,"end_offset":7,"type":"word","position":4},{"token":"高興","start_offset":7,"end_offset":9,"type":"word","position":5},{"token":"認識","start_offset":9,"end_offset":11,"type":"word","position":6},{"token":"你","start_offset":11,"end_offset":12,"type":"word","position":7},{"token":"!","start_offset":12,"end_offset":13,"type":"word","position":8}]} # 將jieba這個插件拷貝到其他節點 scp -P 2016 -r jieba 10.10.17.21:/usr/local/elk/elasticsearch-7.5.1/plugins/ # 注意修改文件權限 chown -R elasticsearch.elasticsearch /usr/local/elk/elasticsearch-7.5.1/ # 在elasticsearch用戶下重啟es su elasticsearch curl -H "Content-Type: application/json" -u elastic:pass -XPOST http://10.10.17.20:9200/_analyze -d '{"analyzer" : "jieba_index", "text" : "你好,世界,很高興認識你!"}' curl -H "Content-Type: application/json" -u elastic:pass -XPOST http://10.10.17.21:9200/_analyze -d '{"analyzer" : "jieba_index", "text" : "你好,世界,很高興認識你!"}' 二、analysis-kuromoji 日語分詞器的安裝 # 下載分詞器 cd /usr/local/elk/elasticsearch-7.5.1/plugins wget https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-kuromoji/analysis-kuromoji-7.5.1.zip unzip -d kuromoji analysis-kuromoji-7.5.1.zip rm -f analysis-kuromoji-7.5.1.zip # 切換到elasticsearch用戶,重啟es程序 su elasticsearch # 分別拷貝到其他節點並且重啟 # 注意修改文件權限 chown -R elasticsearch.elasticsearch /usr/local/elk/elasticsearch-7.5.1/