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

简介: 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并实现搜索。  
相关文章
|
8月前
|
存储 数据安全/隐私保护 Windows
Windows中部署网盘神器 Filebrowser
ZeroNews (零讯)内网穿透赋予 FileBrowser 任意位置互联网访问的能力,无需用户具备固定公网IP,提供专用的访问域名,将 FileBrowser 转变为公有云盘,实现多用户在线协同工作。
|
12月前
|
Linux 应用服务中间件 nginx
在CentOS上部署Minikube教程
至此,您已成功在CentOS上部署并使用Minikube。您可以自由探索Kubernetes的世界,熟练配置和管理Kubernetes集群。
1019 20
|
Java Linux
CentOS环境搭建Elasticsearch集群
至此,您已成功在CentOS环境下搭建了Elasticsearch集群。通过以上介绍和步骤,相信您对部署Elasticsearch集群有了充分的了解。最后祝您在使用Elasticsearch集群的过程中顺利开展工作!
621 22
|
12月前
|
JSON 安全 数据可视化
Elasticsearch(es)在Windows系统上的安装与部署(含Kibana)
Kibana 是 Elastic Stack(原 ELK Stack)中的核心数据可视化工具,主要与 Elasticsearch 配合使用,提供强大的数据探索、分析和展示功能。elasticsearch安装在windows上一般是zip文件,解压到对应目录。文件,elasticsearch8.x以上版本是自动开启安全认证的。kibana安装在windows上一般是zip文件,解压到对应目录。elasticsearch的默认端口是9200,访问。默认用户是elastic,密码需要重置。
6091 0
|
Linux 虚拟化 Docker
Linux服务器部署docker windows
在当今软件开发中,Docker成为流行的虚拟化技术,支持在Linux服务器上运行Windows容器。流程包括:1) 安装Docker;2) 配置支持Windows容器;3) 获取Windows镜像;4) 运行Windows容器;5) 验证容器状态。通过这些步骤,你可以在Linux环境中顺利部署和管理Windows应用,提高开发和运维效率。
2332 1
|
Ubuntu 网络协议 Linux
快速部署WSL(Windows Subsystem for Linux)
WSL提供了一种轻量级的方法,使开发者能够在Windows上无缝运行Linux环境。通过本文介绍的步骤,可以快速安装、配置和使用WSL,以满足开发和测试的需求。
3136 8
|
Oracle 关系型数据库 MySQL
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
|
SQL 分布式计算 大数据
大数据-168 Elasticsearch 单机云服务器部署运行 详细流程
大数据-168 Elasticsearch 单机云服务器部署运行 详细流程
536 2
|
监控 应用服务中间件 nginx
详细解释容器以及虚拟机centos7.9容器化部署基础服务(容器化部署nginx)
容器是一种轻量级、可移植的软件打包和隔离技术,将应用程序及其依赖项打包,确保在任何环境中一致运行。容器共享主机操作系统内核,相比虚拟机更高效、轻量,具有快速启动和高资源利用率的特点。容器的关键技术包括命名空间(如 PID、NET 等)、控制组(cgroups)和联合文件系统(UnionFS)。使用容器可以提高开发和部署效率,简化管理,确保环境一致性。例如,在 CentOS 7.9 上部署 Nginx 时,可以通过 Docker 下载和运行 `nginx:1.20` 镜像,并通过端口映射使外部请求访问 Nginx 服务。此外,还可以将测试页面复制到容器中,进一步验证容器的功能。
516 0
|
存储 安全 Java
在CentOS 7上安装和配置Elasticsearch的方法
在CentOS 7上安装和配置Elasticsearch的方法
1356 0

热门文章

最新文章