1.Elasticsearch下载地址:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz 版本可以根据自己需求填写
2.解压elasticsearch-7.2.0-linux-x86_64.tar.gz到/home/目录:
tar -zvxf elasticsearch-7.2.0-linux-x86_64.tar.gz -C /home
重命名es
mv /home/elasticsearch-7.2.0-linux-x86_64.tar.gz /home/elasticsearch
3.在空间最大的挂载点下数据存储目录(最好在/home下,因为es只能用非root用户启动,要把目录的权限给新用户、home下分配权限比较简单)
mkdir -p /home/xx(项目名)/elasticsearch/data
mkdir -p /home/xx(项目名)/elasticsearch/logs
4.修改elasticsearch.yml:
vim /home/elasticsearch/config/elasticsearch.yml
cluster.name: elasticsearch #集群名称
node.name: es_node_1 #节点名称
path.data: /home/xx(项目名)/elasticsearch/data
path.logs: /home/xx(项目名)/elasticsearch/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
cluster.initial_master_nodes: ["es_node_1"]
保存退出
5.创建用户
添加用户:usedd elasticsearch
创建密码:passwd elasticsearch
6.分配读写文件权限给es用户
chwod -R elasticsearch:elasticsearch /home/xx(项目名)/elasticsearch/data
chwod -R elasticsearch:elasticsearch /home/xx(项目名)/elasticsearch/logs
chwod -R elasticsearch:elasticsearch /home/elasticsearch/
chmod u+x /home/elasticsearch/
7.启动
[1]: max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] 权限不足
解决方案:vim /etc/security/limits.conf
添加下面内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
[2]: max number of threads [1024] for user [leyou] is too low, increase to at least [4096] 线程数不够
解决方案:vim /etc/security/limits.d/90-nproc.conf (注意centos6和7的名称不同7的名称是20-nproc.conf)
* soft nproc 1024 改为* soft nproc 4096
[3]: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144] 进程虚拟内存
解决方案:vim /etc/sysctl.conf 添加下面内容:vm.max_map_count=655360
然后执行:sysctl -p
重启终端窗口
所有错误修改完毕,一定要重启你的 Xshell终端,否则配置无效。
8.启动(es不可以root用户启动,切记,切记)
su elasticsearch
/home/elasticsearch/bin/elasticsearch
我们在浏览器中访问 ip:9200
下一篇会写部署kibana