ES集羣安裝教程

引言

最近項目需要部署ES教程,所以至此記錄安裝過程,本教程使用的es版本爲6.0.1,並且在同一臺機器上搭建三個節點的僞集羣。

ES 集羣至少部署 3 個節點,確保至少存在兩個主節點保證數據可靠性。部署完一個節點後,把部署目錄拷貝到其他節點,修改配置後就可以完成部署。

教程開始==================

1、下載需要的安裝包

[root@acs soft]#  wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.1.tar.gz

2、解壓

tar -zxvf elasticsearch-6.0.1.tar.gz

3、在安裝目錄下面建立文件夾elasticsearch-6.0.1,然後創建第一個節點。

mv elasticsearch-6.0.1.tar.gz /data/app/elasticsearch-6.0.1/es1

4、修改配置文件

vim /data/app/elasticsearch-6.0.1/es1/config/elasticsearch.yml

  需要修改的配置如下:

    1、cluster.name: call-search  //集羣名稱,建議 修改爲有意義的名稱, 不同的節點該名稱需要保持一致。

    2、node.name: node-1  //節點名稱 每個節點名稱不一致

    3、path.data: /data/app/elasticsearch-6.0.1/es1  //數據存放路徑

    4、path.logs: /data/logs/elasticsearch/es1  //日誌存放路徑

    5、network.host: 172.21.64.17  // 服務器的內網地址

    6、http.port: 9201  //對外通訊端口

    7、transport.tcp.port: 9301 //集羣內部通訊端口

    8、discovery.zen.ping.unicast.hosts: ["172.21.64.17:9301", "172.21.64.17:9302","172.21.64.17:9303"]  //集羣配置

    9、discovery.zen.minimum_master_nodes: 2  //集羣存活最少節點數量

  修改上面幾個配置項,就可以了,下面是我項目中的配置文件。各位讀者可以參考

# ======================== 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: call-search
#
# ------------------------------------ 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: /data/app/elasticsearch-6.0.1/es1
#
# Path to log files:
#
path.logs: /data/logs/elasticsearch/es1
#
# ----------------------------------- 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: 172.21.64.17
#
# Set a custom port for HTTP:
#
http.port: 9201
transport.tcp.port: 9301

#
# 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: ["172.21.64.17:9301", "172.21.64.17:9302","172.21.64.17:9303"]
#
# 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

5、配置內存

vim /data/app/elasticsearch-6.0.1/es1/config/jvm.options 

根據服務配置和 業務需求進行內存的分配即可,我我這裏每個節點分配了8g內存。

6、啓動服務

  權限設置  chown daemon:daemon -R /data/app/elasticsearch-6.0.1/es1

 我們使用daemon用戶啓動es服務,所以需要設置權限

 啓動命令:/sbin/runuser -s /bin/bash daemon -c " /data/app/elasticsearch-6.0.1/es1/bin/elasticsearch -d"

7、配置剩餘兩個節點

直接複製es1文件夾爲es2,es3,然後修改對應的 配置文件中的節點名稱和端口名稱即可。注意集羣名稱要保持一致

8、配置完成以後,按照節點1的啓動方式啓動即可。

至此,整個安裝過程完成。

附錄:es配置文件中重要節點說明

  

#集羣名
cluster.name: elasticsearch
#節點名
node.name: es_1
#數據文件路徑
path.data:  /opt/elasticsearch/es1/data
#日誌文件路徑
path.logs: /opt/logs/elasticsearch/es1
#監聽地址
#network.host: 10.141.141.29	
network.host: es1.zhiqingfin.com
#監聽端口
http.port: 9201		
#數據通訊端口
transport.tcp.port: 9301		
#集羣中的節點地址		
#discovery.zen.ping.unicast.hosts : ["10.163.88.250:9301", "10.163.88.250:9302", "10.163.88.250:9303"]
discovery.zen.ping.unicast.hosts : ["es1.zhiqingfin.com:9301", " es2.zhiqingfin.com:9302", " es3.zhiqingfin.com:9303"]
#集羣中的至少主節點數(指定集羣中的節點中有幾個有master資格的節點)
discovery.zen.minimum_master_nodes: 2
#是否爲master
node.master: true
#是否爲數據節點
node.data: true
#設置集羣中自動發現其它節點時ping連接超時時間
discovery.zen.fd.ping_timeout: 180s
#集羣中節點之間ping的次數
discovery.zen.fd.ping_retries: 10
#集羣中節點之間ping的時間間隔
discovery.zen.fd.ping_interval: 30s
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章