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/