elasticearch是目前最流行的实时的分布式搜索和分析引擎,水平扩展能力非常强,提供restful接口简化使用难度。
文档
学习一个技术最好的方式就是阅读官方文档,英语没有那么好的最好方式就是看中文版
elasticsearch权威指南中文翻译,这是我找到的最好一个在线版本。
离线文档下载点击这里

工欲善其事必先利其器,下面介绍安装过程中遇到的坑:
下载
可以到elasticsearch中文社区下载,但是速度很慢。这里是国内镜像地址,速度还可以,就是版本不是最新的。
安装
elasticsearch的安装需要依赖jdk8或openJDK11,最新版本据说内置了jdk?
不管是通过下载tar包,还是npm,debian包的方式,都注意不要放在root目录下,要放在非root用户目录下,不然权限问题会搞得你头大。
解压
tar -zxvf elasticsearch-7.6.2.tar.gz
,切换非root用户
su - jun
进入bin下面
./elasticsearch
即可启动,如果不报错且
curl http://localhost:9200
返回json信息表示启动成功,但事情一般没有这么顺利。
-
如果提示权限不对
赋予非root用户权限,
chown -R jun:jun /home/jun/elasticsearch
-
只有本机能访问
在安装目录下修改
增加vim config/elasticsearch.yml
network.host: 0.0.0.0
或者特定的ip
另外记得防火墙放开端口
/sbin/iptables -I INPUT -p tcp --dport 9200 -j ACCEPT
-
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:切换到root用户
, 添加类似如下内容:vi /etc/security/limits.conf
备注:* 代表Linux所有用户名称(比如 hadoop)* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
-
max number of threads [3798] for user [jun] is too low, increase to at least [4096]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,
找到如下内容:vi /etc/security/limits.d/20-nproc.conf
-
soft nproc 3978
#修改为
- soft nproc 4096
-
-
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:最大虚拟内存太小
root用户执行命令:
[[email protected] ~]# sysctl -w vm.max_map_count=262144
-
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
修改elasticsearch.yml
取消注释保留一个节点
,这里的node-1是默认的cluster.initial_master_nodes: ["node-1"]
另外head(nodejs)、分词器的安装网上都是,这里就不多说了