Centos7安装ElasticSearch6.5.4

因为ElasticSearch是基于Lucene的分布式搜索引擎,Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,所以需要先在你的环境中安装jre环境。具体可以参考这篇文章Centos7 安装和配置jre1.8。

第一步,下载ElasticSearch

https://www.elastic.co/downloads/elasticsearch

 

第二步,上传到/home/data目录下

cd /home
mkdir data
cd data
rz
第三步,解压文件并移动到elasticsearch目录下

tar -zxvf elasticsearch-6.5.4.tar.gz
cd ..
mkdir elasticsearch
mv /home/data/elasticsearch-6.5.4/ /home/elasticsearch/
第四步,启动elasticsearch

cd /home/elasticsearch/elasticsearch-6.5.4/bin
./elasticsearch
发现报错

 

表示不能使用root用户启动elasticsearch。我们需要创建一个用户来启动elasticsearch

groupadd esgroup
useradd esuser -g esgroup-p esuser
给elasticsearch目录授予esuser权限

chown esuser:esgroup -R /home/elasticsearch/
现在切换esuser用户再次启动

su esuser
./elasticsearch
如果出现如下标志表示启动成功了

 

测试一下,9200是elasticsearch的默认端口

curl http://localhost:9200


现在配置远程访问

修改elasticsearch配置文件

/home/elasticsearch/elasticsearch-6.5.4/config/elasticsearch.yml
network.host就是你的服务器的ip地址

 

在末尾添加

http.cors.enabled: true
http.cors.allow-origin: "*"


防火墙开放9200端口

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
或者关闭防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service 禁止防火墙开机启动
再次重启elasticsearch。

在Windows电脑的浏览器访问http://192.168.0.117:9200/

 

这就已经配置好了。

可能遇见的问题

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

解决办法:

vi /etc/security/limits.conf
在末尾添加,* 表示全部用户

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096
max number of threads [2048] for user [lishang] likely too low, increase to at least [4096]

解决办法:

vi /etc/security/limits.d/20-nproc.conf
将如下内容

* soft nproc 2048
修改为

* soft nproc 4096
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

解决办法:

vi /etc/sysctl.conf
文件末尾添加

vm.max_map_count=655360
执行命令

sysctl -p
重启服务器

再次启动elasticsearch,发现可以正常启动了。

转载于:https://www.cnblogs.com/zuikeol/p/10930685.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值