ELK之Elasticsearch集群

环境:

jdk11

Elasticsearch-7.16.3

window10

Elasticsearch下载

window 实现Elasticsearch伪集群

一、部署

创建 Elasticsearch ,复制三份,分别命名node-1、node-2、node-3 

 

node-1 节点

 新建Elasticsearch 集群 node-1 节点

修改 node-1/config/elasticsearch.yml

cluster.name: es-cluster  # 集群名称,节点之间保持一致
node.name: node-1   # 节点名称,每个节点不能相同

node.master: true # 是否可以成为master节点,master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等
node.data: true # 是否可以成为data节点,data节点主要用于执行数据相关的操作。比如文档的CRUD

network.host: localhost  # IP

http.port: 9200  # port  http端口号

#tcp监听端口
transport.tcp.port: 5200

#候选主节点的地址,在开启服务后可以被选为主节点
discovery.zen.ping.unicast.hosts: ["localhost:5200","localhost:5201","localhost:5202"] # 集群ip列表,注意:为tcp 端口号
discovery.zen.minimum_master_nodes: 2 # 可以成为master节点的数量, 配置规则 n/2+1

# 设置cors
http.cors.enabled: true
http.cors.allow-origin: "*"

 打开 http://localhost:9200/ 

 检查集群健康,打开 http://localhost:9200/_cluster/health 

{
  "cluster_name": "es-cluster", //集群名称
  "status": "green", //green:所有分片、复制分片都可用,yellow:主分片可用,复制分片不全可用,red:不是所有主分片可用
  "timed_out": false,
  "number_of_nodes": 1, //节点数量
  "number_of_data_nodes": 1, //数据节点数量
  "active_primary_shards": 2,
  "active_shards": 2,
  "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
}

 

 node-2 节点

这里http.port 端口号不一致是因为是在同一台电脑配置集群缘故,不同服务器部署,port端口号默认系统即可

修改 node-2/config/elasticsearch.yml

cluster.name: es-cluster  # 集群名称
node.name: node-2   # 节点名称

node.master: true # 是否可以成为master节点,master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等
node.data: true # 是否可以成为data节点,data节点主要用于执行数据相关的操作。比如文档的CRUD

network.host: localhost  # IP

http.port: 9201  # port  http端口号

#tcp监听端口
transport.tcp.port: 5201

#候选主节点的地址,在开启服务后可以被选为主节点
discovery.zen.ping.unicast.hosts: ["localhost:5200","localhost:5201","localhost:5202"] # 集群ip列表,注意:为tcp 端口号
discovery.zen.minimum_master_nodes: 2 # 可以成为master节点的数量, 配置规则 n/2+1

# 设置cors
http.cors.enabled: true
http.cors.allow-origin: "*"

 查看集群状态:

http://localhost:9200/_cluster/health 

http://localhost:9201/_cluster/health

可以看到集群已经存在两个节点了

 node-3 节点

这里http.port 端口号不一致是因为是在同一台电脑配置集群缘故,不同服务器部署,port端口号默认系统即可

修改 node-3/config/elasticsearch.yml

cluster.name: es-cluster  # 集群名称
node.name: node-3   # 节点名称

node.master: true # 是否可以成为master节点,master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等
node.data: true # 是否可以成为data节点,data节点主要用于执行数据相关的操作。比如文档的CRUD

network.host: localhost  # IP

http.port: 9202  # port  http端口号

#tcp监听端口
transport.tcp.port: 5202

#候选主节点的地址,在开启服务后可以被选为主节点
discovery.zen.ping.unicast.hosts: ["localhost:5200","localhost:5201","localhost:5202"] # 集群ip列表,注意:为tcp 端口号
discovery.zen.minimum_master_nodes: 2 # 可以成为master节点的数量, 配置规则 n/2+1

# 设置cors
http.cors.enabled: true
http.cors.allow-origin: "*"

查看集群健康状态 

http://localhost:9200/_cluster/health 

http://localhost:9201/_cluster/health

http://localhost:9202/_cluster/health

可以看到节点数量已经为3个

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值