1. Download

  • Download the Linux64(TAR) package from the official website or local community. This article uses the latest version 7.10.2 as an example
    • Official website download address
    • Chinese forum download address

2. Install

  1. Create a new user in Linux to install and run ES (using user name “ES” as an example)
useradd es -s /bin/bash
Copy the code

ES cannot run under root and a new user must be created to run ES

  1. If the installation package is downloaded or uploaded using root, you need to change the user and user group of the installation package
Chown -r es: es elasticsearch - 7.10.2 - Linux - x86_64. Tar. GzCopy the code
  1. Create directories for storing logs and data
mkdir -p /data/logs/es
mkdir -p /data/es/{data,work,plugins,scripts}
Copy the code
  1. Decompress the installation package
Tar - ZXVF elasticsearch 7.10.2 - Linux - x86_64. Tar. GzCopy the code

Configuration of 3.

  1. Modify the configuration
Vi {ES decompressed directory}/conf/ elasticSearch.ymlConfigure the node name
node.name: node-1

# Change the directory where the data is stored
path.data: /data/es/data
# Change the directory for storing logs
path.logs: /data/logs/es

Set the IP address that allows access to ES to 0.0.0.0 to allow all sourcesNetwork. The host: 0.0.0.0Configure the IP address of the current server
discovery.seed_hosts: ["* *. * *. * *. * *"]

Configure the initial primary node
cluster.initial_master_nodes: ["node-1"]

Allow cross-domain configuration, if you need to use browser client links
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code
  1. Modify system-related configurations

    • You can change the maximum number of open files and the maximum number of threads for each process. The changes take effect after you log in again
        vi /etc/security/limits.conf
        
        Add the following configuration to the end of the configuration file to change the maximum value, save and log in again
        *               soft    nofile            65536
        *               hard    nofile            65536
        *               soft    nproc            4096
        *               hard    nproc            4096
       
       Check whether the maximum number of open files for each process is changed successfully
       ulimit -Hn
       ulimit -Sn
       
       Check whether the maximum number of threads is changed successfully
       ulimit -Hu
       ulimit -Su
    Copy the code
    • Change the maximum virtual memory size to 262144
        vi /etc/sysctl.conf
        
        Add the following configuration to the end of the configuration file to change the maximum value, save and exit
        vm.max_map_count=262144
        
        # Effective configuration
        sysctl -p
    Copy the code

4. Start and verify the configuration

  1. Start the ES
Start the daemon with the -d argument./{ES unzip directory} /bin/elasticSearch -dCopy the code
  1. Verify that the startup is normal
  • If the following JSON is returned, the installation and startup are successful
{
  "name" : "es01"."cluster_name" : "elasticsearch"."cluster_uuid" : "_na_"."version" : {
    "number" : "7.10.2"."build_flavor" : "default"."build_type" : "tar"."build_hash" : "747e1cc71def077253878a59143c1f785afa92b9"."build_date" : "The 2021-01-13 T00: let 435326 z"."build_snapshot" : false."lucene_version" : "8.7.0"."minimum_wire_compatibility_version" : "6.8.0"."minimum_index_compatibility_version" : "6.0.0 - beta1"
  },
  "tagline" : "You Know, for Search"
}
Copy the code

5. Install ES standalone version on Docker

  • For details about installation and configuration, refer to the guide on the official website. You can use the following command to create a standalone ES server
# pull ES mirrorDocker pull elasticsearch: 7.12.0Create ES container
docker run -di --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node"Elasticsearch: 7.12.0ES is installed in /usr/share/elasticsearch
docker exec -it es /bin/bash
Copy the code

Note: ElasticSearch is not recommended for production use on Docker because it is an IO sensitive application (similar to a database)