1、在官网下载Get Started with Elasticsearch, Kibana, and the Elastic Stack | Elastic
2、上传到CentOs(我这边在 /home/software/目录下)
3、解压 tar -zxvf
4、移动 (习惯把安装文件统一放到 /usr/local)
并进入到 /usr/local/
mv elasticsearch-8.1.0 /usr/local/
cd /usr/local/
5、进入到 cd elasticsearch-8.1.0/ ,创建文件夹 mkdir data
6、进入 cd config/ ,编辑配置文件 vim elasticsearch.yml
(需要修改的配置请看注释,根据自己的情况自行修改)
(注意:因为是yml文件,顶格写。我这里截图的时候没有顶格写,不想换图了)
修改elasticsearch.yml 后配置文件内容如下
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
# 客户端名称
#cluster.name: my-application
cluster.name: xpf-elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# 节点
node.name: es-node1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# 数据和日志存放位置
path.data: /usr/local/elasticsearch-8.1.0/data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch-8.1.0/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
# 改成0.0.0.0 , 使得外部也能访问
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
# 发现已有的节点(要和上面自己配的节点名字相同)
cluster.initial_master_nodes: ["es-node1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false
7、修改配置文件 jvm.options ,vim jvm.options
8、由于root用户下不准启动es,所以要创建一个新的用户才能够使用es。这里创建一个名叫esuser 的新用户
useradd esuser
9、给新建用户授权 chown -R esuser /usr/local/elasticsearch-8.1.0/
10、切换用户 su esuser ,启动bin下的es: bin/elasticsearch
(若报错与root用户有关,那么第9步就改成 chown -R esuser:esuser /usr/local/elasticsearch-8.1.0/ , 我这里是另一个错误)
(若上面可以直接启动成功直接到第14步)
11、切换成root用户, su root , 修改limits.conf配置
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
12、修改 sysctl.conf 配置文件
vim /etc/sysctl.conf
加入下面一行配置
vm.max_map_count=262145
刷新配置 sysctl -p
13、切换为esuser用户,启动es
su esuser
./bin/elasticsearch
14、访问 192.168.217.129:9200