Centos单机部署Elasticsearch7.2集群
配置node0
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: estest # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: test1 # # Add custom attributes to the node: # node.attr.rack: r1 node.master: true node.data: true # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: data # # Path to log files: # path.logs: logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 0.0.0.0 # # Set a custom port for HTTP: # http.port: 9200 # 内部节点通信端口 transport.tcp.port: 9300 # 开启安全防护 http.cors.enabled: true http.cors.allow-origin: /.*/ # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # 设置可参选master的节点 #discovery.seed_hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] discovery.seed_hosts: ["127.0.0.1", "[::1]"] # ping超时时长,默认3S,适当修改,防止脑裂 discovery.zen.ping_timeout: 120s client.transport.ping_timeout: 60s http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type # # Bootstrap the cluster using an initial set of master-eligible nodes: # #cluster.initial_master_nodes: ["node-1", "node-2"] cluster.initial_master_nodes: ["test1","test2","test3"] #cluster.initial_master_nodes: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] # # For more information, consult the discovery and cluster formation module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true
配置node1
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: estest # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: test2 # # Add custom attributes to the node: # node.attr.rack: r1 node.master: false node.data: true # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: data # # Path to log files: # path.logs: logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 0.0.0.0 # # Set a custom port for HTTP: # http.port: 9201 # 内部节点通信端口 transport.tcp.port: 9301 # 开启安全防护 http.cors.enabled: true http.cors.allow-origin: /.*/ # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # 设置可参选master的节点 #discovery.seed_hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] discovery.seed_hosts: ["127.0.0.1:9300"] # ping超时时长,默认3S,适当修改,防止脑裂 discovery.zen.ping_timeout: 120s client.transport.ping_timeout: 60s http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type # # Bootstrap the cluster using an initial set of master-eligible nodes: # #cluster.initial_master_nodes: ["node-1", "node-2"] cluster.initial_master_nodes: ["test1","test2","test3"] #cluster.initial_master_nodes: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] # # For more information, consult the discovery and cluster formation module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true
配置node2:
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: estest # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: test3 # # Add custom attributes to the node: # node.attr.rack: r1 node.master: false node.data: true # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: data # # Path to log files: # path.logs: logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 0.0.0.0 # # Set a custom port for HTTP: # http.port: 9202 # 内部节点通信端口 transport.tcp.port: 9302 # 开启安全防护 http.cors.enabled: true http.cors.allow-origin: /.*/ # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # 设置可参选master的节点 #discovery.seed_hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] discovery.seed_hosts: ["127.0.0.1:9300"] # ping超时时长,默认3S,适当修改,防止脑裂 discovery.zen.ping_timeout: 120s client.transport.ping_timeout: 60s http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type # # Bootstrap the cluster using an initial set of master-eligible nodes: # #cluster.initial_master_nodes: ["node-1", "node-2"] cluster.initial_master_nodes: ["test1","test2","test3"] #cluster.initial_master_nodes: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"] # # For more information, consult the discovery and cluster formation module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true
系统配置:
vm.max_map_count=655360
启动三个节点:
nohup ./bin/elasticsearch > log 2>&1 &