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即可

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
21天前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
28天前
|
安全 关系型数据库 MySQL
Linux(CentOS6)安装MySQL5.6
Linux(CentOS 6)系统上安装MySQL 5.6版本的详细步骤,包括准备数据存放目录、创建用户、下载安装包、初始化数据库、配置服务脚本、设置环境变量等操作。
83 1
|
20天前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
102 8
centos7 mysql安装及配置
|
16天前
|
NoSQL 关系型数据库 Redis
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
mall在linux环境下的部署(基于Docker容器),docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongodb、minio详细教程,拉取镜像、运行容器
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
|
17天前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
59 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
28天前
|
Linux 开发工具 数据安全/隐私保护
CentOS7安装流程步骤详细教程
【8月更文挑战第22天】
202 2
CentOS7安装流程步骤详细教程
|
6天前
|
存储 自然语言处理 关系型数据库
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
聚合、补全、RabbitMQ消息同步、集群、脑裂问题、集群分布式存储、黑马旅游实现过滤和搜索补全功能
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
|
21天前
|
分布式计算 资源调度 Hadoop
centos7二进制安装Hadoop3
centos7二进制安装Hadoop3
|
26天前
|
Linux 开发工具 git
CentOS安装git客户端
【8月更文挑战第22天】在 CentOS 上安装 Git 可通过两种方式:一是利用 yum 包管理器,只需在终端依次执行 `sudo yum update` 和 `sudo yum install git` 命令,安装时按提示输入 y 即可;二是从源码安装,适用于有特殊需求的场景。首先安装必要的依赖库,然后下载并解压 Git 的源码包,最后通过一系列 make 命令完成配置与编译安装。无论哪种方式,安装完毕后均可通过 `git --version` 验证安装情况。
|
24天前
|
缓存 运维 Linux
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧

热门文章

最新文章