elasticsearch5.5多機叢集配置 與 Centos 7關閉防火牆
今天,講解下elasticsearch叢集的配置與在centos中如何關閉防火牆.....
首先,講解下如何在centos中關閉防火牆?
為啥要講一下這塊內容呢?在實際的開發與運維中,經常會遇到應用啟動後,訪問應用.....報錯404......很多情況下,是與防火牆沒有開應用的埠有關.......
檢視防火牆的狀態:
firewall-cmd --state #檢視預設防火牆狀態(關閉後顯示notrunning,開啟後顯示running)
關閉firewall:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service
開啟防火牆埠:
firewall-cmd --zone=public --add-port=9200/tcp --permanent #####9200根據實際情況,修改成應用埠,或者要開啟的埠 firewall-cmd --reload #######重啟防火牆
=============================================完結===========================================
接下來,就是運維或者實施過程中經常會遇到叢集的部署.....,下面就根據我自己的本地環境,詳細的講解下ES叢集的部署.....
ELasticsearch 5.5要求JDK版本最低為1.8; ######實施過程中需要注意的哦......
配置叢集之前 先把要加群叢集的節點的裡的data目錄下的Node目錄 刪除,否則叢集建立會失敗。
我這邊虛擬機器配置了兩臺centos IP分別是 192.168.1.110 和 192.168.1.111 ;
分別配置下elasticsearch.yml配置檔案
110機器:
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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: 192.168.1.110
#
# 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: ["192.168.1.110"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# 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
http.cors.enabled: true
http.cors.allow-origin: "*"
111機器:
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-2
#
# 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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: 192.168.1.111
#
# 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: ["192.168.1.110"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# 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
這裡兩臺機器的cluster.name必須一致 這樣才算一個叢集......
node.name節點名稱每臺取不同的名稱,用來表示不同的叢集節點
network.host配置成自己的區域網IP
http.port埠就固定9200
discovery.zen.ping.unicast.hosts主動發現節點我們都配置成110節點IP
配置完後 重啟es服務;
然後head外掛我們檢視下:
如果出現上圖的情況,那麼叢集就部署成功了.......