Installation and simple configuration of Elasticsearch

Keywords: Database ElasticSearch Java firewall network


Download Address


After downloading the installation package, unzip the file:

tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz

File directory structure

Catalog configuration file describe
bin Script files, including starting elasticsearch, installing plug-ins, and so on
config elasticsearch.yml Cluster profile, user, role based related configuration
JDK JAVA Runtime Environment
data data file
lib Java class library
logs path.log log file
modules Contains all ES modules
plugins Contains installed plug-ins

Start ES

Error Alert

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8/jdk1.8.0_171/jre] does not meet this requirement
[2019-11-09T00:47:38,667][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [izbp12hdvl4ksivp63qmfrz] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init( ~[elasticsearch-7.4.2.jar:7.4.2]
    at org.elasticsearch.bootstrap.Elasticsearch.execute( ~[elasticsearch-7.4.2.jar:7.4.2]
... ...

There are two points mentioned above:

  1. Hint local is jdk8, current version of ES requires jdk11 version, new version of ES is built-in java environment, so this hint can be ignored
  2. elasticsearch cannot be started as root


Add User Groups and Users

groupadd elsearch
useradd elsearch -g elsearch

Modify users and user groups to which the es folder belongs

chown -R elsearch:elsearch  /usr/local/webserver/elasticsearch-7.4.2

Switch Users

su elsearch

Start es



Request your own IP address: 9200, and the following results will appear:

[root@iZuf6b8f6yfdzu95aqolkcZ ~]# curl
  "name" : "iZuf6b8f6yfdzu95aqolkcZ",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "bD_B1QMnRDqXgbNCG-wKxw",
  "version" : {
    "number" : "7.4.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
    "build_date" : "2019-10-28T20:40:44.881551Z",
    "build_snapshot" : false,
    "lucene_version" : "8.2.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

That means the startup was successful.

External Network Access

If you want to use external network access, you need to configure the following

Modify Configuration

vim config/elasticsearch.yml

Modify the following configuration
http.port: 9200
network.publish_host: To publish IP address

Ali Cloud Open Port

The security group can configure port 9200

Firewall issues

You need to configure the firewall port if you cannot access it yet

firewall-cmd --zone=public --add-port=9200/tcp

Firewall-related commands

View ports that have been opened by the firewall
firewall-cmd --list-ports 

systemctl start firewalld  

View Status
systemctl status firewalld   

Stop it
systemctl disable firewalld 

systemctl stop firewalld


Report errors

After making the above modifications, restart ES, found that the start error, how is the information:

ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured


  1. Switch root user, modify/etc/sysctl.conf configuration

    vim /etc/sysctl.conf 
    # Add Configuration
    vm.max_map_count = 655360
    # Execute the following command
    sysctl -p
  2. Switch root User

    vim /etc/security/limits.conf
    # Add to
    * soft nofile 65535
    * hard nofile 65535

vim /etc/security/limits.d/20-nproc.conf

  • soft nproc 4096

vim config/elasticsearch.yml

#Uncomment to keep a node
cluster.initial_master_nodes: ["node-1"]

3. Restart es and you will be successful.It is now accessible successfully through the external network.


#Plugin Installation

##View Plugin

bin/elasticsearch-plugin list

##Install Plugins

bin/elasticsearch-plugin install plug-in name

Such as installing `analysis-icu`

[root@iZuf6b8f6yfdzu95aqolkcZ elasticsearch-7.4.2]# bin/elasticsearch-plugin install analysis-icu
-> Downloading analysis-icu from elastic
[=================================================] 100%  
-> Installed analysis-icu
[root@iZuf6b8f6yfdzu95aqolkcZ elasticsearch-7.4.2]# bin/elasticsearch-plugin list

##Page View Installed Plugins

`http://External IP:9200/_cat/plugins`

Original address: [ installation and simple configuration/] (

Posted by PurpleMonkey on Fri, 08 Nov 2019 23:18:56 -0800