Single Node ElasticSearch and Kibana Installation Instructions

简体中文

Summary

To support the new features, we have added ES nodes. You can configure ES as a single node or cluster depending on the data situation and status; enable Xpack, enable permission authentication (requires Kibana installation).
The official documentation Set up Elasticsearch has installation instructions for each OS, Installing Elasticsearch page provides links to instructions for various installation packages, which can be consulted. This document provides instructions for installing ES and Kibana on a single-node Linux server.

Setup ES

  1. First make sure you have a JDK in your environment. Elasticsearch 7.x package includes the OpenJDK11 package, if you need to use your own version, refer to the official documentation to set the JAVA_HOME environment variable.

  2. Create an ES-specific user, as it is not possible to start with root user.

    1
    useradd elasticsearch

    Create the ES directory and grant permissions to the elasticsearch user.

    1
    2
    3
    cd /home
    mkdir /es
    chown -R elasticsearch:elasticsearch /home/es/
  3. Upload elasticsearch-7.14.0-linux-x86_64.tar.gz in the zip archive, or you can go to the official website to download it or use other methods to download it.

  4. Unpacked:

    1
    tar -zxvf elasticsearch-7.14.0-linux-x86_64.tar.gz
  5. Modify the configuration file and go to the unpacked directory:

    1
    cd elasticsearch-7.14.0/config

    First backup the configuration file elasticsearch.yml, and then modify:

    1
    2
    3
    4
    5
    6
    7
    8
    cp elasticsearch.yml elasticsearch.yml.bak 
    vim elasticsearch.yml
    ------------------------------
    network.host: ${ip of this server}
    http.port: 9200
    discovery.seed_hosts: ["${ip of this server}"]
    discovery.type: single-node # single-node mode
    ------------------------------
  6. Open ports of 9200 and 9300, or turn off the firewall.

  7. According to the configuration file, create the data directory to store es data.

    1
    mkdir data
  8. Give the ES user all ES-related permissions; switch to the elasticsearch user; start ES in the bin directory:

    1
    2
    3
    4
    chown -R elasticsearch:elasticsearch ./*
    su – elasticsearch
    cd /home/es/elasticsearch-7.14.0/bin
    ./elasticsearch &

    You may get an error after startup:

    1
    2
    trying to update state on non-existing task geoip-downloader
    [ERROR][o.e.i.g.GeoIpDownloader ] [18789989a729] error updating geoip database [GeoLite2-Country.mmdb]

    This error can be ignored; to resolve it, see Appendix 1. Resolving ES Startup Error Reporting.

  9. Verify startup by running locally:

    1
    curl http://${ip}:9200/

    The return result is as follows.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    {
    "name" : "localhost.localdomain",
    "cluster_name" : "oss-es",
    "cluster_uuid" : "HKCnF4l_TOSW8-mznxM5eg",
    "version" : {
    "number" : "7.14.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
    "build_date" : "2021-07-29T20:49:32.864135063Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
    },
    "tagline" : "You Know, for Search"
    }

    That is success!
    Try again to access http://${ip}:9200/ through your browser with the same response successful result. If you can’t access it, check the firewall.


Install Kibana

  1. Refer to the official website for the installation procedure; or follow these steps:

  2. Using the root user, upload the kibana-7.14.0-linux-x86_64.tar.gz in the zip file and extract it.

    1
    tar -zxvf kibana-7.14.0-linux-x86_64.tar.gz
  3. Go to the directory and backup the configuration file kibana.yml and modify this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    cd kibana-7.14.0-linux-x86_64/config/
    cp kibana.yml kibana.yml.bak
    vim kibana.yml
    ------------------------------
    server.port: 5601
    server.host: "${ip of this server}"
    elasticsearch.hosts: ["http://${IP of the ES service}:9200"]
    elasticsearch.username: "kibana_system"
    ------------------------------
  4. Go to the /bin directory and start,

    1
    2
    cd ../bin
    ./kibana

    The interface prints a log and is successful when it finally appears as shown below!

    1
    Kibana is now available

    It can be accessed through a browser http://ip:5601.

Configure permissions (run local cluster using username and password authentication)

  1. You can refer to the official website Minimum Security Settings.

  2. Stop Kibana and Elasticsearch (if they are running).

  3. Add the xpack.security.enabled setting to the $ES_PATH_CONF/elasticsearch.yml file and set the value to true.

    1
    2
    3
    4
    5
     cd /home/es/elasticsearch-7.14.0/config
    vim elasticsearch.yml
    ----- add the following information ----
    xpack.security.enabled:true
    ----------------------------------------

    Tips:This $ES_PATH_CONF variable is the path to the Elasticsearch configuration file. If you installed Elasticsearch using an archive distribution (zip or tar.gz), the variable defaults to $ES_HOME/config. If you are using a package distribution (Debian or RPM), the variable defaults to /etc/elasticsearch..

  4. Start ES and wait for it to start successfully.

    1
    2
    cd ../bin
    ./elasticsearch
  5. Open another terminal window, go to the ES directory, and enable the Configuration Password Tool by executing the command

    1
    ./bin/elasticsearch-setup-passwords interactive

    Execute the command and follow the command line prompts to configure passwords.

  6. Configure Kibana to connect to Elasticsearch with a password, create a Kibana keystore, and add security settings:

    1
    2
    3
    cd kibana-7.14.0-linux-x86_64/
    ./bin/kibana-keystore create
    ./bin/kibana-keystore add elasticsearch.password

    When prompted, enter the password for the kibana_system user.

  7. Restart Kibana and log in to Kibana as the elastic user in your browser at “http://${kibanaIp}:5601”.

    1
    ./bin/kibana

Appendix

  1. Resolving ES startup errors
    1. Refer to How to disable geoip usage in 7.14.0
      Option: Use cluster settings API instead of elasticsearch.yml; i.e., after installing Kibana, run
      1
      2
      3
      4
      5
      6
      PUT _cluster/settings
      {
      "persistent": {
      "ingest.geoip.downloader.enabled": false
      }
      }

Comments