Installing Elasticsearch on Linux

NetBrain adopts Elasticsearch as a full-text search and analytics engine in a distributed multi-user environment.

Note: Elasticsearch has a dependency on openjdk-12.0.1, which will be automatically installed while Elasticsearch is installed.

1.Prepare a Linux server. See System Requirements for more details.

2.Log in to the Linux server as the root user.

3.Run the mkdir command to create a directory under the /opt directory to place the installation package. For example, netbraintemp8.0.3.

4.Run the cd /opt/netbraintemp8.0.3 command to navigate to the /opt/netbraintemp8.0.3 directory.

5.Download the installation package.

Option 1: If the Linux server has no access to the Internet, obtain the elasticsearch-linux-x86_64-rhel7-6.7.2-8.0.3.tar.gz file from NetBrain and then upload it to the /opt/netbraintemp8.0.3 directory by using a file transfer tool.  

Option 2: If the Linux server has access to the Internet, run the
wget <download link> command under the /opt/netbraintemp8.0.3 directory to directly download the elasticsearch-linux-x86_64-rhel7-6.7.2-8.0.3.tar.gz file from NetBrain official download site.

Note: Contact NetBrain Support Team to get the download link. The download link is case-sensitive.

Tip: Run the yum -y install wget command to install the wget command if it has not been installed on the server.

6.Run the tar -zxvf elasticsearch-linux-x86_64-rhel7-6.7.2-8.0.3.tar.gz command under the /opt/netbraintemp8.0.3 directory to extract installation files.

[[email protected] netbraintemp8.0.3]# tar -zxvf elasticsearch-linux-x86_64-rhel7-6.7.2-8.0.3.tar.gz
Elasticsearch/
Elasticsearch/config/
...
Elasticsearch/install.sh
...
Elasticsearch/upgrade.sh

7.Run the cd Elasticsearch/config command to navigate to the config directory.

8.Modify the parameters in the setup.conf file located under the config directory and save the changes. For how to modify the configuration file, refer to Editing a File with VI Editor.

[[email protected] config]# vi setup.conf
# Account info
# The UserName or Password should not contain{}[]:”,’|<>@&^%\ or a space
# The first character of UserName and Password cannot be ! or #.
# The length of UserName or Password should not be more than 64 characters
UserName=admin
Password=admin
 
# DataPath is used to store data files for Elasticsearch. This directory must be at least a second level directory and used exclusively for this purpose.
DataPath=/var/lib/elasticsearch
# LogPath is used to store log files for Elasticsearch. This directory must be at least a second level directory and used exclusively for this purpose.
LogPath=/var/log/elasticsearch
 
# BindIp: The IP address to be bound to provide service. 127.0.0.1 is not allowed. If this IP is set as default 0.0.0.0, you can use Fully Qualified 
Domain Name (FQDN) in ClusterMembers.
BindIp=0.0.0.0
 
# Port is used to start elasticsearch service on specified port. The port must be between 1025 and 65535.
Port=9200
 
# CPULimit and MemoryLimit should be ended by % and the range is from 1% to 100%.
CPULimit=35%
MemoryLimit=25%
 
# Specify whether to enable Secure Sockets Layer(SSL)
# By default, it is disabled. "no" indicates disabled; "yes" indicates enabled.
UseSSL=no
# If SSL is enabled, you must enter the full path of the server certificate and key file.
Certificate=/etc/ssl/cert.pem
PrivateKey=/etc/ssl/key.pem
CertAuth=/etc/ssl/cacert.pem
 
# SingleNode: Define the node type. Default ‘yes’ indicates standalone node. For cluster, please set it as ‘no’.
SingleNode=yes
# ClusterMembers: List all the cluster member’s IP addresses here, using ‘,’ to separate each of them.
ClusterMembers=10.10.2.34,10.10.2.35,10.10.2.36
 
#It is not supported to firstly install the master-only node.
MasterOnlyNode=no

9.Run the cd .. command to navigate to the Elasticsearch directory.

10.Run the ./install.sh script under the Elasticsearch directory.

[[email protected] Elasticsearch]# ./install.sh
Preprocessing SUCCEEDED
Starting to install Elasticsearch ...
Starting to system checking...
INFO: Collecting system information SUCCEEDED.
System checking SUCCEEDED.
Starting to configuration parameters checking...
Configuration parameters checking SUCCEEDED.
Starting to official rpm package installing...
warning: /opt/netbraintemp/Elasticsearch/sources/elasticsearch-oss-6.7.2.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Preparing...                          ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Updating / installing...
   1:elasticsearch-oss-0:6.7.2-1      ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
Official rpm package installing SUCCEEDED.
Starting to configuration parameters updating...
Configuration parameters updating SUCCEEDED.
Starting to permission setting...
Permission setting SUCCEEDED.
Starting to deamon setting...
Deamon setting SUCCEEDED.
Starting to the service of the elasticsearch. Please wait...
Starting to verification connection...
Successfully initialized the username and password in the elasticsearch.
It is the No.1 times to attempt to connect to the elasticsearch, please wait...
Successfully connected to the elasticsearch. The setup was finished.
 elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-01-14 00:43:41 EST; 27min ago
     Docs: http://www.elastic.co
 Main PID: 25040 (java)
   Memory: 4.1G
  CGroup: /system.slice/elasticsearch.service
           25040 /usr/local/jdk-11.0.1//bin/java -Xms3969m -Xmx3969m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss...
 
Apr 23 22:56:31 localhost.localdomain systemd[1]: Started Elasticsearch.
Apr 23 22:56:32 localhost.localdomain elasticsearch[25040]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Apr 23 22:56:32 localhost.localdomain elasticsearch[25040]: OpenJDK 64-Bit Server VM warning: UseAVX=2 is not supported on this CPU, setting it to UseAVX=1
Successfully installed Elasticsearch. Service is running.
INFO: Backing up uninstall.sh SUCCEEDED
INFO: Successfully installed Elasticsearch 

11. Run the following command to verify whether the Elasticsearch service is running.

curl -s -XGET --user <user:password> http://<IP address of Elasticsearch>:<Port>

Example:

[[email protected]centos Elasticsearch]# curl -s -XGET --user admin:admin http://10.10.3.142:9200
{
  "name" : "localhost.localdomain",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : " zQxrYOooSzmUMRG5C-fwrA",
  "version" : {
    "number" : "6.7.2",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "a9861f4",
    "build_date" : "2020-01-24T11:27:09.439740Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Tip: It is highly recommended to run the rm -rf /opt/netbraintemp8.0.3/Elasticsearch/config/setup.conf command to delete the setup.conf file from the server after Elasticsearch is successfully installed because the file may cause security vulnerability.

Note: If you enabled SSL, replace http with https.

Parameters

The following table describes the parameters that can be configured when installing Elasticsearch.

Parameter

Default Value

Description

UserName

admin

Specify the admin username used to log in to Elasticsearch.

Note: The username and password cannot contain any of the following special characters, and its length cannot exceed 64 characters.
{ } [ ] : " , ' | < > @ & ^ % \ and spaces

Password

admin

Specify the admin password used to log in to Elasticsearch.

Note: The password cannot be empty, and it cannot start with ! or #.

DataPath

/var/lib/elasticsearch

Specify the storage path for all data files of Elasticsearch. It is recommended to keep the default path.

Note: If you want to modify it, don't use an existing directory.

Note: Make sure the directory has more than 100GB free space to save all the data files.

Tip: You can run the df -h command to check which directory has been mounted to a large disk.

LogPath

/var/log/elasticsearch

Specify the storage path for all log files of Elasticsearch.

Note: It is recommended to keep the default path as it is. If you want to modify it, don't use an existing directory.

Note: Make sure the directory has more than 50GB free space to save all the log files.

BindIp

0.0.0.0

Enter the IP address of the network card you want to use for the Elasticsearch.

Note: Modify the value only if you have multiple network cards on this machine.

Port

9200

Specify the port number that Elasticsearch service listens to.

CPULimit

35%

Specify the maximum CPU utilization that can be consumed by Elasticsearch.

To make both MongoDB and Elasticsearch utilize the CPU resources of the same machine, the recommended value is 35%. And the sum of CPU utilization allocated to the MongoDB and Elasticsearch cannot exceed 90% of the machine's CPU.

MemoryLimit

25%

Specify the maximum memory capacity of the machine that can be consumed by Elasticsearch.

To make both MongoDB and Elasticsearch utilize the memory resources of the same machine, the recommended value is in the range of 12.5%~25%.

Note: The maximum memory that Elasticsearch can utilize is 35%. Setting the value of the MemoryLimit parameter to higher than 35% will not increase the performance of Elasticsearch. Instead, it may affect the performance of co-existing servers on this machine.

UseSSL

no

Set whether to enable the encrypted connections to Elasticsearch by using SSL.

Certificate

/etc/ssl/cert.pem

Specify the name of the SSL certificate file containing the public key.

Note: It is required only if UseSSL is enabled.

PrivateKey

/etc/ssl/key.pem

Specify the name of the SSL private key file.

Note: It is required only if UseSSL is enabled.

CertAuth

/etc/ssl/cacert.pem

Specify the name of the SSL certificate chain or intermediate certificate (class 2 or class 3 certificate).

Note: It is required only if UseSSL is enabled.

SingleNode

yes

Set whether to enable cluster deployments. The default option yes means cluster deployment is disabled. For a standalone Elasticsearch, keep the default option as it is.

If you want to deploy a cluster, change it to no.

ClusterMembers

10.10.2.34
10.10.2.35
10.10.2.36

This parameter is only required for cluster deployments. For a standalone Elasticsearch, keep the default value as it is.

If you want to deploy a cluster, specify the IP addresses of three cluster members.

Note: The first entered cluster member has the tendency to be elected as the master, but the master-eligible-only node cannot be the first member.

MasterOnlyNode

no

Set whether the node is a master-eligible one, which is only dedicated to the master node functionality. For a standalone Elasticsearch, keep the default value as it is.

Note: If you want to deploy a cluster, it is not allowed to firstly install the master-only node.