1. 程式人生 > >es5.4安裝head、ik中文分詞插件

es5.4安裝head、ik中文分詞插件

es

  1. 安裝maven打包工具

wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar -xf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 /usr/local/data/apache-maven
vim /etc/profile
export MAVEN_HOME=/usr/local/data/apache-maven
export PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile

2. 安裝ik分詞

git  clone https://github.com/medcl/elasticsearch-analysis-ik
cd elasticsearch-analysis-ik/
mvn package
ll /usr/local/data/elasticsearch-analysis-ik/target/releases/
total 4400
-rw-r--r-- 1 root root 4502096 May 26 11:29 elasticsearch-analysis-ik-5.4.0.zip

創建分詞目錄

mkdir /usr/local/data/elasticsearch/plugins/ik
cp target/releases/elasticsearch-analysis-ik-5.4.0.zip  /usr/local/data/elasticsearch/plugins/ik/
cd /usr/local/data/elasticsearch/plugins/ik && unzip elasticsearch-analysis-ik-5.4.0.zip
chown -R es.es /usr/local/data/elasticsearch

測試分詞

http://172.16.230.198:9200/index/_analyze?analyzer=ik_max_word&text=中華人民共和國

技術分享

3.安裝head插件

yum -y install git npm
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm install -g cnpm --registry=
修改head監聽地址為內網
vim Gruntfile.js
                connect: {
                        server: {
                                options: {
                                        hostname:‘172.16.230.198‘,
                                        port: 9100,
                                        base: ‘.‘,
                                        keepalive: true
                                }
                        }
                }
後臺啟動elasticsearch-head 插件
npm install grunt-cli
ln -s /usr/local/data/elasticsearch-head/node_modules/grunt/bin/grunt  /usr/bin/
grunt  server &

遇到的問題:head 插件無法連接es集群 顯示集群健康值未連接

修改head的es監聽地址

cd elasticsearch-head
vim _site/app.js

修改 『http://localhost:9200』字段到本機ES端口與IP

vim $ES_HOME$/config/elasticsearch.yml
# 增加如下字段
http.cors.enabled: true
http.cors.allow-origin: "*"

重啟es 和head即可


本文出自 “不拋棄!不放棄” 博客,請務必保留此出處http://thedream.blog.51cto.com/6427769/1929838

es5.4安裝head、ik中文分詞插件