ElasticSearch(七):ElasticSearch集群的搭建

由于资源有限,使用是一台机器上安装三个elasticSearch服务端组成的集群。

1. 安装elasticSearch6.3.2

将原本安装的elasticSearch6.3.2复制两份,分别重新命名,如下:

2. 修改配置文件

进入elasticSearch的config目录,打开 elasticsearch.yml文件,修改如下信息:

  需要注意的是:

    默认所有节点都会存储数据。

    如果你是一台机器上多个es服务器,那么必须指定不同的tcp端口。

# ======================== 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: zskj
#
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
# 节点名
node.name: node
#
# 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):
# 节点的ip地址
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
# 端口
http.port: 9200
# tcp端口。
transport.tcp.port: 9300
#
# 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]"]
# elasticSearch集群的地址。这里使用的是一台机器的不同端口。
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
# 预防脑裂,建议为总集群数一半 + 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
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

需要特别注意的是:

  1. 如果你的elasticSearch节点在 elasticsearch.yml中添加了中文之后,导致elasticSearch无法启动,就必须把yml文件中的中文删除,然后就可以重启启动了。报错信息如下:

  

  2. 配置文件书写的时候需要注意:属性必须定格写,之后是一个“:”,之后空格,然后是属性值。不能使用tab键。

3. 启动集群

分别启动三个elasticSearch节点即可启动集群。

4. 一个小的技巧

如果你也是和我一样,使用的是一台机器的三个elasticSearch服务端,每次都需要点到文件中,点击elasticsearch.bat,确实挺麻烦,那么你可以试试批处理。

右键创建一个文件,命名为xxxx.bat即可。使用记事本打开,然后写入如下命令,保存即可。

@echo off
title ES集群启动工具
REM 切换命令行目录为当前BAT所在目录
cd /d E:\ElasticSearch\elasticsearch-6.3.2\bin
start elasticsearch.bat

echo elasticsearch1正在启动。。。
cd /d E:\ElasticSearch\elasticsearch-6.3.2_02\bin
start elasticsearch.bat

echo elasticsearch2正在启动。。。
cd /d E:\ElasticSearch\elasticsearch-6.3.2_03\bin
start elasticsearch.bat

echo elasticsearch3正在启动。。。

作用就是:分别自动切换到三个elasticSearch的目录,然后自动点击 elasticsearch.bat,启动服务端。

如果你还安装了head插件,每次点开启动也挺麻烦,可以直接在批处理后面添加语句即可:当elasticSearch服务端完全启动之后,点击任意键启动head插件

echo 任意键继续启动head插件
pause

cd /d E:\ElasticSearch\head
call grunt server

综上:你只需要双击你的批处理工具 xxxx.bat就可以完成集群的启动了,如果你在多台服务器上,那么还是一个一个启动吧。

原文地址:https://www.cnblogs.com/chenmc/p/9541632.html

时间: 2024-08-30 17:54:48

ElasticSearch(七):ElasticSearch集群的搭建的相关文章

【基础组件12】Elasticsearch 6.8集群搭建+es-head安装+es-ik安装

1.总结遇到的elasticsearch启动失败的几种情况及解决参考: http://www.mamicode.com/info-detail-2322576.html 2.Elasticsearch 6.8集群搭建参考: https://blog.csdn.net/guohan_solft/article/details/85015118 https://blog.csdn.net/weixin_40036109/article/details/86595578 3.es-head的安装(wi

使用docker安装elasticsearch伪分布式集群

docker安装elasticsearch伪分布式集群 0.在安装es之前,首先编辑一下宿主机的内核参数,否则配置es集群的时候极有可能启动不成功: [[email protected] ~]# vim /etc/sysctl.conf vm.max_map_count=655360 [[email protected] ~]# sysctl -p # 加载参数 1.搜索es的镜像,如下第一个就是官方镜像: 2.拉取镜像: [[email protected] ~]# docker pull e

一:Storm集群环境搭建

第一:storm集群环境准备及部署[1]硬件环境准备--->机器数量>=3--->网卡>=1--->内存:尽可能大--->硬盘:无额外需求[2]软件环境准备--->CentOS-6.0-x86_64系统环境--->三台地址--->zookeeper和storm公用物理环境 第二:节点环境查看 第三:节点之间用ip-->别名绑定/etc/hosts,然后用ping 别名 进行测试 第四:zookeeper集群环境搭建第五:Storm集群环境搭建[1

Apache Storm 集群环境搭建

Apache storm 是一个由twitter开源的大数据处理系统,与其他系统不同的是,storm旨在用于分布式实时处理并且与语言无关.笔者所认知的storm使用场景诸 如 实时日志分析.网站用户行为实时分析.实时计算等,目前很多公司也都把storm作为自己的大数据架构的一部分,来实现一些实时业务的处理. 相信大家都和我有一样的认知,那就是现在的技术都是项目驱动模式,没有最好的技术,只有最适合自己项目的技术.下面先跟大家分享一下我对storm的一些简单了解: storm的优点: 1.简单的编程

redis集群的搭建详细教程

1 Redis-cluster架构图             redis-cluster投票:容错  (至少要三个才可以,才能超过半数) 架构细节: (1)所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽. (2)节点的fail是通过集群中超过半数的节点检测失效时才生效. (3)客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可. (4)redis-cluster把所有的物理节点映射到[0-

Linux环境下HDFS集群环境搭建关键步骤

Linux环境下HDFS集群环境搭建关键步骤记录. 介质版本:hadoop-2.7.3.tar.gz 节点数量:3节点. 一.下载安装介质 官网下载地址:http://hadoop.apache.org/releases.html 二.服务器规划 MASTER:NAMENODE, DATANODENODE1:DATANODENODE2:SECONDARY NAMENODE, DATANODE 三.配置hostname和hosts 192.168.13.4 master192.168.13.5 n

Linux环境下SolrCloud集群环境搭建关键步骤

Linux环境下SolrCloud集群环境搭建关键步骤. 前提条件:已经完成ZooKeeper集群环境搭建. 一.下载介质 官网下载地址:http://www.apache.org/dyn/closer.lua/lucene/solr/7.3.1 历史版本下载:http://archive.apache.org/dist/lucene/solr/ 二.上传介质 通过工具将下载好的安装介质上传至服务器目录. 三.解压安装 解压即可完成安装. unzip solr-5.5.5.zip 四.修改配置文

RocketMq 集群方式搭建 步骤教学包教包会

mq集群方式搭建 有段时间没写这些技术文章了, 今天抽空写一点,不然自己都快忘记了 这篇文章记录了rocketmq 集群方式搭建的过程, 也是自己半天的成果记录吧! 感兴趣的朋友点个赞在走呗! 好了,废话不多,下面开搞. 本文章参考https://blog.csdn.net/qq_35400008/article/details/82467562#comments 这个博客文章编写 准备工作 第一步:关闭要搭建的所有机器的防火墙 第二步:每台机器执行下如下步骤 [[email protected

Redis Cluster集群部署搭建

在Oracle的路上走了许多年,换换感觉,尝试一下新的知识,也是一个不错的感觉.Redis,一个超轻量化的内存数据库,只做一小块数据库功能实现,却非常优秀的一个产品.今天,就分享一下安装Redis集群的过程. 搭建redis集群,建议至少需要准备3台服务器,共搭建6个节点,3个master,3个slave,并且要求3个master节点不能全部跑到同一台服务器上,保证节点安全,3台服务器的配置相同,使用redistest账号搭建,对应的端口是7000/7001/7002端口 我的集群分配如下,每个

项目进阶 之 集群环境搭建(三)多管理节点MySQL集群

上次的博文项目进阶 之 集群环境搭建(二)MySQL集群中,我们搭建了一个基础的MySQL集群,这篇博客咱们继续讲解MySQL集群的相关内容,同时针对上一篇遗留的问题提出一个解决方案. 1.单管理节点MySQL集群和多管理节点MySQL集群 上一篇的博客中,我们搭建的MySQL集群架构中,只存在一个管理节点,这样搭建的集群可以用如下所示的结构表示. 仔细分析上图就会发现,上图所示的单管理节点MySQL集群存在当唯一的管理节点由于网络.断电.压力过大等各种原因宕机后,数据节点和SQL节点将会各自为