This guide covers the complete process of setting up Elasticsearch 7.x on a Linux environment, including download, configuration, user setup, and automatic startup configuration.
Downloading the Distribution Package
Obtain the desired Elasticsearch version from the official archive repository. The folowing commands download the archive and extract it too the system:
</div>Initial Launch and Common Errors
--------------------------------
Attempting to start Elasticsearch directly may produce errors. The most frequent issue encountered is the security restriction that prevents the service from running under the root account:
<div>```
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0
[2019-12-17T14:41:57,321][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler]
uncaught exception in thread [thread-name]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163)
...
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105)
Navigate to the configuration directory and modify the JVM options file to address potential garbage collection warnings:
</div>Add the following parameter at the end of the file to resolve multiprocessor awareness issues:
<div>```
-XX:+AssumeMP
Elasticsearch requires a non-privileged user for secure operation. Create a dedicated user and assign ownership of the installation directory:
</div>Starting the Service
--------------------
Ensure the firewall permits traffic on port 9200, which is the default Elasticsearch listaning port. Then initiate the service:
<div>```
/opt/elasticsearch/bin/elasticsearch -d
Verifying the Installation
Confirm the service is running by checking listening ports:
</div>Alternatively, query the cluster health endpoint:
<div>```
curl 'http://localhost:9200/?pretty'
To enable automatic startup on boot, create a systemd service unit:
</div>Add the following configuration:
<div>```
[Unit]
Description=Elasticsearch Search Engine
[Service]
LimitNOFILE=100000
LimitNPROC=100000
ExecStart=/opt/elasticsearch/bin/elasticsearch
User=elastic
Group=elastic
[Install]
WantedBy=multi-user.target
</div>