文章目录

  • 概述
  • CentOS上部署ES集群
    • 集群组成
    • 关键配置信息
    • Master节点搭建
    • Slave1节点搭建
    • Slave2节点搭建
  • Windows 部署 ES集群
    • elasticsearch.yml配置修改
    • 启动服务
  • 注意事项

概述

Elasticsearch-01CentOS7单节点部署ES5.6.16中我们学习了ES单节点的部署,这里我们来看下ES集群是如何部署的吧

CentOS上部署ES集群

集群组成

  • 节点数量: 3个 (1个Master 2个Slave)
  • OS: CentOS 7
  • IP: 192.168.91.128
  • port : master-9200 slave01-8200 slave02-7200

方便起见,先按照伪集群模式部署吧,在同一台主机上使用不同的端口来区分不同的节点,当然了你也可以使用3台虚机,那是最好不过的了


关键配置信息

必须保证集群名相同,如果节点处于同一局域网同一网段,es会自动去发现其他的节点。

elasticsearch.yml

Master


# 绑定的服务器IP,可设置为本机IP
network.host: 192.168.91.128
#启动的端口,默认9200
http.port: 9200#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"#集群信息
cluster.name: artisan
node.name: master
node.master: true

其他配置,也可以按需修改


Slave01:

#host 和 端口
network.host: 192.168.91.128
http.port: 8200#集群信息
cluster.name: artisan
node.name: slave01
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Slave02:

#host 和 端口
network.host: 192.168.91.128
http.port: 7200#集群信息
cluster.name: artisan
node.name: slave02
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Master节点搭建

修改elasticsearch.yml中的配置

# ======================== 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: my-application
#
# ------------------------------------ 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: /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):
#
network.host: 192.168.91.128
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# 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: "*"
#集群信息
cluster.name: artisan
node.name: master
node.master: true

通过head插件访问集群信息

可以看到 节点名字已经变成了master, 并且前面的五角星表示为master节点(指挥官) 。


Slave1节点搭建

复制一份,然后修改配置文件

[root@localhost ~]# su - elastic
Last login: Thu Apr 18 08:47:46 PDT 2019 on pts/1
[elastic@localhost ~]$ pwd
/home/elastic
[elastic@localhost ~]$ ll
total 33108
drwxr-xr-x. 9 elastic elastic     4096 Apr 18 03:30 elasticsearch-5.6.16
-rw-r--r--. 1 root    root    33894983 Apr 18 03:27 elasticsearch-5.6.16.tar.gz
[elastic@localhost ~]$
[elastic@localhost ~]$
[elastic@localhost ~]$ mkdir elasticsearch-5.6.16-salve
[elastic@localhost ~]$ cp elasticsearch-5.6.16.tar.gz elasticsearch-5.6.16-salve/
[elastic@localhost ~]$ cd elasticsearch-5.6.16-salve/
[elastic@localhost elasticsearch-5.6.16-salve]$ ll
total 33104
-rw-r--r--. 1 elastic elastic 33894983 Apr 18 18:28 elasticsearch-5.6.16.tar.gz
[elastic@localhost elasticsearch-5.6.16-salve]$ tar -xvzf elasticsearch-5.6.16.tar.gz [elastic@localhost elasticsearch-5.6.16-salve]$ cp -r  elasticsearch-5.6.16  elasticsearch-slave01
[elastic@localhost elasticsearch-5.6.16-salve]$ cp -r  elasticsearch-5.6.16  elasticsearch-slave02[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave01[elastic@localhost elasticsearch-slave01]$ vim config/elasticsearch.yml 

elasticsearch.yml 追加如下配置

#host 和 端口
network.host: 192.168.91.128
http.port: 8200#集群信息
cluster.name: artisan
node.name: slave01
#默认的通讯接口是9300,找到集群的信
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Slave2节点搭建

[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave02

elasticsearch.yml 追加如下配置

#host 和 端口
network.host: 192.168.91.128
http.port: 7200#集群信息
cluster.name: artisan
node.name: slave02
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

我这里用的虚机的内存太小了,无法启动两个及两个以上的节点, 为了验证配置的正确性,windows上部署下吧


Windows 部署 ES集群

三个节点:


elasticsearch.yml配置修改

elasticsearch.yml的配置如下:

和centos中的配置一样,仅仅是IP不同

master:

# 绑定的服务器IP,可设置为本机IP
network.host: 127.0.0.1
#启动的端口,默认9200
http.port: 9200#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"#集群信息
cluster.name: artisan
node.name: master
node.master: true


salve01:

#host 和 端口
network.host: 127.0.0.1
http.port: 8200#集群信息
cluster.name: artisan
node.name: slave01
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


slave02:

#host 和 端口
network.host: 127.0.0.1
http.port: 7200#集群信息
cluster.name: artisan
node.name: slave02
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


启动服务

双击H:\elasticsearch-5.6.16-slave02\bin\elasticsearch.bat

通过head 插件查看 集群信息

配置OK


注意事项

found existing node {master}{xdHjXCdET_e7M0G_MYNiTQ}{WbXaI8HtRDCbFEzS8VtdIg}{127.0.0.1}{127.0.0.1:9300} with the same id but is a different node instance];

如果配到了这种错误,很明显id重复了,如果配置没有问题,看下你是不是直接copy的已经存在的节点data目录中的数据重复导致的。 建议解压一个新的压缩包,重新配置,避免上述错误。

Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式相关推荐

  1. 在阿里云上部署生产级别Kubernetes集群

    阿里云是国内非常受欢迎的基础云平台,随着Kubernetes的普及,越来越多的企业开始筹划在阿里云上部署自己的Kubernetes集群. 本文将结合实战中总结的经验,分析和归纳一套在阿里云上部署生产级 ...

  2. 在 Windows 上测试 Redis Cluster的集群填坑笔记

    redis 集群实现的原理请参考http://www.tuicool.com/articles/VvIZje 集群环境至少需要3个节点.推荐使用6个节点配置,即3个主节点,3个从节点. 新建6个文件夹 ...

  3. 在阿里云 ACK 上部署 EMQX MQTT 服务器集群

    云进入以「应用为中心」的云原生阶段,Operator 模式的出现,则为 Kubernetes 中的自动化任务创建配置与管理提供了一套行之有效的标准规范.通过将运维知识固化成高级语言 Go/Java 代 ...

  4. 在华为云 CCE 上部署 EMQX MQTT 服务器集群

    云进入以「应用为中心」的云原生阶段,Operator 模式的出现,则为 Kubernetes 中的自动化任务创建配置与管理提供了一套行之有效的标准规范.通过将运维知识固化成高级语言 Go/Java 代 ...

  5. reids 5.0.4 cluster集群模式部署实操。

    一.准备工作 5.0.4的redis压缩包,可以自行去官网下载. linux环境 二.解压并且安装 1.新建6个文件夹用于安装redis目录 目录路径为/root/tools/7001 [root@m ...

  6. CentOS7.9上部署OpenShift3.11集群

    CentOS7.9上部署OpenShift3.11集群 OCP官网文档:https://docs.openshift.com/container-platform/3.11/welcome/index ...

  7. 在 Windows 上部署 gitblit

    在 Windows 上部署 gitblit 在 Windows 上部署 gitblit 缘起 gitblit 是什么 安装JDK 部署 gitblit 下载 gitblit 并解压 配置 登录 注册为 ...

  8. 在windows上部署IIS web服务

    在windows上部署IIS web服务 在windows上部署IIS web服务安装IIS相关环境并利用IIS服务器发布靶站源代码(注意应用程序池使用.net 4.0并开启.NET服务) 1.1程序 ...

  9. 【游戏开发】《Java游戏服务器架构实战》项目在windows上部署

    [游戏开发]<Java游戏服务器架构实战>项目在windows上部署 文章目录 [游戏开发]<Java游戏服务器架构实战>项目在windows上部署 一.配置项目基础环境 二. ...

最新文章

  1. 2021年大数据常用语言Scala(二):Scala开发环境安装
  2. 前方高能!金三银四Java高级工程师面试题整理
  3. EasyPusher/EasyDarwin/EasyPlayer实现手机直播版本及效果整理
  4. Git常用指令及功能总结
  5. Do not use built-in or reserved HTML elements as component id等等vue warn问题
  6. 5G(2)---NR协议栈及功能1 - 总体架构与物理层
  7. mysql in 按顺序排序_Mysql查询结果顺序按in()中ID的顺序排列的实例分析
  8. php 简单日志搜索
  9. 四线温度探头怎么接线_温度变送器接线详解
  10. nginx利用try_files实现多个源
  11. 计算机辅助英语教学 研究背景,计算机辅助外语教学中的教师角色研究
  12. 接口测试常见问题及答案
  13. c语言编程马克思手稿 百例,清华大学出版社-图书详情-《C语言趣味编程100例》...
  14. 大数据可视化 — 学期总结
  15. BUUCTF~Misc~Test2
  16. 跑腿小程序需要服务器吗,小程序设置流程
  17. GreenDao的简单学习(附带demo源码)
  18. 考研380分什么水平计算机,考研380分属于什么水平 算高分吗
  19. App移动应用测试点总结
  20. Linux查看端口详情

热门文章

  1. ListView嵌套RecyclerView遇到的一些坑以及解决办法
  2. php aapt apk 包名,aapt 命令可应用于查看apk包名、主activity、版本等很多信息
  3. AttributeError: module ‘grpc.experimental.aio‘ has no attribute ‘StreamUnaryCall‘
  4. tensorflow random的用法
  5. 图论算法-图论的表示、分类及基本概念(系列1)
  6. torch_geometric 笔记:TORCH_GEOMETRIC.UTILS(更新中)
  7. 机器学习笔记:线性回归
  8. 文巾解题3. 无重复字符的最长子串
  9. Python编程基础:第十八节 字典Dictionaries
  10. 【干货】Kaggle 数据挖掘比赛经验分享(mark 专业的数据建模过程)