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内存。

ES集群安装教程_第1张图片

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

 

你可能感兴趣的:(@运维,ElasticSearch实战)