Installing Elasticsearch on Linux

Note: If the Service Monitor Agent was not previously installed, it will be installed with Elasticsearch. You'll need to use the interactive command line to install it. See Installing MongoDB on Linux for more details. You can also install the Service Monitor Agent separately before installing Elasticsearch.

Installing Elasticsearch

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

Note: Elasticsearch has a dependency on AdoptOpenJDK v11.0.9, 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, netbraintemp10.0a.

4.Run the cd /opt/netbraintemp10.0a command to navigate to the /opt/netbraintemp10.0a directory.

5.Download the installation package.

Option 1: If the Linux server has no access to the Internet, obtain the elasticsearch-linux-x86_64-rhel-6.8.12-10.0a.tar.gz file from NetBrain and then upload it to the /opt/netbraintemp10.0a 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/netbraintemp10.0a directory to directly download the elasticsearch-linux-x86_64-rhel-6.8.12-10.0a.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-rhel-6.8.12-10.0a.tar.gz command under the /opt/netbraintemp10.0a directory to extract installation files.

[[email protected] netbraintemp10.0a]# tar -zxvf elasticsearch-linux-x86_64-rhel-6.8.12-10.0a.tar.gz
Elasticsearch/
Elasticsearch/config/
...
Elasticsearch/install.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=Admin1.# 
 
# 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 32767.
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
INFO: Creating installation log file SUCCEEDED
INFO: Collecting system information SUCCEEDED.
INFO: Component Name: Elasticsearch
INFO: RPM name: elasticsearch-oss
INFO: Service name: elasticsearch
INFO: Installation path: /usr/share/elasticsearch
INFO: Config path: /etc/elasticsearch
INFO: Preprocessing SUCCEEDED
INFO: Start installing Elasticsearch... 
INFO: Starting to install Elasticsearch ... 
INFO: Starting to system checking... 
INFO: System checking SUCCEEDED
INFO: Starting to configuration parameters checking...
...
Preparing...                          ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Updating / installing...
   1:elasticsearch-oss-0:6.8.12-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
INFO: Official rpm package installing SUCCEEDED.
INFO: Starting to configuration parameters updating...
...
INFO: Successfully connected to the elasticsearch. The setup is complete.
 elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-02-24 00:11:21 EST; 31s 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 -...
INFO: Successfully installed Elasticsearch. Service is running.
   Active: active (running) since Wed 2021-02-24 00:11:55 EST; 10s ago
INFO: netbrainagent has been restarted.
INFO: Backing up uninstall.sh SUCCEEDED
INFO: Succeeded in installing 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.8.12",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "a9861f4",
    "build_date" : "2020-08-12T07:27:20.804867Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.3",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

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

Admin1.#

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 all the cluster members' IP addresses or FQDNs (if the BindIp is set as 0.0.0.0).

Note: Use ',' to separate each of the 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 master-eligible-only. 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.