windows 下安装elasticsearch 及其插件head,ik,marvel

来源:互联网 发布:雅各布矩阵和海森矩阵 编辑:程序博客网 时间:2024/05/21 07:55

1.首先下载elasticsearch for windows

官网地址:https://www.elastic.co/downloads/elasticsearch,这里我下载的是2.4.0版本。

2.安装jdk,jdk版本最好在1.7以上,否则无法启动elasticsearch服务

官方建议:

We recommend installing the Java 8 update 20 or later, or Java 7 update 55 or later.Previous versions of Java 7 are known to have bugs that can cause index corruption and data loss. Elasticsearch will refuse to start if a known-bad version of Java is used.

3.解压下载包到某个目录,例如:解压到D:\大数据软件安装包\elasticsearch-2.4.0\elasticsearch-2.4.0。

4.开始安装启动:这里有2种方法:

方法一:

进入解压文件的bin目录,双击执行elasticsearch.bat 如图,


进入 http://localhost:9200 ,出现以下页面,说明安装成功。


如果要停止服务: ctrl+c 即可。

方法二

(1)进入解压文件的bin目录下,执行以下命令:

service install

service start

如下图所示:


(2)同样打开 http://localhost:9200 浏览查看,如果要停止elasticsearch服务,则执行 service stop 即可关闭elasticsearch。

插件安装

1.安装head插件

安装head插件,在网页上管理、监视集群的状态。

打开cmd命令窗口,进入解压文件的bin目录,然后执行命令:

plugin install mobz/elasticsearch-head

如下图所示:


浏览http://localhost:9200/_plugin/head/,出现如下界面,则安装成功:


2.安装marvel插件

进入es安装目录的bin目录,执行命令:

bin/plugin install license
bin/plugin install marvel-agent

进入kibana的bin目录(首先下载kibana):

bin/kibana plugin --install elasticsearch/marvel/latest

如果机器没有连网,则上述命令无法执行,需要首先下载安装文件包,下载地址:

· https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.4.0/license-2.4.0.zip (sha1)

· https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/marvel-agent/2.4.0/marvel-agent-2.4.0.zip (sha1)

· https://download.elasticsearch.org/elasticsearch/marvel/marvel-2.4.0.tar.gz (sha1)

然后分别执行命令:

进入es的bin目录:

plugin install file:///D:/大数据软件安装包/elasticsearch-2.4.0/license-2.4.0.zip

plugin install file:///D:/大数据软件安装包/elasticsearch-2.4.0/marvel-agent-2.4.0.zip

进入kibana的bin目录:

kibana plugin --install marvel --url file:///path/to/file/marvel-2.4.0.tar.gz

最后访问:http://localhost:5601/app/marvel

3.安装ik分词插件

首先在git上下载已经编译好的代码,一定要选择和自己的es版本对应,否则无法启动服务,git下载地址如下:

https://github.com/medcl/elasticsearch-analysis-ik/releases

然后把文件解压放在es的plugins的analysis-ik目录下,如果没有此目录,则新建。

最后在es的conf中elasticsearch.yml文件末尾中加入 index.analysis.analyzer.ik.type: "ik"

测试分词插件是否可以分词:

在浏览器输入:

 http://localhost:9200/_analyze?analyzer=ik&pretty=true&text=中华人民共和国国歌
结果:
{ "tokens" : [ { "token" : "中华人民共和国", "start_offset" : 0, "end_offset" : 7, "type" : "CN_WORD", "position" : 0 },
{ "token" : "中华人民", "start_offset" : 0, "end_offset" : 4, "type" : "CN_WORD", "position" : 1 },
{ "token" : "中华", "start_offset" : 0, "end_offset" : 2, "type" : "CN_WORD", "position" : 2 },
{ "token" : "华人", "start_offset" : 1, "end_offset" : 3, "type" : "CN_WORD", "position" : 3 },
{ "token" : "人民共和国", "start_offset" : 2, "end_offset" : 7, "type" : "CN_WORD", "position" : 4 },
{ "token" : "人民", "start_offset" : 2, "end_offset" : 4, "type" : "CN_WORD", "position" : 5 },
{ "token" : "共和国", "start_offset" : 4, "end_offset" : 7, "type" : "CN_WORD", "position" : 6 },
{ "token" : "共和", "start_offset" : 4, "end_offset" : 6, "type" : "CN_WORD", "position" : 7 }, {
"token" : "国", "start_offset" : 6, "end_offset" : 7, "type" : "CN_CHAR", "position" : 8 },
{ "token" : "国歌", "start_offset" : 7, "end_offset" : 9, "type" : "CN_WORD", "position" : 9 } ]}
如果想要粗粒度的分词:则把analyzer的属性换成ik_smart即可
 http://localhost:9200/_analyze?analyzer=ik_smart&pretty=true&text=中华人民共和国国歌
结果:
{ "tokens" : [ { "token" : "中华人民共和国", "start_offset" : 0, "end_offset" : 7, "type" : "CN_WORD", "position" : 0 },
{ "token" : "国歌", "start_offset" : 7, "end_offset" : 9, "type" : "CN_WORD", "position" : 1 } ]}







0 0
原创粉丝点击