Skip to content

Elasticsearch single-node deployment

Elasticsearch single-node deployment refers to the installation and configuration of a standalone Elasticsearch instance for centralized log storage within the ELK stack^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. This setup is typically utilized to support data indexing workflows for monitoring and visualization tools like Kibana.

Architecture

In a single-node deployment, a single host is configured to perform the roles of both cluster node and data node^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. This configuration is often chosen for learning or lab environments to demonstrate data flow, such as pipelines involving Filebeat, Kafka, and Logstash^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Installation Prerequisites

Before deploying the service, specific system limits and kernel parameters must be configured to ensure stability^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

File Descriptors and Memory Locking: System limits must be adjusted to allow the Elasticsearch user to lock unlimited memory and open a large number of files^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. This is typically configured in /etc/security/limits.d/es.conf^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Kernel Parameters: The vm.max_map_count kernel parameter must be set to at least 262144^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. This setting prevents the "max virtual memory areas vm.max_map_count [65530] is too low" error^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Configuration Steps

The process involves downloading the software, configuring the cluster settings, and setting up the Java environment^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

1. User and Directory Setup Create a dedicated non-root user (e.g., es) to run the service, and create necessary directories for data and logs^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. These directories must be owned by the service user^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

2. Java Virtual Machine (JVM) Settings Configure heap size settings in config/jvm.options to manage memory allocation^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. A typical configuration sets both minimum (-Xms) and maximum (-Xmx) heap size to 512m^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

3. Cluster Configuration Edit config/elasticsearch.yml to define node properties^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]: * Cluster Name: Defines the cluster (e.g., es.od.com)^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. * Node Name: Identifies the specific node^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. * Path Data/Logs: Specifies the storage paths for data and log files^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. * Network Host: Binds the service to the host's IP address^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. * HTTP Port: Sets the listening port, typically 9200^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Index Template Configuration

To optimize data storage for Kubernetes logs, an index template can be applied^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

A common configuration sets the number of primary shards to 5 and replicas to 0^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. The template pattern k8s* is used to match indices created by the log pipeline^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

This configuration can be applied via a curl command using the _template API^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

  • [[Kibana]]
  • [[Logstash]]
  • [[Filebeat]]

Sources

^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]