强调:elasticsearch是基于JDK1.8运行的,安装前请务必安装完jdk1.8(一行命令解决:yum install java-1.8.0-openjdk* -y)
cd /usr/local/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz
tar -zxf elasticsearch-5.1.1.tar.gz
./elasticsearch5.6.3/bin/elasticsearch
接下来会各种报错,一步一步解决
java.lang.RuntimeException: can not run elasticsearch as root
显示不能用root用户执行,需要切换一个非root用户进行执行
第一步:adduser esuser //这个自定义
第二步:passwd rpj199301 //这是我的密码,以防自己忘记
第三步:chown -R esuser /自己的elasticsearch安装目录 //这是赋权限
第四步:su esuser
使用esuser启动elasticsearch后接着会报如下错:
ERROR:bootstrap checks failed
max virtual memory areas vm.max_map_count[65530] is too low,increase to at least
解决方案:
要将用户的最大打开文件数设置elasticsearch为65,536,切换到root用户,编辑limits.conf 添加类似如下内容
vim /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
切换到esuser启动elasticsearch后接着会报如下错:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决方案:
切换到root用户修改配置sysctl.conf
vim /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
再次切换用户启动elasticsearch发现启动成功!
curl:http://localhost:9200
//显示如下结果说明启动成功
{
"name" : "K8LDTYN",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "2KDpZHX6RTyNpm08lq3Jqg",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
解决方案:
cd /自己elasticsearch的安装目录/config
修改 elasticsearch.yml
修改 network.host: 0.0.0.0
关闭防火墙:
systemctl stop firewalld
最后成功!!!
elasticsearch的9200端口和9300端口的区别:
9300是tcp通讯端口,集群间和TCPClient都走的它,9200是http协议的RESTful接口;
Java客户端连接的是9300接口,使用HTTP请求的方式连接的是9200端口
推荐链接(安装kibana官网最新版本也适用):
http://blog.csdn.net/houjixin/article/details/70230623