Elasticsearch-5.5.0以及elasticsearch-analysis-ik安装使用

  最近项目中要求对文章进行全文检索,所以选择了elasticsearch作为全文检索引擎。在安装以及使用的过程中也是碰到了很多的坑,从最开始的7.3.2换到6.4.3再换到5.5.0,最后终于可以

使用了,太不容易了,所以开篇帖子记录下,希望能帮助到刚入门es的朋友们。

  下面介绍如何在Centos7上安装es,以及中文分词工具ik。因Elasticsearch是基于Java写的,所以它的运行环境中需要java的支持,在Linux下执行命令:java -version,检查JDK是否安装。如果没有安装,请安装JDK1.8以上版本。

一、es安装

1.下载elasticsearch压缩包

可前往 https://learnku.com/articles/33403 这个网址下载。选择5.5.0版本elasticsearch-5.5.0.zip即可。

2.解压elasticsearch压缩包

将压缩包拷贝之/usr/local/ 目录下,执行解压名称。

cp elasticsearch-5.5.0.zip /usr/local/
cd /usr/local
unzip elasticsearch-5.5.0.zip 

3.修改elasticsearch.yml配置文件

因为Elasticsearch5.0之后,不能使用root账户启动,所以我们要创建专门的elasticsearch用户组并授予文件夹权限。

vi /usr/local/elasticsearch-5.5.0/config/elasticsearch.yml
//插入如下内容#集群的名称
cluster.name: knowgram
# 节点的名称
node.name: knowgram_node1
#配置你存数据的目录
path.data: /usr/local/elasticsearch-5.5.0/data
# 配置你存日志的目录
path.logs: /usr/local/elasticsearch-5.5.0/logs
# Lock the memory on startup: 这两个配置用于解决后面报错问题,否则会报错
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# Set the bind address to a specific IP (IPv4 or IPv6):
#需要配置成本面的ip,否则外部无法访问
network.host: 0.0.0.0
transport.tcp.port: 9300
#设置跨域以及端口
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"

4.创建一个elasticsearch组和账户

因为Elasticsearch5.0之后,不能使用root账户启动,所以我们要创建专门的elasticsearch用户组并授予文件夹权限。

groupadd elasticsearch
useradd  elasticsearch -g elasticsearch -p elasticsearch
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-5.5.0

5.切换到elasticsearch用户并启动elasticsearch

cd /usr/local/elasticsearch5.5.0/
su elasticsearch
./bin/elasticsearch

//或用以下命令
su - elasticsearch -c "/usr/local/elasticsearch-5.5.0/bin/elasticsearch -d"

若看到输出started表示启动成功,若没有启动成功参考后面常见问题

[2019-11-05T12:34:09,961][INFO ][o.e.n.Node               ] [node_1] initializing ...
[2019-11-05T12:34:10,113][INFO ][o.e.e.NodeEnvironment    ] [node_1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [46gb], net total_space [59.9gb], spins? [unknown], types [rootfs]
[2019-11-05T12:34:10,116][INFO ][o.e.e.NodeEnvironment    ] [node_1] heap size [1.9gb], compressed ordinary object pointers [true]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] node name [node_1], node ID [b7PKnpL8TBqfX_j6N0ydyQ]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] version[5.5.0], pid[17571], build[260387d/2017-06-30T23:16:05.735Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_201/25.201-b09]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.5.0]
[2019-11-05T12:34:14,197][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [aggs-matrix-stats]
[2019-11-05T12:34:14,198][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [ingest-common]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-expression]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-groovy]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-mustache]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-painless]
[2019-11-05T12:34:14,201][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [parent-join]
[2019-11-05T12:34:14,201][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [percolator]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [reindex]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [transport-netty3]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [transport-netty4]
[2019-11-05T12:34:14,203][INFO ][o.e.p.PluginsService     ] [node_1] loaded plugin [analysis-ik]
[2019-11-05T12:34:21,588][INFO ][o.e.d.DiscoveryModule    ] [node_1] using discovery type [zen]
[2019-11-05T12:34:24,056][INFO ][o.e.n.Node               ] [node_1] initialized
[2019-11-05T12:34:24,057][INFO ][o.e.n.Node               ] [node_1] starting ...
[2019-11-05T12:34:24,930][INFO ][o.e.t.TransportService   ] [node_1] publish_address {192.168.16.152:9300}, bound_addresses {[::]:9300}
[2019-11-05T12:34:25,035][INFO ][o.e.b.BootstrapChecks    ] [node_1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2019-11-05T12:34:28,268][INFO ][o.e.c.s.ClusterService   ] [node_1] new_master {node_1}{b7PKnpL8TBqfX_j6N0ydyQ}{8rQez1gDSturfNgSHluIyw}{192.168.16.152}{192.168.16.152:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2019-11-05T12:34:28,651][INFO ][o.e.h.n.Netty4HttpServerTransport] [node_1] publish_address {192.168.16.152:9200}, bound_addresses {[::]:9200}
[2019-11-05T12:34:28,651][INFO ][o.e.n.Node               ] [node_1] started //看到这条信息表示启动成功
[2019-11-05T12:34:28,676][INFO ][o.e.g.GatewayService     ] [node_1] recovered [0] indices into cluster_state

6.常见问题处理
问题一

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

max number of threads [1024] for user [es] likely too low, increase to at least [2048]


max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]max number of threads [1024] for user [es] likely too low, increase to at least [2048]

解决方式:更换到root用户,编辑limits.conf 配置文件

vi /etc/security/limits.conf

//添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

  

问题二

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]  

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]  

解决方式:修改 /etc/sysctl.conf 配置文件,增加如下配置

vi /etc/sysctl.conf//追加如下内容vm.max_map_count=655360

二、安装elasticsearch-analysis-ik

1.下载对应的版本IK

前往github下载对应elasticsearch对应的ik版本,我安装的是elasticsearch5.5.0,所以选择对应5.5.0版本

2.在elasticsearch的plugins文件夹下新建ik目录

mkdir /usr/local/elasticsearch-5.5.0/plugins/ik

3.将压缩包复制到ik目录下并解压

cp elasticsearch-analysis-ik-5.5.0.zip /usr/local/elasticsearch-5.5.0/plugins/ik
cd /usr/local/elasticsearch-5.5.0/plugins/ik
unzip elasticsearch-analysis-ik-5.5.0.zip

最后重启elasticsearch,看到loaded plugin [analysis-ik]标识插件加载完成。

[2019-11-05T12:34:09,961][INFO ][o.e.n.Node               ] [node_1] initializing ...
[2019-11-05T12:34:10,113][INFO ][o.e.e.NodeEnvironment    ] [node_1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [46gb], net total_space [59.9gb], spins? [unknown], types [rootfs]
[2019-11-05T12:34:10,116][INFO ][o.e.e.NodeEnvironment    ] [node_1] heap size [1.9gb], compressed ordinary object pointers [true]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] node name [node_1], node ID [b7PKnpL8TBqfX_j6N0ydyQ]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] version[5.5.0], pid[17571], build[260387d/2017-06-30T23:16:05.735Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_201/25.201-b09]
[2019-11-05T12:34:10,125][INFO ][o.e.n.Node               ] [node_1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.5.0]
[2019-11-05T12:34:14,197][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [aggs-matrix-stats]
[2019-11-05T12:34:14,198][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [ingest-common]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-expression]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-groovy]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-mustache]
[2019-11-05T12:34:14,199][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [lang-painless]
[2019-11-05T12:34:14,201][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [parent-join]
[2019-11-05T12:34:14,201][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [percolator]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [reindex]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [transport-netty3]
[2019-11-05T12:34:14,202][INFO ][o.e.p.PluginsService     ] [node_1] loaded module [transport-netty4]
[2019-11-05T12:34:14,203][INFO ][o.e.p.PluginsService     ] [node_1] loaded plugin [analysis-ik] //看到这个标识插件加载成功
[2019-11-05T12:34:21,588][INFO ][o.e.d.DiscoveryModule    ] [node_1] using discovery type [zen]
[2019-11-05T12:34:24,056][INFO ][o.e.n.Node               ] [node_1] initialized
[2019-11-05T12:34:24,057][INFO ][o.e.n.Node               ] [node_1] starting ...
[2019-11-05T12:34:24,930][INFO ][o.e.t.TransportService   ] [node_1] publish_address {192.168.16.152:9300}, bound_addresses {[::]:9300}
[2019-11-05T12:34:25,035][INFO ][o.e.b.BootstrapChecks    ] [node_1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2019-11-05T12:34:28,268][INFO ][o.e.c.s.ClusterService   ] [node_1] new_master {node_1}{b7PKnpL8TBqfX_j6N0ydyQ}{8rQez1gDSturfNgSHluIyw}{192.168.16.152}{192.168.16.152:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2019-11-05T12:34:28,651][INFO ][o.e.h.n.Netty4HttpServerTransport] [node_1] publish_address {192.168.16.152:9200}, bound_addresses {[::]:9200}
[2019-11-05T12:34:28,651][INFO ][o.e.n.Node               ] [node_1] started
[2019-11-05T12:34:28,676][INFO ][o.e.g.GatewayService     ] [node_1] recovered [0] indices into cluster_state

至此,elasticsearch+ik分词工具安装完成!

 


  

原文地址:https://www.cnblogs.com/iteacat/p/11799187.html

时间: 2024-10-23 11:39:19

Elasticsearch-5.5.0以及elasticsearch-analysis-ik安装使用的相关文章

ElasticSearch记录(0)详细梳理

转自:https://blog.csdn.net/makang110/article/details/80596017 题记: Elasticsearch研究有一段时间了,现特将Elasticsearch相关核心知识.原理从初学者认知.学习的角度,从以下9个方面进行详细梳理.欢迎讨论…… 0. 带着问题上路——ES是如何产生的? (1)思考:大规模数据如何检索? 如:当系统数据量上了10亿.100亿条的时候,我们在做系统架构的时候通常会从以下角度去考虑问题: 1)用什么数据库好?(mysql.s

spring boot 2.0 整合 elasticsearch NoNodeAvailableException

原文地址:spring boot 2.0 整合 elasticsearch NoNodeAvailableException 原文说的有点问题,下面贴出我的配置: 码云项目地址:https://gitee.com/11230595/springboot-elasticsearch elasticsearch.yml cluster.name: my-applicationnetwork.host: 0.0.0.0 http.port: 9200transport.tcp.port: 9300tr

Spring-boot2.0.1.BUILD-SNAPSHOT整合Elasticsearch报failed to load elasticsearch nodes错误解决办法

spring-boot整合es的application.properties的默认配置为: spring.data.elasticsearch.cluster-nodes=localhost:9200 将端口号改成9300即可解决failed to load elasticsearch nodes错误 拓展:如果es的安装版本为2.x,那么spring-boot对应的版本要大于1.4.0.RC1版本![结果来源于stackoverflow] p.p1 { margin: 0.0px 0.0px

【拆分版】Docker-compose构建Elasticsearch 7.1.0集群

写在前边 搞了两三天了,一直有个问题困扰着我,ES集群中配置怎么能正确映射到主机上,这边经常报ClusterFormationFailureHelper master not discovered or elected yet.原因是容器中的ES节点没有正确的映射到主机上,而且容器内ip是易变的,我该怎么配置呢? 临下班了,终于想到个法子,固定容器ip--使用network_mode: host 看到主机模式的我眼前一亮,容器就相当于一个主机服务,你占哪个端口就是哪个,没有必要再去自己指定por

Elasticsearch 7.5.0集群部署

一.背景介绍ELK 不是一款软件,而是 Elasticsearch.Logstash 和 Kibana 三种软件产品的首字母缩写.这三者都是开源软件,通常配合使用,而且又先后归于 Elastic.co 公司名下,所以被简称为 ELK Stack.根据 Google Trend 的信息显示,ELK Stack 已经成为目前最流行的集中式日志解决方案. Elasticsearch:分布式搜索和分析引擎,具有高可伸缩.高可靠和易管理等特点.基于 Apache Lucene 构建,能对大容量的数据进行接

Elasticsearch 7.4.0 白金版 绿色教程

Elasticsearch X-PACK 白金版只有 30 天试用,为了可以经常使用,特出以下教程, 特别强调,仅作学习使用!!! 首先,从官网下一份 Linux 版的 Elasticsearch 安装包,再从开源社区拉取一份 Elasticsearch 源码. 官方下载页 https://www.elastic.co/cn/downloads/elasticsearch 开源仓库地址 GitHub https://github.com/elastic/elasticsearch Gitee(推

Elasticsearch入门教程(三):Elasticsearch索引&映射

原文:Elasticsearch入门教程(三):Elasticsearch索引&映射 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/vbirdbest/article/details/79213163 索引概念简介 通常说的索引有两种词性,名称和动词. 动词索引indexing,索引一个文档,表示把一个文档存储到索引Index里,可以用来查询和检索,es采用倒排索引 名词索引index,

Elasticsearch入门教程(一):Elasticsearch及插件安装

原文:Elasticsearch入门教程(一):Elasticsearch及插件安装 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/vbirdbest/article/details/79194244 分享一个朋友的人工智能教程(请以"右键"->"在新标签页中打开连接"的方式访问).比较通俗易懂,风趣幽默,感兴趣的朋友可以去看看. 一:安装Elasti

Elasticsearch入门教程(五):Elasticsearch查询(一)

原文:Elasticsearch入门教程(五):Elasticsearch查询(一) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/vbirdbest/article/details/79228852 // 准备数据 PUT /shop/goods/1 { "name": "2017新款女装冬季外套ulzzang棉袄中长款棉衣韩版百搭棉服面包服", &quo

Elasticsearch最新版本2.20特性及如何安装

版本选择:Elasticsearch最新版本2.20 Elasticsearch的更新速度实在太快了,16年2月2日更新到了2.2版本,首先看一下这个版本增加了哪些新的特性.首先是基于Lucene 5.4.1,修复了Elasticsearch 2.1.2和Elasticsearch 1.7.5版本中存在的很多bug,同时Elasticsearch 2.2.0增加了两个很棒的新功能:查询分析器和增强地理位置字段.这个版本增加了更加严格的安全性和修复了2.1的一个重大bug,就是在分片恢复的时候会非