Bobcares

Restart Elasticsearch service – The foolproof way

by | Aug 5, 2019

Database driven search engines often take ages to respond to a query.

Here comes the importance of search engines like Elasticsearch. It uses a NoSQL database to store, retrieve, and manage data.

However, customers may get errors when executing commands to restart elasticsearch service.

At Bobcares, we often get requests from our customers to set up Elasticsearch as part of our Server Management Services.

Today, we’ll see how our Support Engineers fix restart Elasticsearch service-related errors.

 

Importance of Elasticsearch

Elasticsearch is an open-source full-text search engine with a web interface.

Unlike popular search engines, Elasticsearch uses a NoSQL database for storing data. That explains the reason for the speed and scalability of Elasticsearch.

Elasticsearch database stores the data as JSON Documents. One of the main advantages of elasticsearch is the ability to index many types of content. Therefore, it can give faster search responses by searching for an index instead of searching the entire text directly.

Thus, in a real-time environment, Elasticsearch is popular in Application search, a website search, security and business analytics, performance monitoring and many more.

 

How we set up Elasticsearch

Now, let’s see how our Support Engineers install and configure Elasticsearch.

1. Initially, we download the latest version for the respective platform from Elasticsearch download site.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.0.tar.gz

tar xvfz elasticsearch-6.7.0.tar.gz

2. Then, we edit the following fields to modify the elasticsearch.yml file to configure it on the server.

  1. Cluster name
  2. Node name
  3. Data path
  4. Path to logs
  5. Bind Address
  6. Custom Port

3. Next, we modify elasticsearch jvm.options in jvm.options file and set the memory to be allocated, for heap memory.

-Xms1g
-Xmx1g

4. Again, we switch to the elasticsearch-installed directory and start elasticsearch by run the following command.

bin/elasticsearch

That’s it. Elasticsearch will be now available for use.

Usually, the cloud installation web interface shows the health status, Elasticsearch version used, the number of nodes in the cluster, and node capacity.

 

Common problems after setting up elasticsearch

From our experience in managing servers, we’ve seen customers facing different kinds of problems after installing and configuring elasticsearch on the server.

Let’s see how our Support Team solved these common errors.

 

1. Duplicate directory

Recently, one of our customers had a problem with Elasticsearch installation. He was getting the following error while restarting the elasticsearch service.

ERROR: Cluster name [elasticsearch] subdirectory exists in data paths [/var/lib/elasticsearch/elasticsearch]. All data under these paths must be moved up one directory to paths [/var/lib/elasticsearch]

On checking, our Support Engineers found that elasticsearch subdirectory (as well as nodes subdirectory) was present inside the elasticsearch directory.

Therefore we copied the content from /var/lib/elasticsearch/elasticsearch directory to /var/lib/elasticsearch and deleted the elasticsearch folder from /var/lib/elasticsearch.

cp /var/lib/elasticsearch/elasticsearch/* /var/lib/elasticsearch/

rm -rf /var/lib/elasticsearch/elasticsearch/

At last, we restart the elasticsearch service.

That fixed the problem.

 

2. Firewall block

Often, Elasticsearch may not work due to problems with the server firewall settings. This mainly happens when server owners forget to open the port in firewall settings after installing the Elasticsearch.

As a result, it shows an error like,

Curl: (7) Failed connect to localhost:9200; Connection refused.

Normally, this error happens when the Elasticsearch gets blocked by firewall settings. The Elasticsearch default communication port is 9300. And, its HTTP interface runs on port 9200 by default.

Therefore, our Support Engineers tweaked the firewall settings for elasticsearch and that fixed the error.

 

In addition, this error Curl: (7) Failed connect to localhost:9200; Connection refused may occur when we set up a wrong port in elasticsearch.yml.  Also, some customers remove the ” # ” from line http.port: 9200.  It also cause errors when trying to start the elasticsearch.

Then, our Support Engineers check the file elasticsearch.yml and ensure that all settings are given correctly.

 

3. Incorrect Java path

Similarly, another customer had a problem while trying to start the process with systemctl. The returned status was somewhat opaque and no log files were created. The output looked like,

Aug 01 06:33:16 cs01025937.dnn4less.com systemd[1]: Started Elasticsearch.
[root@cs01025937 elasticsearch]# service elasticsearch status
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2019-08-01 06:33:28 CDT; 7s ago

Then, our Support Engineers checked the file /etc/sysconfig/elasticsearch and found that the JAVA_HOME setting in /etc/sysconfig/elasticsearch was pointing to incorrect Java path.

Therefore, we used the “whereis java” option to find the right java path. Then, we corrected the Java path in the /etc/sysconfig/elasticsearch and solved the problem.

 

[Having trouble while restarting Elasticsearch service? We’ll fix it for you.]

 

Conclusion

In short, Elasticsearch is an open-source, distributed full-text search engine based on Apache Lucene. Today, we saw how our Support Engineers set up Elasticsearch and fix restart errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.