之前项目中用过ElasticSearch,是一个不错的搜索引擎,现在想深入的学习一下,尝试自己安装,遇到不少困难,踩了不少坑,参考网上很多优秀的文章得以解决,下面对自己的安装过程做一个记录:
一、环境准备
- 虚拟机、jdk还用原先准备好的,环境准备可以参考另一篇文章环境搭建
- 下载elasticsearch安装包
下载链接:https://pan.baidu.com/s/1G9AmQ3iflTl4R7hJvjVbPA
提取码:jjg6
二、安装es
1、将压缩包上传到虚拟机指定目录,并解压,整体命令如下:
[root@localhost ~]# cd /usr
[root@localhost usr]# mkdir elastic
[root@localhost usr]# cd elastic
[root@localhost elastic]# rz
[root@localhost elastic]# tar -zxvf elasticsearch-7.1.1-linux-x86_64.tar.gz
[root@localhost elastic]# ls
elasticsearch-7.1.1 elasticsearch-7.1.1-linux-x86_64.tar.gz
三、启动
启动遇到很多问题,需要做很多配置:
1、不支持root用户启动
需要创建其他用户登录,赋予权限,并启动
- 添加并切换用户
user add zrk
tail -1 /etc/passwd
passwd zrk
chown -R zrk elasticsearch-7.1.1
su - zrk
- 启动
cd /usr/elastic/elasticsearch-7.1.1/bin
./elasticsearch
#后台启动
./elasticsearch -d
2、bootstrap checks failed
报错信息:
ERROR: [4] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3891] for user [zrk] 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]
[4]: 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
解决方法:参考链接
3、外网无法访问
通过浏览器无法访问到虚拟机的9200端口
解决办法:参考链接
四、访问
[root@localhost elastic]# curl localhost:9200
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Z3U7OMa7QDOEmP9Cdw69dg",
"version" : {
"number" : "7.1.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "7a013de",
"build_date" : "2019-05-23T14:04:00.380842Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
虚拟机、浏览器(postman代替)皆可访问