Deploying Elasticsearch on a Linux Server
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.