CentOS7安装ElasticSearch7.14.2和ik分词器

简介: CentOS7安装ElasticSearch7.14.2和ik分词器

安装包

安装jdk(参考文章):https://blog.csdn.net/m0_51510236/article/details/113739345

ElasticSearch: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.2-linux-x86_64.tar.gz

ik分词器:https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.14.2/elasticsearch-analysis-ik-7.14.2.zip

安装步骤

创建安装目录(可依照个人使用习惯更改):

mkdir /opt/server

解压elasticsearch安装包到这个目录

tar -zxvf elasticsearch-7.14.2-linux-x86_64.tar.gz -C /opt/server

修改 elasticsearch-7.14.2/config/jvm.options 文件,修改内存大小,可根据物理机实际配置修改(配置可参考文档https://blog.csdn.net/m0_51510236/article/details/113738338):

-Xms256m
-Xmx256m
-Xmn128m

修改 elasticsearch-7.14.2/config/elasticsearch.yml 文件,修改配置(192.168.27.5 为我自己的IP地址,需要改为自己的IP地址):

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 192.168.27.5
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["192.168.27.5"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

因为ElasticSearch不允许root用户启动,所以创建一个es用户:

groupadd es
useradd es -g es
passwd es
# 下面设置es用户登录的密码

创建步骤:

顺便将elasticsearch目录的所有者改为es:

chown es:es -R elasticsearch-7.14.2

修改系统配置文件:

vim /etc/security/limits.conf
# 添加已下内容
es hard nofile 65536
es soft nofile 65536

第二个配置文件:

vim /etc/sysctl.conf
# 添加以下内容
vm.max_map_count=655360

打印并生效:

sysctl -p

可以直接执行这一段shell添加配置:

echo "es hard nofile 65536" >> /etc/security/limits.conf
echo "es soft nofile 65536" >> /etc/security/limits.conf
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl -p

切换到es用户并启动elasticsearch:

su es
bin/elasticsearch

看到这个代表启动成功:

访问elasticsearch主机的 9200 端口:

elasticsearch安装成功

安装ik分词器

ik分词器的作用为:”为中文搜索提供词汇支持“,所以建议安装,在elasticsearch的 plugins 目录下创建文件夹 ik,然后将之前下载的分词器的压缩包解压到该目录中:

mkdir ik
cd ik/
yum install -y unzip
unzip /usr/local/src/elasticsearch-analysis-ik-7.14.2.zip

然后从新启动elasticsearch即可

相关实践学习
以电商场景为例搭建AI语义搜索应用
本实验旨在通过阿里云Elasticsearch结合阿里云搜索开发工作台AI模型服务,构建一个高效、精准的语义搜索系统,模拟电商场景,深入理解AI搜索技术原理并掌握其实现过程。
ElasticSearch 最新快速入门教程
本课程由千锋教育提供。全文搜索的需求非常大。而开源的解决办法Elasricsearch(Elastic)就是一个非常好的工具。目前是全文搜索引擎的首选。本系列教程由浅入深讲解了在CentOS7系统下如何搭建ElasticSearch,如何使用Kibana实现各种方式的搜索并详细分析了搜索的原理,最后讲解了在Java应用中如何集成ElasticSearch并实现搜索。  
相关文章
|
5月前
|
Java Linux
CentOS环境搭建Elasticsearch集群
至此,您已成功在CentOS环境下搭建了Elasticsearch集群。通过以上介绍和步骤,相信您对部署Elasticsearch集群有了充分的了解。最后祝您在使用Elasticsearch集群的过程中顺利开展工作!
323 22
|
11月前
|
自然语言处理 大数据 应用服务中间件
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
大数据-172 Elasticsearch 索引操作 与 IK 分词器 自定义停用词 Nginx 服务
217 5
|
11月前
|
自然语言处理 Java 网络架构
elasticsearch学习三:elasticsearch-ik分词器的自定义配置 分词内容
这篇文章是关于如何自定义Elasticsearch的ik分词器配置以满足特定的中文分词需求。
556 0
elasticsearch学习三:elasticsearch-ik分词器的自定义配置 分词内容
|
10月前
|
测试技术 API 开发工具
ElasticSearch的IK分词器
ElasticSearch的IK分词器
198 7
|
11月前
|
存储 JSON Java
elasticsearch学习一:了解 ES,版本之间的对应。安装elasticsearch,kibana,head插件、elasticsearch-ik分词器。
这篇文章是关于Elasticsearch的学习指南,包括了解Elasticsearch、版本对应、安装运行Elasticsearch和Kibana、安装head插件和elasticsearch-ik分词器的步骤。
1070 0
elasticsearch学习一:了解 ES,版本之间的对应。安装elasticsearch,kibana,head插件、elasticsearch-ik分词器。
|
存储 自然语言处理 关系型数据库
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
聚合、补全、RabbitMQ消息同步、集群、脑裂问题、集群分布式存储、黑马旅游实现过滤和搜索补全功能
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
|
JSON 自然语言处理 Java
ElasticSearch 实现分词全文检索 - 搜素关键字自动补全(Completion Suggest)
ElasticSearch 实现分词全文检索 - 搜素关键字自动补全(Completion Suggest)
440 1
|
JSON 自然语言处理 数据库
Elasticsearch从入门到项目部署 安装 分词器 索引库操作
这篇文章详细介绍了Elasticsearch的基本概念、倒排索引原理、安装部署、IK分词器的使用,以及如何在Elasticsearch中进行索引库的CRUD操作,旨在帮助读者从入门到项目部署全面掌握Elasticsearch的使用。
|
存储 安全 Java
在CentOS 7上安装和配置Elasticsearch的方法
在CentOS 7上安装和配置Elasticsearch的方法
925 0
|
自然语言处理 Java 关系型数据库
ElasticSearch 实现分词全文检索 - SpringBoot 完整实现 Demo 附源码【完结篇】
ElasticSearch 实现分词全文检索 - SpringBoot 完整实现 Demo 附源码【完结篇】
278 0