当前位置: 首页 > news >正文

ES搭建集群

一、创建 elasticsearch-cluster 文件夹

创建 elasticsearch-7.8.0-cluster 文件夹,在内部复制三个 elasticsearch 服务。

 然后每个文件目录中每个节点的 config/elasticsearch.yml 配置文件

node-1001 节点

#节点 1 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node-1001
node.master: true
node.data: true
#ip 地址
network.host: localhost
#http 端口
http.port: 1001
#tcp 监听端口
transport.tcp.port: 9301
#discovery.seed_hosts: ["localhost:9301", "localhost:9302","localhost:9303"]
#discovery.zen.fd.ping_timeout: 1m
#discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

node-1002 节点

#节点 2 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node-1002
node.master: true
node.data: true
#ip 地址
network.host: localhost
#http 端口
http.port: 1002
#tcp 监听端口
transport.tcp.port: 9302
discovery.seed_hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

node-1003 节点

#节点 3 的配置信息:
#集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
#节点名称,集群内要唯一
node.name: node-1003
node.master: true
node.data: true
#ip 地址
network.host: localhost
#http 端口
http.port: 1003
#tcp 监听端口
transport.tcp.port: 9303
#候选主节点的地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["localhost:9301", "localhost:9302"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#集群内的可以被选为主节点的节点列表
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#跨域配置
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

启动集群
分别依次双击执行节点的bin/elasticsearch.bat, 启动节点服务器(可以编写一个脚本启动),启动后,会自动加入指定名称的集群。

测试集群
一、用Postman,查看集群状态

GET http://127.0.0.1:1001/_cluster/health
GET http://127.0.0.1:1002/_cluster/health
GET http://127.0.0.1:1003/_cluster/health
 返回结果皆为如下:

{"cluster_name": "my-application","status": "green","timed_out": false,"number_of_nodes": 3,"number_of_data_nodes": 3,"active_primary_shards": 0,"active_shards": 0,"relocating_shards": 0,"initializing_shards": 0,"unassigned_shards": 0,"delayed_unassigned_shards": 0,"number_of_pending_tasks": 0,"number_of_in_flight_fetch": 0,"task_max_waiting_in_queue_millis": 0,"active_shards_percent_as_number": 100.0
}

status字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下:

  1. green:所有的主分片和副本分片都正常运行。
  2. yellow:所有的主分片都正常运行,但不是所有的副本分片都正常运行。
  3. red:有主分片没能正常运行。
http://www.lryc.cn/news/135345.html

相关文章:

  • # Lua与C++交互(二)———— 交互
  • 机器人焊接生产线参数监控系统理解需求
  • 前端基础(ES6 模块化)
  • 第七章,文章界面
  • HJ102 字符统计
  • Maven聚合项目(微服务项目)创建流程,以及pom详解
  • Android OkHttp 源码浅析一
  • 【Redis】——Redis基础的数据结构以及应用场景
  • SpringBoot+WebSocket搭建多人在线聊天环境
  • 推荐适用于不同规模企业的会计软件:选择最适合您企业的解决方案
  • Apache Zookeeper架构和选举机制
  • 车联网TCU USB的配置和使用
  • Linux系统USB摄像头测试程序(三)_视频预览
  • 目标检测任务数据集的数据增强中,图像水平翻转和xml标注文件坐标调整
  • 系统架构的演变
  • IDC发布《亚太决策支持型分析数据平台评估》报告,亚马逊云科技位列“领导者”类别
  • C#之OpenFileDialog创建和管理文件选择对话框
  • Java中使用MongoTemplate 简单操作MongoDB
  • [Mac软件]Pixelmator Pro 3.3.12 专业图像编辑中文版
  • 吴恩达 GPT Prompting 课程
  • gpt3.5写MATLAB代码剪辑视频,使之保留画面ROI区域
  • 设计模式二十一:状态模式(State Pattern)
  • 【校招VIP】产品思维能力之产品设计
  • 微信小程序卡片横向滚动竖图
  • SpringBoot项目(支付宝整合)——springboot整合支付宝沙箱支付 从极简实现到IOC改进
  • 【AIGC】一款离线版的AI智能换脸工具V2.0分享(支持图片、视频、直播)
  • 管理类联考——逻辑——真题篇——按知识分类——汇总篇——一、形式逻辑——选言——相容选言——或
  • Git如何操作本地分支仓库?
  • WPS右键新建没有docx pptx xlsx 修复
  • 【巧学C++之西游篇】No.2 --- C++闹天宫,带着“重载“和“引用“