Skip to content

Building Elasticsearch

aborkar-ibm edited this page Dec 21, 2021 · 72 revisions

Building Elasticsearch

ATTENTION!!! This package uses Log4j. Please see details here, for the updates on security vulnerabilities.

Below versions of Elasticsearch are available in respective distributions at the time of creation of these build instructions.

The instructions provided below specify the steps to build Elasticsearch 7.12.1 on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9, 8.1, 8.2, 8.3)
  • SLES (12 SP5, 15 SP2)
  • Ubuntu (18.04, 20.04)

General Notes

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Build and Install Elasticsearch

1) Build using script

If you want to build Elasticsearch using manual steps, go to STEP 2.

Use the following commands to build Elasticsearch using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Elasticsearch/7.12.1/build_elasticsearch.sh

# Build Elasticsearch
bash build_elasticsearch.sh  [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 8. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2) Install build dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.8, 7.9, 8.1, 8.2, 8.3)

    sudo yum install -y curl git gzip tar wget patch
    • Download and install AdoptOpenJDK (OpenJDK15 with Hotspot) from here.
  • SLES (12 SP5, 15 SP2)

    sudo zypper install -y curl git gzip tar wget patch
    • Download and install AdoptOpenJDK (OpenJDK15 with Hotspot) from here.
  • Ubuntu (18.04, 20.04)

    sudo apt-get update
    sudo apt-get install -y curl git gzip tar wget patch locales
    sudo locale-gen en_US.UTF-8
    • Download and install AdoptOpenJDK (OpenJDK15 with Hotspot) from here.

Note: At the time of creation of these build instructions, Elasticsearch was verified with AdoptOpenJDK 15 version (build 15.0.2+7).

3) Set the environment variables

unset JAVA_TOOL_OPTIONS
export LANG="en_US.UTF-8"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
export JAVA_HOME=/<Path to JDK>/
export JAVA15_HOME=/<Path to JDK>/
export PATH=$JAVA_HOME/bin:$PATH

Note: Ensure system locale is set up correctly for Elasticsearch to build without encoding errors.

4) Download Elasticsearch and apply patches

cd $SOURCE_ROOT
git clone https://github.com/elastic/elasticsearch
cd elasticsearch
git checkout v7.12.1
  • Apply gradle patches to create s390x distribution
 export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Elasticsearch/7.12.1/patch"
 curl -sSL $PATCH_URL/elasticsearch.patch | git apply

5) Build

cd $SOURCE_ROOT/elasticsearch
./gradlew :distribution:archives:oss-linux-s390x-tar:assemble --parallel

6) Testing (Optional)

cd $SOURCE_ROOT/elasticsearch
./gradlew --continue test -Dtests.haltonfailure=false -Dtests.jvm.argline="-Xss2m"

Notes:

  • You can set RUNTIME_JAVA_HOME optionally to the location of the JDK(another version of the JDK that act as the runtime) that you'd like to use during testing. AdoptOpenJDK 15 with Hotspot was used at the time of this writing.
  • Certain test cases may require an individual rerun to pass. There may be false negatives due to seccomp not supporting s390x properly.
  • If there is an stack overflow error, increase the -Xss arg value in the above command.
  • Some X-Pack test cases will fail as X-Pack plugins are not supported on s390x, such as Machine Learning features.
  • The test case failures in modules server:test and :libs:elasticsearch-ssl-config:test can be ignored. They fail on both intel and s390x.
  • The node.processors setting is now bounded by the number of available processors. Some X-Pack Test case may fail for this reason. To fix this, ensure the value of node.processors setting does not exceed the number of available processors.
  • Illegal reflective access warnings in the logs are known issues. See https://github.com/elastic/elasticsearch/issues/40334.
  • For more information regarding Elasticsearch testing, please refer to their testing documentation.
  • User can also create distributions as deb, rpm and docker using below commands. In case of docker distribution, User needs to change Dockerfile to use built tar distribution instead of downloading it.
./gradlew :distribution:packages:s390x-oss-deb:assemble
./gradlew :distribution:packages:s390x-oss-rpm:assemble
./gradlew :distribution:docker:oss-docker-s390x-build-context:assemble

7) Install Elasticsearch

cd $SOURCE_ROOT/elasticsearch
sudo mkdir /usr/share/elasticsearch
sudo tar -xzf distribution/archives/oss-linux-s390x-tar/build/distributions/elasticsearch-oss-7.12.1-SNAPSHOT-linux-s390x.tar.gz -C /usr/share/elasticsearch --strip-components 1
sudo ln -sf /usr/share/elasticsearch/bin/* /usr/bin/

sudo groupadd [username]
sudo chown [username]:[username] -R /usr/share/elasticsearch/

8) Verify Elasticsearch Server

> elasticsearch --version
Version: 7.12.1-SNAPSHOT, Build: oss/tar/3186837139b9c6b6d23c3200870651f10d3343b7/2021-05-04T14:14:39.948477763Z, JVM: 15.0.2

9) Start Elasticsearch Server

elasticsearch

Use curl -X GET http://localhost:9200/ when running Elasticsearch. The output should be similar to this:

{
  "name" : "889845df506c",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Sl8OgP8ERO-G1hOB6FwIwQ",
  "version" : {
    "number" : "7.12.1-SNAPSHOT",
    "build_flavor" : "oss",
    "build_type" : "tar",
    "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7",
    "build_date" : "2021-05-04T14:13:39.771750373Z",
    "build_snapshot" : true,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Note:

  • Elasticsearch needs to be run by a non-root user which has standard permission rights, hence we have changed the owner in the above step.
  • If Access denied to Keystore error occurs on starting Elasticsearch, try updating/created new password for the keystore using
elasticsearch-keystore create -p

Installing Elasticsearch Curator client (Optional)

Elasticsearch Curator can be used to curate, or manage, Elasticsearch indices and snapshots. It can be installed using below steps:

1) Install dependencies

  • RHEL (7.8, 7.9, 8.1, 8.2, 8.3)

    sudo yum install -y python3-devel libyaml-devel
  • SLES (12 SP5)

    sudo zypper install -y libyaml-devel
    • Python 3.9.x -- Instructions for building Python 3.9.x can be found here
  • SLES (15 SP2)

    sudo zypper install -y python3-devel python3-pip libyaml-devel
  • Ubuntu (18.04, 20.04)

    sudo apt-get update
    sudo apt-get install -y python3-pip libyaml-dev

2) Install Elasticsearch Curator

  sudo pip3 install elasticsearch==7.13.4
  sudo pip3 install elasticsearch-curator==5.8.4

Note:

  • In case of an error sudo: pip3: command not found, Run above command as sudo env PATH=$PATH -H pip3 install elasticsearch-curator==5.8.4.

3) Verify Elasticsearch Curator installation

> curator --version
curator, version 5.8.4

Note:

  • In case an error related to ASCII encoding is thrown by Click, ensure your locale is correctly set. For more details, refer this.

References:

Clone this wiki locally