maowenqiang

环境

linux环境: centos7
es版本:7.8.0
java版本:1.8

安装

1、检查java版本

[root@localhost ~]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

2、安装java

yum list java-1.8*
yum install java-1.8.0-openjdk* -y

3、下载es

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-linux-x86_64.tar.gz

4、解压

tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz

5、添加用户

 ES不允许使用root操作es,需要添加用户,操作如下:

useradd es
chown -R es:es /tool/software/elasticsearch-7.8.0
su es

6、es 目录介绍

bin:可执行文件在里面,运行es的命令就在这个里面,包含了一些脚本文件等
config:配置文件目录
JDK:java环境
lib:依赖的jar,类库
logs:日志文件
modules:es相关的模块
plugins:可以自己开发的插件
data:这个目录没有,自己新建一下,后面要用 -> mkdir data,这个作为索引目录

7、修改核心配置文件elasticearch.yml

修改集群名称
修改当前的es节点名称
修改data数据保存地址和日志数据保存地址
绑定es网络ip
集群节点修改为之前的节点名称

 

 

 

 8、修改jvm参数

[root@localhost ~]# vi config/jvm.options
## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

# 修改这里的配置
-Xms128m
-Xmx128m

9、启动es

./bin/elasticsearch -d #-d参数可选,后端启动

10、访问测试

[root@localhost ~]# curl localhost:9200
{
  "name" : "localhost",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "IZHnOCWDSliGNV0vMC_UsQ",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

异常处理

ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3795] for user [esuser] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

如果出现以上异常,不用慌,可以一步一步处理

需要切换到root用户修改配置

  • 修改/etc/security/limits.conf 文件 

增加以下内容

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

修改 /etc/sysctl.conf 增加

vm.max_map_count=655360

修改完后 sysctl -p 刷新一下

再次切换到用户es 进行启动

ERROR: [2] bootstrap checks failed
[1]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

在 elasticsearch.yml中添加配置项:bootstrap.system_call_filter为false:

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

修改
elasticsearch.yml
取消注释保留一个节点
cluster.initial_master_nodes: ["node-1"]
这个的话,这里的node-1是上面一个默认的记得打开就可以了

安装分词插件(默认是英文分词词,如字段是中文,需为其指定字段的字段文本和搜索词的中文分词器)

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.0.0/elasticsearch-analysis-ik-7.0.0.zip
重新启动 Elastic,就会自动加载这个新安装的插件。
基本上,凡是需要搜索的中文字段,都要单独设置一下。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-04-13
  • 2021-06-10
  • 2021-09-29
  • 2022-12-23
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-09-08
  • 2022-12-23
相关资源
相似解决方案