Step-by-Step Guide to Installing and Configuring an Elasticsearch Cluster on CentOS
This comprehensive tutorial walks developers through preparing the operating system, disabling firewalls and SELinux, setting up users and JVM options, configuring single‑node and multi‑node Elasticsearch clusters, integrating Kibana, and deploying everything via Docker on CentOS with detailed code examples.
Introduction: In the era of information explosion, Elasticsearch (ES) provides a high‑performance, scalable search engine for enterprise applications. This guide walks developers through installing and configuring an ES service cluster from scratch on CentOS 7.
Prerequisites: OS CentOS 7‑2003, JDK 15.x, Elastic Stack 7.11.x, VMware 15.5.x.
Download sources: official, community, Huawei mirrors, or Docker images.
System preparation: disable firewalld (service firewalld stop; chkconfig firewalld off), disable SELinux (edit /etc/selinux/config, set SELINUX=disabled), set hostname, turn off swap (swapoff -a, vm.swappiness=1), adjust vm.max_map_count, configure file‑handle limits in /etc/security/limits.conf, create dedicated ES user (useradd elk; chown -R elk:elk /elk/*).
JDK configuration (optional) via /etc/profile with JAVA_HOME, JRE_HOME, PATH, CLASSPATH.
Set ES temporary directories: ES_TMPDIR and JNA_TMPDIR in environment or JVM.options.
Single‑node ES configuration: edit {ES_HOME}/config/elasticsearch.yml with cluster.name, node.name, network.host, http.port, transport.port, data and log paths, bootstrap.memory_lock, action.destructive_requires_name, node.processors, discovery.type=single-node, xpack.ml.enabled=false. Adjust JVM options in jvm.options (‑Xms1g, ‑Xmx1g, GC settings, log path).
# Example elasticsearch.yml
cluster.name: elk01
node.name: ${HOSTNAME}-9200
network.host: 192.168.86.106
http.port: 9200
transport.port: 9300
path.data: /elk/9200/data
path.logs: /elk/9200/logs
bootstrap.memory_lock: true
action.destructive_requires_name: true
node.processors: 4
discovery.type: single-node
discovery.seed_hosts: ["192.168.86.106:9300"]
cluster.initial_master_nodes: ["192.168.86.106:9300"]
xpack.ml.enabled: falseKibana configuration: edit {KIBANA_HOME}/config/kibana.yml with server.port, server.host, elasticsearch.hosts, kibana.index, xpack.ml.enabled=false.
# Example kibana.yml
server.port: 5601
server.host: "192.168.86.106"
elasticsearch.hosts: ["http://192.168.86.106:9200"]
kibana.index: ".kibana"
xpack.ml.enabled: falseCluster setup: At least three nodes (e.g., gpes06, gpes07, gpes08) with IP 192.168.86.106, each with its own ES and Kibana directories. Use the same cluster.name (elk02) and configure node.name, network.host, http/transport ports, discovery.seed_hosts, and cluster.initial_master_nodes accordingly.
Docker deployment: Verify Docker and docker‑compose versions, pull ES and Kibana images (docker.elastic.co/elasticsearch/elasticsearch:7.11.1, docker.elastic.co/kibana/kibana:7.11.1). Run single‑node container:
docker run -p 9200:9200 -p 9300:9300 --name es9200 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.11.1
docker start es9200For cluster mode, mount custom elasticsearch.yml, use host network, and start containers accordingly.
Similarly, launch Kibana containers with appropriate port mappings and configuration files.
Top Architecture Tech Stack
Sharing Java and Python tech insights, with occasional practical development tool tips.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.