一、单节点
1、下载、安装JDk
1、前置安装java8
jdk-8u112-linux-x64.rpm
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
2、下载、安装、运行ES
2、下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.zip
3、解压
unzipelasticsearch-5.1.1.zip
4、运行
./bin/elasticsearch
./bin/elasticsearch -d #后台运行
tail -flogs/elasticsearch.log #查看日志
3、注意
注:ES有执行脚本的能力,因安全因素,不能在root用户下运行,强行运行会报如下错误:
org.elasticsearch.bootstrap.StartupException:java.lang.RuntimeException: can not run elasticsearch as root
解决方案:
groupadd es #增加es组
useradd es -g es -p pwd #增加es用户并附加到es组
chown -R es:es elasticsearch-5.1.1 #给目录权限
su es #使用es用户
./bin/elasticsearch-d #后台运行es
4、修改配置
外网访问
vim conf/elasticsearch.yml
修改network.host: 0.0.0.0
5、问题
(1)bootstrapchecks failed max filedescriptors [65535] for elasticsearch process is too low, increase to at least[65536]
启动linux可能出现如下类似错误
bootstrapchecks failed max filedescriptors [65535] for elasticsearch process is too low, increase to at least[65536]
解决方案
1、vim /etc/sysctl.conf
设置fs.file-max=655350
保存之后sysctl -p使设置生效
2、vim /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
3、重新使用SSH登录,再次启动elasticsearch即可。
外网访问:serverip:9200/
8、为es设置跨域访问
vim config/elasticsearch.yml #新增两行
http.cors.enabled: true
http.cors.allow-origin: "*"
(2)max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vim /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
保存之后sysctl -p使设置生效