elasticSearch的安装

前言

1. 什么是elasticsearch?

         ElasticSearch是一个分布式,高性能、高可用、可伸缩的搜索和分析系统

2. 什么是Elastic Stack?

         Elastic Stack,前身缩写是ELK,就是ElasticSearch + LogStash + Kibana

linux ES的安装

1.下载elasticsearch-7.3.2 tar包 下载地址(https://www.elastic.co/cn/downloads/elasticsearch)
2.上传到linux,解压 tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
3.进入解压后的 elasticsearch-7.3.2文件夹的bin目录下 执行./elasticsearch

         执行结果如下:

         这个错误,是因为使用root用户启动elasticsearch,elasticsearch是不允许使用root用户启动的
         解决方案如下:

groupadd liulong
useradd liulong -g liulong
cd /opt     [elasticsearch-7.3.2所在路径]
chown -R liulong:liulong elasticsearch-7.3.2

修改配置

1、调整jvm内存大小(机器内存够也可不调整)

vim config/jvm.options

-Xms512m
-Xmx512m
2、修改network配置,支持通过ip访问

vim config/elasticsearch.yml

cluster.name=liulong
node.name=node-1
network.host: 192.168.204.209
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
此时,进入bin目录下执行./elasticsearch还会报错
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] vm最大虚拟内存,max_map_count[65530]太低,至少增加到[262144]

vim /etc/sysctl.conf

vm.max_map_count=655360
sysctl -p   使配置生效
descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] 最大文件描述符[4096]对于elasticsearch进程可能太低,至少增加到[65536]

vim /etc/security/limits.conf

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

* 所有用户
nofile - 打开文件的最大数目
noproc - 进程的最大数目
soft 指的是当前系统生效的设置值
hard 表明系统中所能设定的最大值
max number of threads [2048] for user [tongtech] is too low, increase to at least [4096] 用户的最大线程数[2048]过低,增加到至少[4096]

vim /etc/security/limits.d/90-nproc.conf

* soft nproc 4096

启动

su liulong
cd /opt/elasticsearch-7.3.2/bin
./elasticsearch 或  ./elasticsearch -d   (以后台方式运行)
注意:注意开放端口或者关闭防火墙(centos7)
         1. 查询防火墙状态:firewall-cmd --state          2. 关闭防火墙:systemctl stop firewalld.service          3. 开启防火墙: systemctl start firewalld.service          4. 禁止firewall开机启动:systemctl disable firewalld.service

启动成功:

原文地址:https://www.cnblogs.com/liulong99/p/liulong99.html