ES(Elastic Search)入门和springboot结合(一)

ES(Elastic Search)入门和springboot结合

带你熟悉和了解ES 和结合SpringBoot来编写demo

1、ES入门

1、全文检索概念和ES基本介绍

  1. 全文检索:计算机程序通过扫描,对每个词建立一个索引,指明该词在文章中出现的次数和位置,当用户查询时,根据索引去查,类似字典的检索字表查字的过程

  2. 全文检索和数据库检索区别
    全文:效率高于数据库、搜索结果存在相关度排序、不区分大小写

2、安装

2.1、下载ES,
各版本集合:
https://www.elastic.co/cn/downloads/past-releases#elasticsearch
7-4-2:
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-4-2
linux:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz
2.2、创建用户》上传》安装

创建用户 之后再上传和解压
groupadd es
创建cxq用户到 es组下
useradd cxq -g es
==修改密码:cxq ==
passwd cxq
使用普通用户登录:
tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz

2.3、启动

./elasticsearch
出现: Security is disabled 启动成功
报错:can not run elasticsearch as root ES默认不能用root用户》》参考上面提到的创建用户要用cxq(普通用户来启动)

2.4、验证:

curl localhost:9200

2.5、ES开启远程连接权限:

修改配置文件:elasticsearch.yml 修改如下配置: 注意格式空格
network.host: 0.0.0.0

2.6、启动报错处理:

修改配置记得切换到root

ERROR: [3] bootstrap checks failed
报错[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
处理方法:
vim /etc/security/limits.conf
在后面追加如下内容,修改系统配置:
* soft nofile 65536
* hard nofile 65536  
* soft nproc 4096
* hard nproc 4096
退出当前所有用户,重新登陆 验证:
[root@localhost ~]# ulimit -Hn
65536
[root@localhost ~]# ulimit -Hu
4096
[root@localhost ~]# ulimit -Su
4096
[root@localhost ~]# ulimit -Sn
65536
报错[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
处理方法:
修改:vim /etc/security/limits.d/20-nproc.conf 
![原](https://img-blog.csdnimg.cn/20200622160728171.png)
修改为启动ES的用户名:
![修改为启动ES的用户名](https://img-blog.csdnimg.cn/20200622160740826.png)

报错[3]: 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
解决方法:
修改:追加:
vm.max_map_count=655360
保存退出后执行:
sysctl -p
重新启动ES
报错:ERROR: [4] 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
解决方法:
cd ..
cd config
vim elasticsearch.yml
# Use a descriptive name for the node:
#
 node.name: node-1
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
 cluster.initial_master_nodes: ["node-1"]
注意空格

重新启动ES :Security is disabled 成功
浏览器输入:http://服务器IP:9200/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值