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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值