软件环境:
ElasticSearch5.4.3
Centos 6.8 两台
JavaJDK 1.8.0_131
集群名称:
cluster.name: test_es
node.name:
节点1: node-115
节点2: node-114
搭建开始:
前面单节点搭建完成之后,下面搭建集群,比较简单因为问题都上面遇到的解决了,剩下的问题就不多了。
安装完成之后,按照前两篇的步骤,下面修改配置文件/etc/elasticsearch/elasticsearch.yml如下:
# ======================== 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: test_es #集群名称必须一样 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node-115 #两台服务器节点名字不能相同 # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: /mnt/elasticsearch-5.4.3/data # # Path to log files: # path.logs: /mnt/elasticsearch-5.4.3/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: 10.144.255.45 #本机的域内ip # # Set a custom port for HTTP: # #http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # discovery.zen.ping.unicast.hosts: ["10.163.189.82"] #另一台服务器的域内ip # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # discovery.zen.minimum_master_nodes: 2 # # For more information, consult the zen discovery 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 bootstrap.system_call_filter: false
两台机器的配置基本相同,
elasticsearch.yml两台不同的地方
1. 上面标注域内ip的地方,network.host每台服务器上都填写自己的域内也就是内网ip。
2. node.name各自取一个名称,不能相同。
3. discovery.zen.ping.unicast.hosts填写另外几台,这里只有一台,多个用,隔开即可,然后分别启动两台服务器的节点。如下:
第一台服务器:下面是tail看日志信息有点多
第二台服务器的启动:启动方式一样,启动完成查看启动情况
这样就集群了两个节点。
配置文件:settings
ElasticSearch5.4.3 环境搭建 2017 (2-集群搭建)
最新推荐文章于 2024-08-26 12:12:47 发布