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

本文涉及的产品
Elasticsearch Serverless通用抵扣包,测试体验金 200元
简介: Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式

20190806092132811.jpg

概述


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插件访问集群信息


20190419093339310.png

可以看到 节点名字已经变成了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集群


三个节点:


20190419103903254.png


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

20190419103935467.png


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"]


20190419104001844.png


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"]


20190419104029115.png


启动服务


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


20190419104256942.png

通过head 插件查看 集群信息


20190419104359914.png

配置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目录中的数据重复导致的。 建议解压一个新的压缩包,重新配置,避免上述错误。


相关实践学习
以电商场景为例搭建AI语义搜索应用
本实验旨在通过阿里云Elasticsearch结合阿里云搜索开发工作台AI模型服务,构建一个高效、精准的语义搜索系统,模拟电商场景,深入理解AI搜索技术原理并掌握其实现过程。
ElasticSearch 最新快速入门教程
本课程由千锋教育提供。全文搜索的需求非常大。而开源的解决办法Elasricsearch(Elastic)就是一个非常好的工具。目前是全文搜索引擎的首选。本系列教程由浅入深讲解了在CentOS7系统下如何搭建ElasticSearch,如何使用Kibana实现各种方式的搜索并详细分析了搜索的原理,最后讲解了在Java应用中如何集成ElasticSearch并实现搜索。  
相关文章
|
3月前
|
存储 数据安全/隐私保护 Windows
Windows中部署网盘神器 Filebrowser
ZeroNews (零讯)内网穿透赋予 FileBrowser 任意位置互联网访问的能力,无需用户具备固定公网IP,提供专用的访问域名,将 FileBrowser 转变为公有云盘,实现多用户在线协同工作。
|
7月前
|
分布式计算 Hadoop Java
CentOS中构建高可用Hadoop 3集群
这个过程像是在一个未知的森林中探索。但当你抵达终点,看到那个熟悉的Hadoop管理界面时,所有的艰辛都会化为乌有。仔细观察,尽全力,这就是构建高可用Hadoop 3集群的挑战之旅。
271 21
|
8月前
|
Java Linux
CentOS环境搭建Elasticsearch集群
至此,您已成功在CentOS环境下搭建了Elasticsearch集群。通过以上介绍和步骤,相信您对部署Elasticsearch集群有了充分的了解。最后祝您在使用Elasticsearch集群的过程中顺利开展工作!
463 22
|
7月前
|
JSON 安全 数据可视化
Elasticsearch(es)在Windows系统上的安装与部署(含Kibana)
Kibana 是 Elastic Stack(原 ELK Stack)中的核心数据可视化工具,主要与 Elasticsearch 配合使用,提供强大的数据探索、分析和展示功能。elasticsearch安装在windows上一般是zip文件,解压到对应目录。文件,elasticsearch8.x以上版本是自动开启安全认证的。kibana安装在windows上一般是zip文件,解压到对应目录。elasticsearch的默认端口是9200,访问。默认用户是elastic,密码需要重置。
3419 0
|
9月前
|
Linux 虚拟化 Docker
Linux服务器部署docker windows
在当今软件开发中,Docker成为流行的虚拟化技术,支持在Linux服务器上运行Windows容器。流程包括:1) 安装Docker;2) 配置支持Windows容器;3) 获取Windows镜像;4) 运行Windows容器;5) 验证容器状态。通过这些步骤,你可以在Linux环境中顺利部署和管理Windows应用,提高开发和运维效率。
1266 1
|
12月前
|
Ubuntu 网络协议 Linux
快速部署WSL(Windows Subsystem for Linux)
WSL提供了一种轻量级的方法,使开发者能够在Windows上无缝运行Linux环境。通过本文介绍的步骤,可以快速安装、配置和使用WSL,以满足开发和测试的需求。
2105 8
|
分布式计算 Hadoop Java
Hadoop集群搭建,基于3.3.4hadoop和centos8【图文教程-从零开始搭建Hadoop集群】,常见问题解决
本文是一份详细的Hadoop集群搭建指南,基于Hadoop 3.3.4版本和CentOS 8操作系统。文章内容包括虚拟机创建、网络配置、Java与Hadoop环境搭建、克隆虚拟机、SSH免密登录设置、格式化NameNode、启动Hadoop集群以及通过UI界面查看Hadoop运行状态。同时,还提供了常见问题的解决方案。
Hadoop集群搭建,基于3.3.4hadoop和centos8【图文教程-从零开始搭建Hadoop集群】,常见问题解决
|
存储 Kubernetes 负载均衡
CentOS 7.9二进制部署K8S 1.28.3+集群实战
本文详细介绍了在CentOS 7.9上通过二进制方式部署Kubernetes 1.28.3+集群的全过程,包括环境准备、组件安装、证书生成、高可用配置以及网络插件部署等关键步骤。
2156 4
CentOS 7.9二进制部署K8S 1.28.3+集群实战
|
Kubernetes Ubuntu Linux
Centos7 搭建 kubernetes集群
本文介绍了如何搭建一个三节点的Kubernetes集群,包括一个主节点和两个工作节点。各节点运行CentOS 7系统,最低配置为2核CPU、2GB内存和15GB硬盘。详细步骤包括环境配置、安装Docker、关闭防火墙和SELinux、禁用交换分区、安装kubeadm、kubelet、kubectl,以及初始化Kubernetes集群和安装网络插件Calico或Flannel。
1022 4
|
4月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
793 69