Elasticsearch安装(6.4.3版)
一 了解es背景知识
https://www.cnblogs.com/pangyangqi/p/11277354.html
ElasticSearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析和探索的能力。充分利用ElasticSearch的水平伸缩性,能使数据在生产环境变得更有价值。ElasticSearch 的实现原理主要分为以下几个步骤,首先用户将数据提交到Elastic Search 数据库中,再通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据,当用户搜索数据时候,再根据权重将结果排名,打分,再将返回结果呈现给用户。
Elasticsearch是与名为Logstash的数据收集和日志解析引擎以及名为Kibana的分析和可视化平台一起开发的。这三个产品被设计成一个集成解决方案,称为“Elastic Stack”(以前称为“ELK stack”)。
Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。”Elasticsearch是分布式的,这意味着索引可以被分成分片,每个分片可以有0个或多个副本。每个节点托管一个或多个分片,并充当协调器将操作委托给正确的分片。再平衡和路由是自动完成的。“相关数据通常存储在同一个索引中,该索引由一个或多个主分片和零个或多个复制分片组成。一旦创建了索引,就不能更改主分片的数量。
Elasticsearch使用Lucene,并试图通过JSON和Java API提供其所有特性。它支持facetting和percolating,如果新文档与注册查询匹配,这对于通知非常有用。另一个特性称为“网关”,处理索引的长期持久性;例如,在服务器崩溃的情况下,可以从网关恢复索引。Elasticsearch支持实时GET请求,适合作为NoSQL数据存储,但缺少分布式事务。
二 es安装
下载elasticsearch https://www.elastic.co/downloads/elasticsearch
1.linux tar包 # wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz 如果觉得官方的下载太慢,可以下载我服务器上的: # wget https://www.pangyangqi.cn/download/elasticsearch-6.4.3.tar.gz 2.解压tar包 # tar -zxvf wget elasticsearch-6.4.3.tar.gz 3.重命名文件名(可以不用) # mv elasticsearch-6.4.3 elasticsearch 4.新增用户 # groupadd es # useradd es -g es -p es 5.授权文件夹 # chown -R es:es /usr/local/elasticsearch 我的是在/usr/local 下安装着 6.配置elasticsearch.yml # vi elasticsearch.yml 底部追加 network.host: 0.0.0.0 http.port: 9200
7.切换用户 # su es # cd elasticsearch/bin 8.启动es # ./elasticsearch 报错处理
ERROR: max file descriptors [1024] for elasticsearch process likely too low, increase to at least [65536]
切换到root用户,编辑limits.conf添加如下内容vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
ERROR: bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
1、切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
9.运行curl 服务器的ip:9200/
10.后台运行es
# ./elasticsearch -d
三 安装ik中文分词插件
# cd /usr/local/elasticsearch # ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.3/elasticsearch-analysis-ik-6.4.3.zip
切换到普通用户启动即可
elasticsearch启动常见的几个报错
2019.02.12 16:24:31字数 242阅读 4034
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换到root用户,编辑limits.conf添加如下内容vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
[2]: max number of threads [3818] for user [es] is too low, increase to at least [4096]
最大线程个数太低。修改配置文件etc/security/limits.conf,增加配置* soft nproc 4096
* hard nproc 4096
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144vi /etc/sysctl.conf
sysctl -p
执行命令sysctl -p生效
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
问题原因:因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动
解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:bootstrap.memory_lock: false
bootstrap.system_call_filter: false