ES集群安装教程

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: ES集群安装教程

引言


最近项目需要部署ES教程,所以至此记录安装过程,本教程使用的es版本为6.0.1,并且在同一台机器上搭建三个节点的伪集群。


ES 集群至少部署 3 个节点,确保至少存在两个主节点保证数据可靠性。部署完一个节点后,把部署目录拷贝到其他节点,修改配置后就可以完成部署。


教程开始==================


1、下载需要的安装包

[root@jack 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: 123.321.45.6
#
# 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: ["123.321.45.6:9301", "123.321.45.6:9302","123.321.45.6: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内存。

image.png



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.jack.com
#监听端口
http.port: 9201   
#数据通讯端口
transport.tcp.port: 9301    
#集群中的节点地址   
#discovery.zen.ping.unicast.hosts : ["123.321.45.6:9301", "123.321.45.6:9302", "123.321.45.6:9303"]
discovery.zen.ping.unicast.hosts : ["es1.jack.com:9301", " es2.jack.com:9302", " es3.jack.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体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
目录
相关文章
|
9月前
|
Java Shell 数据安全/隐私保护
|
数据安全/隐私保护 Docker 容器
ElasticStack----使用Docker方式安装单节点的8.1.3版本的ElasticSearch
ElasticStack----使用Docker方式安装单节点的8.1.3版本的ElasticSearch
966 0
ElasticStack----使用Docker方式安装单节点的8.1.3版本的ElasticSearch
|
5月前
Kibana配置ES集群(6.x版本之前和7.x版本两种写法)
Kibana配置ES集群(6.x版本之前和7.x版本两种写法)
36 0
|
8月前
|
存储 安全 Linux
Elasticsearch7.17.5 Linux安装部署
Elasticsearch7.17.5 Linux安装部署
139 0
|
11月前
|
搜索推荐 网络协议 安全
Elasticsearch-01CentOS7单节点部署ES5.6.16
Elasticsearch-01CentOS7单节点部署ES5.6.16
113 0
|
11月前
|
存储 数据可视化 定位技术
docker Kibana安装配置连接ES
docker Kibana安装配置连接ES
323 0
|
存储 监控 数据可视化
windows安装es、kibana教程
windows安装es、kibana教程
244 0
windows安装es、kibana教程
|
存储 监控 数据安全/隐私保护
【ElasticSearch实战】——ES集群监控 之 Cerebro 0.8.3 安装及简单使用
【ElasticSearch实战】——ES集群监控 之 Cerebro 0.8.3 安装及简单使用
333 0
【ElasticSearch实战】——ES集群监控 之 Cerebro 0.8.3 安装及简单使用
|
分布式计算 前端开发 Hadoop
环境篇 ES 集群的配置|学习笔记
快速学习环境篇 ES 集群的配置
284 0
|
Java Linux
ES单机版和集群安装
ES单机版和集群安装
138 0