本文章使用CentOS7.9.2009服务器安装elasticsearch7.11.1软件
1.服务器信息
[root@elasticsearch ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@elasticsearch ~]#
[root@elasticsearch ~]# cat /etc/hosts | grep elasticsearch
192.168.10.243 elasticsearch
[root@elasticsearch ~]#
2.ES安装
2.1.创建ES用户
创建ES用户和组
命令:
useradd elk
[root@elasticsearch ~]# useradd elk
[root@elasticsearch ~]# cat /etc/passwd | grep elk
elk:x:1000:1000::/home/elk:/bin/bash
[root@elasticsearch ~]#
2.2.OS系统参数调优
-->编辑/etc/security/limits.conf文件,添加如下调优配置
* soft nofile 65535
* hard nofile 65535
[root@elasticsearch ~]# cat /etc/security/limits.conf | grep -Ev "^#|^$"
* soft nofile 65535
* hard nofile 65535
[root@elasticsearch ~]#
-->编辑/etc/security/limits.d/20-nproc.conf文件,添加如下调优配置
* soft nproc 4096
root soft nproc unlimited
[root@elasticsearch limits.d]# cat /etc/security/limits.d/20-nproc.conf | grep -Ev "^#|^$"
* soft nproc 4096
root soft nproc unlimited
[root@elasticsearch limits.d]#
-->重启服务器生效
2.3.配置java环境变量
-->上传JDK11.0.10版本至CentOS7.9.2009并解压
[root@elasticsearch ~]# ls -l jdk-11.0.10_linux-x64_bin.tar.gz
-rw-r--r-- 1 root root 181727980 Oct 18 20:08 jdk-11.0.10_linux-x64_bin.tar.gz
[root@elasticsearch ~]# tar -zxvf jdk-11.0.10_linux-x64_bin.tar.gz -C /usr/local/
[root@elasticsearch ~]# cd /usr/local/
[root@elasticsearch local]# ls -ld jdk-11.0.10/
drwxr-xr-x 8 root root 115 Oct 25 09:20 jdk-11.0.10/
[root@elasticsearch local]#
-->配置JDK环境变量,编辑/etc/profile文件,添加如下代码
export JAVA_HOME=/usr/local/jdk-11.0.10
export PATH=$PATH:$JAVA_HOME/bin
[root@elasticsearch ~]# tail -n2 /etc/profile
export JAVA_HOME=/usr/local/jdk-11.0.10
export PATH=$PATH:$JAVA_HOME/bin
[root@elasticsearch ~]#
-->生效环境变量,并查看JDK版本,显示出版本信息,则证明安装成功
命令:
source /etc/profile
java -version
[root@elasticsearch ~]# source /etc/profile
[root@elasticsearch ~]# java -version
java version "11.0.10" 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
[root@elasticsearch ~]#
2.4.安装ES7.11.1
-->官网下载ES7.11.1版本
地址:
Past Releases of Elastic Stack Software | Elastic
--> 上传elasticsearch7.11.1版本至CentOS7.9.2009并解压
[root@elasticsearch ~]# ls -l elasticsearch-7.11.1-linux-x86_64.tar.gz
-rw-r--r-- 1 root root 322835716 Oct 18 20:11 elasticsearch-7.11.1-linux-x86_64.tar.gz
[root@elasticsearch ~]# tar -zxvf elasticsearch-7.11.1-linux-x86_64.tar.gz -C /usr/local/
[root@elasticsearch ~]# cd /usr/local/
[root@elasticsearch local]# ls -ld elasticsearch-7.11.1/
drwxr-xr-x 10 root root 167 Oct 25 09:39 elasticsearch-7.11.1/
[root@elasticsearch local]#
-->编辑/usr/local/elasticsearch-7.11.1/config/elasticsearch.yml并保存
对于ES单节点,只需更改如下配置,其它保持不变
network.host: 0.0.0.0
#网络地址设置为0.0.0.0表示用来监听全网卡接收外部请求,还可以为实际IP地址等
[root@elasticsearch config]# pwd
/usr/local/elasticsearch-7.11.1/config
[root@elasticsearch config]# cat 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
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: elasticsearch
#
# 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:
#