elasticsearch 跨網段組集群


elasticsearch 是非常流行的全文搜索引擎,但網上的教程多是初次使用,並沒有一些高級用法demo。這次遇到需要跨網段組網問題,自己摸索了文檔很久,發現確實可行,於是着手做了個實驗,最終實驗成功。在跨網段下實現了自動發現和組網。

 

總共運行了三個節點,一個節點IP是192.168.45.67,另外兩個節點IP都是172.20.5.161三個文件的配置文件都改為如下配置文件,先后啟動三個節點,記錄日志在后面。

192.168.45.67節點啟動后,自動用9300作為通信端口,將自身作為master節點存在。

172.20.5.161節點啟動后,自動用9300作為通信端口,發現hosts列表中有master存在,master將其加入集群中。

172.20.5.161節點啟動后,發現9300被占用,自動用9301作為通信端口,發現hosts列表中有master存在,master將其加入集群中。

 

192.168.45.67:9300添加日志

Image(50)

172.20.5.161:9300添加日志

Image(51)

172.20.5.161:9301添加

Image(52)

 

elasticsearch-1.5.2/config/elasticsearch.yml需要修改部分為

discovery.zen.ping.multicast.enabled和discovery.zen.ping.unicast.hosts,修改如下:

################################## Discovery ##################################

# Discovery infrastructure ensures nodes can be found within a cluster
# and master node is elected. Multicast discovery is the default.

# Set to ensure a node sees N other master eligible nodes to be considered
# operational within the cluster. This should be set to a quorum/majority of
# the master-eligible nodes in the cluster.
#
#discovery.zen.minimum_master_nodes: 1

# Set the time to wait for ping responses from other nodes when discovering.
# Set this option to a higher value on a slow or congested network
# to minimize discovery failures:
#
#discovery.zen.ping.timeout: 3s

# For more information, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-zen.html>

# Unicast discovery allows to explicitly control which nodes will be used
# to discover the cluster. It can be used when multicast is not present,
# or to restrict the cluster communication-wise.
#
# 1. Disable multicast discovery (enabled by default):
#
discovery.zen.ping.multicast.enabled: false
#
# 2. Configure an initial list of master nodes in the cluster
#    to perform discovery when new nodes (master or data) are started:
#
discovery.zen.ping.unicast.hosts: ["192.168.45.67", "172.20.5.161:9300"]

# EC2 discovery allows to use AWS EC2 API in order to perform discovery.
#
# You have to install the cloud-aws plugin for enabling the EC2 discovery.
#
# For more information, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-ec2.html>
#
# See <http://elasticsearch.org/tutorials/elasticsearch-on-ec2/>
# for a step-by-step tutorial.

# GCE discovery allows to use Google Compute Engine API in order to perform discovery.
#
# You have to install the cloud-gce plugin for enabling the GCE discovery.
#
# For more information, see <https://github.com/elasticsearch/elasticsearch-cloud-gce>.

# Azure discovery allows to use Azure API in order to perform discovery.
#
# You have to install the cloud-azure plugin for enabling the Azure discovery.
#
# For more information, see <https://github.com/elasticsearch/elasticsearch-cloud-azure>.

配置的中文注釋請看:

http://www.tuicool.com/articles/Nryu2i


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM