ElasticSearch安装

之前项目中用过ElasticSearch,是一个不错的搜索引擎,现在想深入的学习一下,尝试自己安装,遇到不少困难,踩了不少坑,参考网上很多优秀的文章得以解决,下面对自己的安装过程做一个记录:

一、环境准备

二、安装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代替)皆可访问

五、参考链接

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章