Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Deploying Elasticsearch on a Linux Server

Tech 1

Environment Setup

Begin by establishing a dedicated directory for the application and acquiring the necessary binaries.

INSTALL_DIR="/usr/local/elastic-stack"
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR

ES_VERSION="8.12.2"
curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz

System User Configuration

For security reasons, the service must not run as the root user. Create a dedicated system account and assign ownership of the installation directory.

sudo useradd -r -s /bin/false es_service
sudo chown -R es_service:es_service /usr/local/elastic-stack/

Kernel Parameter Tuning

Adjust the virtual memory map count to prevent startup failures.

echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

File Descriptor Limits

Ensure the system allows sufficient file descriptors for the search engine.

echo "* soft nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "* hard nofile 65536" | sudo tee -a /etc/security/limits.conf

Application Configuration

Modify the configuration file to suit the development environment requirements.

vi /usr/local/elastic-stack/elasticsearch-${ES_VERSION}/config/elasticsearch.yml

Add or update the following property to disable security features:

xpack.security.enabled: false

Service Execution

Launch the process using the dedicated user account. The -d flag runs it as a background daemon.

sudo -u es_service /usr/local/elastic-stack/elasticsearch-${ES_VERSION}/bin/elasticsearch -d

Deployment Verification

Confirm the service is operational by querying the default port via curl.

curl http://localhost:9200

A successful response will return a JSON payload containing the cluster name, node UUID, and version details.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.