下载地址
https://www.elastic.co/cn/downloads/elasticsearch
在downloads 后面会有zip, tar, deb,msi等多种格式,可根据需要下载,本人安装在centos上,选择了tar
解压
tar -zvxf elasticsearch-5.6.3.tar.gz
cd elasticsearch-5.6.3
bin/elasticsearch
也可以后台启动:
bin/elasticsearch -d
我在root用户执行此命令,报错:
~[elasticsearch-5.6.3.jar:5.6.3] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106)
elasticsearch 默认不允许在root用户下运行。所以可以创建一个新用户组和用户:
groupadd es
useradd es1 -g es -p yourpassword
chown -R es1:es elasticsearch-5.6.3
su es1
这时在本机上执行:
curl http://localhost:9200会看到下面的结果:
{
"name" : "G15MpYf",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "z9C6udnBRFKclBJRYM6ujQ",
"version" : {
"number" : "5.6.3",
"build_hash" : "1a2f265",
"build_date" : "2017-10-06T20:33:39.012Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
但如果在别的机器上访问是访问不到的。
需要修改elasticsearch的配置文件,
vim config/elasticsearch.yml
network.host配置修改成如下配置:
network.host: 0.0.0.0
这时如果启动elasticsearch ,会有下面的错误:
[2017-10-30T12:11:25,565][ERROR][o.e.b.Bootstrap] [G15MpYf] node validation exception
[2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
需要修改Linux的两个配置文件,切换回root用户,
1. [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 这个错误需要修改下面这个文件:
注意:这个文件由root用户修改再切换回es1用户时才会起效。
vim /etc/security/limits.conf
添加配置,第一列也可以用*号,表示所有用户
es1 soft nofile 819200
es1 hard nofile 819200
[2]max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
需修改sysctl文件:
vim /etc/sysctl.conf
增加下面配置项:
vm.max_map_count=655360
保存退出后,执行:
sysctl -p
切换回es1用户,再次启动elasticsearch,其他机器就可以通过http://ip:9200 访问数据了。
安装完毕,其他api有待进一步使用总结。
http://blog.csdn.net/abcd_d_/article/details/53018927