elasticsearch- 7.9.2 单机安装

本文详细介绍了Elasticsearch 7.9.2的单机安装过程,包括安装与启动步骤、遇到的启动报错问题、配置文件的修改以及后台启动的方法。在修改elasticsearch.yml配置文件后出现的报错问题也给出了相应的解决方案。

Elasticsearch是提供核心的数据存储、搜索、分析功能的。elasticsearch之所以有如此高性能的搜索表现,正是得益于底层的倒排索引技术。那么什么是倒排索引呢?
倒排索引的概念是基于MySQL这样的正向索引而言的。
正向索引:适合于根据索引字段的精确搜索,不适合基于部分词条的模糊匹配。
而倒排索引恰好解决的就是根据部分词条模糊匹配的问题。
倒排索引:倒排索引中有两个非常重要的概念:
- 文档(Document):用来搜索的数据,其中的每一条数据就是一个文档。例如一个网页、一个商品信息
- 词条(Term):对文档数据或用户搜索数据,利用某种算法分词,得到的具备含义的词语就是词条。例如:我是中国人,就可以分为:我、是、中国人、中国、国人这样的几个词条。
创建倒排索引是对正向索引的一种特殊处理和应用,流程如下:
- 将每一个文档的数据利用分词算法根据语义拆分,得到一个个词条
- 创建表,每行数据包括词条、词条所在文档id、位置等信息
- 因为词条唯一性,可以给词条创建正向索引
此时形成的这张以词条为索引的表,就是倒排索引表

词条(索引)文档id
苹果1,2
手机1,3

MySQL

Elasticsearch

说明

Table

Index

索引(index),就是文档的集合,类似数据库的表(table)

Row

Document

文档(Document),就是一条条的数据,类似数据库中的行(Row),文档都是JSON格式

Column

Field

字段(Field),就是JSON文档中的字段,类似数据库中的列(Column)

Schema

Mapping

Mapping(映射)是索引中文档的约束,例如字段类型约束。类似数据库的表结构(Schema)

SQL

DSL

DSL是elasticsearch提供的JSON风格的请求语句,用来操作elasticsearch,实现CRUD

1.安装&启动

下载安装包 elasticsearch-7.9.2-linux-x86_64.tar.gz
下载地址https://www.elastic.co/cn/downloads/elasticsearch
解压 到/data/  下
[root@node1 tmp]# tar -zxvf elasticsearch-7.9.2-linux-x86_64.tar.gz -C /data/
解压成功后 /data/ 目录下生成 elasticsearch-7.9.2/
[root@node1 elasticsearch-7.9.2]# ll
总用量 572
drwxr-xr-x.  2 root root   4096 9月  23 2020 bin
drwxr-xr-x.  3 root root   4096 6月   9 02:59 config
drwxr-xr-x.  9 root root     99 9月  23 2020 jdk
drwxr-xr-x.  3 root root   4096 9月  23 2020 lib
-rw-r--r--.  1 root root  13675 9月  23 2020 LICENSE.txt
drwxr-xr-x.  2 root root      6 9月  23 2020 logs
drwxr-xr-x. 51 root root   4096 9月  23 2020 modules
-rw-r--r--.  1 root root 544318 9月  23 2020 NOTICE.txt
drwxr-xr-x.  2 root root      6 9月  23 2020 plugins
-rw-r--r--.  1 root root   7007 9月  23 2020 README.asciidoc
启动es
 ./bin/elasticsearch


2.启动报错

启动报错原因 elasticsearch 不允许root 用户启动
添加一个es 用户
[root@node1 elasticsearch-7.9.2]# adduser es
[root@node1 elasticsearch-7.9.2]# passwd es
es 用户添加权限
[root@node1 elasticsearch-7.9.2]# chown -R es:es /data/
使用es 用户登录
[es@node1 elasticsearch-7.9.2]$ ./bin/elasticsearch
测试访问
[es@node1 ~]$ curl 127.0.0.1:9200
{
  "name" : "node1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "jBRShcY4SZybbMMrEdVQ9Q",
  "version" : {
    "number" : "7.9.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
    "build_date" : "2020-09-23T00:45:33.626720Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

3.修改配置文件

进入/data/elasticsearch-7.9.2/config/ 目录
编辑elasticsearch.yml
[es@node1 config]$ vim elasticsearch.yml 
将55行 #network.host: 192.168.0.1 修改network.host: 192.168.6.130
保存后退出

4.后台启动

[es@node1 elasticsearch-7.9.2]$ ./bin/elasticsearch -d

5.修改elasticsearch.yml配置文件后启动报错

启动报错
[3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

6.解决报错

#用户最大可创建文件数太小
#查看可打开文件数量  ulimit -Hn
vim /etc/security/limits.conf 
#@student        -       maxlogins       4
* soft nofile 65536
* hard nofile 65536
# End of file
保存退出

#最大虚拟内存太小
#查看虚拟内存的大小 sysctl -p
vim /etc/sysctl.conf 
vm.max_map_count=262144
保存退出
修改配置后 重启机器
#shutdown -r now
再次启动 elasticsearch
[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: ["node1"]
#node1  为该机器的主机名

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值