ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
下面我们来看样它的安装步骤:
第一、从官网下载linux版本的elasticsearch安装程序,https://www.elastic.co/cn/downloads/elasticsearch (最好直接通过迅雷工具下载,普通下载太慢了)目前的版本是7.x的:elasticsearch-7.0.1-linux-x86_64.tar.gz
第二、centos服务器安装ftp软件(winSCP等),通过ftp软件把elasticsearch-7.0.1-linux-x86_64.tar.gz上传到服务器的opt/mysoft目录下。
第三、提供tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz 解压到当前目录下,通过命令:mv elasticsearch-7.0.1/ elasticsearch 重命名为elasticsearch
第四、通过命令:sh /opt/mysoft/elasticsearch/bin/elasticsearch 启动ElasticSearch。启动后会抛出异常:
解决方法:
1.添加用户:useradd elastic
2.给用户授权:chown -R elastic:elastic /opt/mysoft/elasticserch/
3.切换用户:su elastic
4.通过命令重写启动服务:sh /opt/mysoft/elasticsearch/bin/elasticsearch -d
5.输入:curl http://localhost:9200 测试能够正常访问
第五、修改配置文件:vi /opt/mysoft/elasticserch/config/elasticsearch.yml
修改network配置本机的ip地址和端口号:
network.host: 192.168.248.100
http.port: 9200
修改之后可能会出现问题:
1.警告提示 WARN [o.e.b.JNANatives ] unable to install syscall filter
使用新的linux版本就没问题了
2.ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
解决:切换到root用户,编辑limits.conf 添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
3.max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
4.max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
5.max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
解决:修改切换到root用户修改配置limits.conf 添加下面两行
命令:vi /etc/security/limits.conf
* hard nofile 65536
* soft nofile 65536
6.启动Elasticsearch时使用新建的elk用户,启动时报错:max number of threads [3895] for user [elk] is too low, increase to at least [4096]
解决方法:root用户修改:vi /etc/security/limits.d/90-nproc.conf
* soft nproc 2048
修改为:
* soft nproc 4096
7.ERROR: [1] bootstrap checks failed
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.0默认bootstrap.system_call_filter为true
禁用:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面添加:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
再次启动ElasticSearch就能够正常启动了。
注意:在外部访问ElasticSearch服务的时候,要停掉CentOS的防火墙,不然仍旧无法访问。
防火墙查看命令:service iptables status
防火墙停止命令:service iptables stop
ElasticSeach后台启动命令:sh /opt/mysoft/elasticsearch/bin/elasticsearch -d