ElasticSearch笔记

来源:互联网 发布:linux 搭建OpenVPN 编辑:程序博客网 时间:2024/04/28 17:54

ElasticSearch是基于Lucene的搜索服务,它提供分布式多用户的搜索引擎,支持Restful Web接口。


1. 对于es初学者,可能对关系型数据库mysql更熟悉一些。两者都能提供存储和查询。


MySQL ElasticSearchdatabaseindex tabletyperowdocumentfieldfield

2. ElasticSearch服务的搭建


(1)前提: jdk安装

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz
vim /etc/profile
JAVA_HOME=/opt/soft/jdk1.7.0_51
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CLASSPATH
JRE_HOME=$JAVA_HOME/jre
export JRE_HOME

source /etc/profile

验证设置是否生效 java -version (应该是需要重启系统才能生效)


(2)安装ES

https://www.elastic.co/downloads/elasticsearch

下载tar包,解压缩。里面有三个文件夹:bin是运行的脚本,config是设置文件,lib是放依赖的包。要装插件的话就要新建一个plugins的文件夹,把插件放到这个文件夹中。

启动起来先  bin/elasticsearch start



报UnknownHostException错误

解决方案: 

vi /etc/hosts

在hosts文件中加入主机的IP   zjm_45_12(主机名)  如: 127.0.0.1  localhost  zjm_45_12

测试是否正常 curl -i -XGET 'localhost:9200'



证明安装启动成功。


安装插件。

1.  Head 插件 此插件可以帮助我们查看集群状态,集群中的节点、索引以及索引中的数据一目了然,同时还支持结构化的查询并自动生成对应的查询Body,还支持通过自定义的查询Body进行查询,方便测试、调试。个人很喜欢这个插件。

sudo ln -s /opt/soft/elasticsearch-1.3.4/bin/plugin /usr/bin/plugin

plugin -install mobz/elasticsearch-head

http://blog.csdn.net/laigood/article/details/8193758

访问方式: http://localhost:9200/_plugin/head/

2. bigdesk插件 一个集群监控工具,可以通过它来查看es集群的各种状态,如:cpu、内存使用情况,索引数据、搜索情况,http连接数等。

plugin -install lukas-vlcek/bigdesk

访问方式:  http://localhost:9200/_plugin/bigdesk/

3 suggester插件:

bin/plugin -install de.spinscale/elasticsearch-plugin-suggest/1.3.2-2.0.1

http://maxrocray.iteye.com/blog/1748172 

4. ik分词插件:

       https://github.com/medcl/elasticsearch-analysis-ik
    http://blog.csdn.net/achilles12345/article/details/40248021

org.apache.http.client.ClientProtocolException类找不到异常,而且索引创建失败。

       注意: 进行maven打包时,我查看源码,原来作者为了可以从远程库中动态加入新的分词,就使用了httpclient来加载。然后查看了源码的pom.xml文件,发现这个分词器依赖:httpclient-4.3.5、httpcore-4.3.2、log4j-1.2.16、commons-logging-1.1.3、commons-codec-1.6几个jar包。于是,就将这几个jar包放在ES_HOMT/lib下,问题解决了

vim config/elasticsearch.yml


5. mmseg分词插件: 

https://github.com/medcl/elasticsearch-analysis-mmseg


1 0
原创粉丝点击