elastic search muti host config file : consistent and different - unix1998/technical_notes GitHub Wiki
The elasticsearch.yml
configuration file, located at /etc/elasticsearch/elasticsearch.yml
, is where most of Elasticsearch's configuration settings are defined. While many of the configuration items should be the same across all nodes in a cluster to ensure consistent behavior, some settings need to be unique or node-specific. Here’s a breakdown:
Configuration Items to be Consistent Across All Nodes:
- Cluster Name:
cluster.name: my_cluster
- Discovery Seed Hosts:
discovery.seed_hosts: ["node1_ip", "node2_ip", "node3_ip"]
- Cluster Initial Master Nodes:
cluster.initial_master_nodes: ["node1", "node2", "node3"]
- Network Host (if using the same across all nodes, but can be node-specific):
network.host: 0.0.0.0
- Minimum Master Nodes (usually set to a majority of master-eligible nodes):
discovery.zen.minimum_master_nodes: 2
- Path Data and Path Logs (can be node-specific but often consistent):
path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch
- Gateway Recovery (important for data consistency across the cluster):
gateway.recover_after_nodes: 2
Configuration Items to be Node-Specific:
- Node Name:
node.name: node_1 # Change this for each node
- Node Roles (if different nodes have different roles):
node.master: true node.data: true node.ingest: true
- Network Host (if nodes are configured to listen on different IPs):
network.host: node1_ip
- Port Settings (if using different ports for HTTP or transport on different nodes):
http.port: 9200 transport.port: 9300
- Path Data and Path Logs (if nodes use different directories):
path.data: /var/lib/elasticsearch/node1_data path.logs: /var/log/elasticsearch/node1_logs
elasticsearch.yml
for Node 1:
Example of cluster.name: my_cluster
node.name: node_1
node.master: true
node.data: true
network.host: node1_ip
http.port: 9200
path.data: /var/lib/elasticsearch/node1_data
path.logs: /var/log/elasticsearch/node1_logs
discovery.seed_hosts: ["node1_ip", "node2_ip", "node3_ip"]
cluster.initial_master_nodes: ["node1", "node2", "node3"]
elasticsearch.yml
for Node 2:
Example of cluster.name: my_cluster
node.name: node_2
node.master: true
node.data: true
network.host: node2_ip
http.port: 9200
path.data: /var/lib/elasticsearch/node2_data
path.logs: /var/log/elasticsearch/node2_logs
discovery.seed_hosts: ["node1_ip", "node2_ip", "node3_ip"]
cluster.initial_master_nodes: ["node1", "node2", "node3"]
Conclusion:
- Consistent Settings: Cluster-wide settings such as
cluster.name
,discovery.seed_hosts
, andcluster.initial_master_nodes
should be consistent across all nodes. - Node-Specific Settings: Node-specific settings such as
node.name
,network.host
,path.data
, andpath.logs
should be unique to each node. - Balance: Ensure a balance between consistency for cluster-wide settings and uniqueness for node-specific configurations to maintain a healthy and well-functioning Elasticsearch cluster.