Elastic Search multi hosts setting - unix1998/technical_notes GitHub Wiki
To install and set up a multi-node Elasticsearch cluster, follow these general steps:
Prerequisites:
- Java: Ensure Java is installed on all nodes. Elasticsearch requires Java 8 or later.
java -version
- System Requirements: Ensure each node meets the minimum system requirements for Elasticsearch.
Installation:
-
Download and Install Elasticsearch:
- Download the latest version of Elasticsearch from the official website.
- Install it on each node using the appropriate package manager or by extracting the tar.gz file.
# For Debian-based systems sudo apt-get update sudo apt-get install elasticsearch # For RHEL-based systems sudo yum install elasticsearch
-
Configure Elasticsearch:
- Edit the
elasticsearch.yml
configuration file on each node, typically located at/etc/elasticsearch/elasticsearch.yml
. - Set unique node names and the same cluster name for all nodes:
cluster.name: my_cluster node.name: node_1 # Change this for each node
- Configure the network settings:
network.host: 0.0.0.0 # or specific IP address http.port: 9200
- Configure discovery settings for the multi-node cluster:
discovery.seed_hosts: ["node1_ip", "node2_ip", "node3_ip"] cluster.initial_master_nodes: ["node1", "node2", "node3"] # Mention the master-eligible nodes
- Ensure each node's
path.data
andpath.logs
directories are set appropriately:path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch
- Edit the
-
Start Elasticsearch:
- Start the Elasticsearch service on each node:
sudo systemctl start elasticsearch
- Enable it to start on boot:
sudo systemctl enable elasticsearch
- Start the Elasticsearch service on each node:
-
Verify the Cluster:
- Verify that each node has joined the cluster by checking the cluster health and node information:
curl -X GET "http://node1_ip:9200/_cluster/health?pretty" curl -X GET "http://node1_ip:9200/_cat/nodes?v"
- Verify that each node has joined the cluster by checking the cluster health and node information:
Post-Installation:
-
Set Up Index Replicas:
- Configure index settings to ensure data is replicated across nodes for high availability:
{ "settings": { "index": { "number_of_replicas": 2 } } }
- Configure index settings to ensure data is replicated across nodes for high availability:
-
Monitor the Cluster:
- Use Kibana or any other monitoring tools to keep track of the cluster's health and performance.
- Regularly check logs and Elasticsearch APIs for any issues.
-
Secure the Cluster:
- Implement security features such as TLS encryption, user authentication, and role-based access control (RBAC).
elasticsearch.yml
):
Example Configuration (cluster.name: my_cluster
node.name: node_1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["node1_ip", "node2_ip", "node3_ip"]
cluster.initial_master_nodes: ["node1", "node2", "node3"]
By following these steps, you can set up a multi-node Elasticsearch cluster that is scalable and resilient.