创建目录es目录
cd /home
mkdir es
cd es
下载es并解压
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
tar -xvf elasticsearch-7.1.1-linux-x86_64.tar.gz
配置jdk11
vim /home/es/elasticsearch-7.1.1/bin/elasticsearch
#在首行,加入下面配置
export JAVA_HOME=/home/es/elasticsearch-7.1.1/jdk
export PATH=$JAVA_HOME/bin:$PATH
配置用户(ES不允许root用户运行它)
useradd esuser
passwd 123456
修改配置文件
vim /home/es/elasticsearch-7.15.1/config/elasticsearch.yml
/network #检索
#network.host: 192.168.0.1 改为
#开启远程访问
network.host: 0.0.0.0
# 在文件末尾写入
# 初始主节点IP地址
cluster.initial_master_nodes: ["你自己的IP地址"]
# 子节点IP地址
discovery.seed_hosts: ["你自己的IP地址"]
完整内容如下
# ======================== 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
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
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: ["10.116.93.66"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
重新授权给新增的用户
chown -R esuser /home/es
修改系统文件
vim /etc/security/limits.conf
# 在文件中插入如下内容 给 es_user 赋予更多操作空间(否则它施展不开拳脚)
esuser soft nofile 65535
esuser hard nofile 65535
esuser soft nproc 4096
esuser hard nproc 4096
完整内容如下
# /etc/security/limits.conf
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
esuser soft nofile 65535
esuser hard nofile 65535
esuser soft nproc 4096
esuser hard nproc 4096
# End of file
修改系统文件
vi /etc/sysctl.conf
# 文件中写入如下内容 增加最大运行内存
vm.max_map_count=262144
刷新内存
sysctl -p
开启ES对外默认端口 9200
firewall-cmd --zone=public --add-port=9200/tcp --permanent
#重启防火墙
firewall-cmd --reload
切换用户
su esuser
cd /home/es/elasticsearch-7.1.1/bin
#启动 -d 后台启动
./elasticsearch -d
访问 http://你的IP:9200 反馈内容即为成功