ES集群安装教程

本文涉及的产品
Elasticsearch Serverless通用抵扣包,测试体验金 200元
简介: 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


相关实践学习
以电商场景为例搭建AI语义搜索应用
本实验旨在通过阿里云Elasticsearch结合阿里云搜索开发工作台AI模型服务,构建一个高效、精准的语义搜索系统,模拟电商场景,深入理解AI搜索技术原理并掌握其实现过程。
ElasticSearch 最新快速入门教程
本课程由千锋教育提供。全文搜索的需求非常大。而开源的解决办法Elasricsearch(Elastic)就是一个非常好的工具。目前是全文搜索引擎的首选。本系列教程由浅入深讲解了在CentOS7系统下如何搭建ElasticSearch,如何使用Kibana实现各种方式的搜索并详细分析了搜索的原理,最后讲解了在Java应用中如何集成ElasticSearch并实现搜索。  
目录
相关文章
【ES系列五】——集群搭建(多机集群&单机多节点集群)
集群是为一组互联的完整计算机,一起作为一个统一的计算资源而工作,给人以一台机器的感觉。
|
4月前
|
安全 Linux Android开发
如何将Kindle电子书下载到电脑:技术流程与操作解析
随着数字阅读兴起,Kindle成为主流电子书平台。然而,Amazon的封闭生态和DRM限制,使用户难以灵活管理书籍。本文从技术角度出发,讲解如何合法下载Kindle电子书至电脑,包括使用Kindle for PC、USB导出及进阶方案(如Android模拟器、WINE环境)。同时介绍文件格式处理、自动化备份与阅读体验优化方法,并强调版权合规的重要性,助您构建个人数字图书馆。
1360 3
|
12月前
|
Java 关系型数据库 API
介绍一款Java开发的企业接口管理系统和开放平台
YesApi接口管理平台Java版,基于Spring Boot、Vue.js等技术,提供API接口的快速研发、管理、开放及收费等功能,支持多数据库、Docker部署,适用于企业级PaaS和SaaS平台的二次开发与搭建。
|
监控 Java
ElasticSearch集群搭建
ElasticSearch集群搭建
556 0
|
设计模式 JavaScript 前端开发
前端(十一)——Vue vs. React:两大前端框架的深度对比与分析
前端(十一)——Vue vs. React:两大前端框架的深度对比与分析
1199 0
|
安全 数据挖掘 测试技术
深入探究软件测试中的风险分析与管理
【5月更文挑战第7天】 在软件开发生命周期中,风险分析与管理是确保产品质量和项目成功的关键步骤。本文将探讨软件测试过程中如何有效进行风险评估、分类及采取相应的缓解措施。文章首先介绍了风险管理的重要性,然后详细阐述了风险识别的技术和工具,接着分析了如何制定和实施风险应对策略。最后,通过案例研究展示了一个结构化风险分析流程的实施效果。
359 2
|
关系型数据库 MySQL
MySQL开窗聚合函数——SUM(),AVG(),MIN(),MAX()
MySQL开窗聚合函数——SUM(),AVG(),MIN(),MAX()
510 0
MySQL开窗聚合函数——SUM(),AVG(),MIN(),MAX()
|
SQL Java 关系型数据库
SpringBoot+Mybatis Plus+ClickHouse入门教程
SpringBoot+Mybatis Plus+ClickHouse入门教程
1345 0
SpringBoot+Mybatis Plus+ClickHouse入门教程
|
存储 计算机视觉 C++
Opencv (C++)系列学习---模板匹配
Opencv (C++)系列学习---模板匹配
336 0
|
前端开发 Java 数据安全/隐私保护
【2022】Elasticsearch-7.17.6集群部署
【2022】Elasticsearch-7.17.6集群部署
1404 0