1、下载解压
cd /usr/local
mkdir elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-linux-x86_64.tar.gz
tar -zxf elasticsearch-7.8.0-linux-x86_64.tar.gz
注:官方地址下载过慢的话可以试下下方的华为镜像云,资源是一样的:
https://mirrors.huaweicloud.com/elasticsearch/7.8.0/elasticsearch-7.8.0-linux-x86_64.tar.gz
2、创建 elasticsearch 用户
useradd es
chown es:es -R /usr/local/elasticsearch/elasticsearch-7.8.0
su - es
3、单机配置修改
创建数据和日志存放地址:
mkdir -p /usr/local/elasticsearch/elasticsearch-7.8.0/data/
mkdir -p /usr/local/elasticsearch/elasticsearch-7.8.0/logs/
配置elasticsearch:
vim /usr/local/elasticsearch/elasticsearch-7.8.0/config/elasticsearch.yml
#设置绑定的ip,设置为0.0.0.0可以让任何计算机节点访问
network.host: 0.0.0.0
#默认端口
http.port: 9200
#数据和日志的存储目录
path.data: /usr/local/elasticsearch/elasticsearch-7.8.0/data/
path.logs: /usr/local/elasticsearch/elasticsearch-7.8.0/logs/
discovery.seed_hosts: []
# 通过为 cluster.initial_master_nodes 参数设置符合主节点条件的节点的 IP 地址来引导启动集群
cluster.initial_master_nodes: ["node-1"]
node.name: node-1
cluster.name: elk-es-cluster
#跨域配置,便于后面使用es-head和kabana
http.cors.enabled: true
http.cors.allow-origin: "*"
su root
vim /etc/sysctl.conf
#最后添加以下配置:注意等号两边有空格
vm.max_map_count = 655360
#【保存完毕后,从指定的文件加载系统参数(不指定即从/etc/sysctl.conf中加载)】
#执行
sysctl -p
vim /etc/security/limits.conf
#【末尾加上一下内容,首单词是用户名】
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
vim ./config/jvm.options
#这里的4g不能超过最大内存的一半,需要给lucene留内存
-Xms4g
-Xmx4g
:wq
4、启动
注意:不能用root用户 启动(使用刚创建的es用户)
./bin/elasticsearch -d
5、查看日志
vim ./logs/elasticsearch.log
6、验证是否成功启动
curl localhost:9200
出现下图效果即代表安装成功!