es 简单集群搭建,版本8.6.2

Node-1 配置:

yaml 复制代码
# elasticsearch.yml for Node-1

cluster.name: my-test-cluster
node.name: node-1
path.data: /path/to/data/node-1
path.logs: /path/to/logs/node-1
network.host: 127.0.0.1
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["127.0.0.1:9301", "127.0.0.1:9302"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]

Node-2 配置:

yaml 复制代码
# elasticsearch.yml for Node-2

cluster.name: my-test-cluster
node.name: node-2
path.data: /path/to/data/node-2
path.logs: /path/to/logs/node-2
network.host: 127.0.0.1
http.port: 9201
transport.port: 9301
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9302"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]

Node-3 配置:

yaml 复制代码
# elasticsearch.yml for Node-3

cluster.name: my-test-cluster
node.name: node-3
path.data: /path/to/data/node-3
path.logs: /path/to/logs/node-3
network.host: 127.0.0.1
http.port: 9202
transport.port: 9302
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301"]
cluster.initial_master_nodes: ["node-1","node-2","node-3"]

请注意以下几点:

  • 节点名称 (node.name): 每个节点的名称应该是唯一的。

  • 数据目录 (path.data): 每个节点的数据目录应该是独立的,以防止节点之间的数据冲突。

  • HTTP 端口 (http.port): 每个节点的 HTTP 端口应该是唯一的。

  • 传输端口 (transport.port): 每个节点的传输端口应该是唯一的。

  • 发现种子主机 (discovery.seed_hosts): 每个节点的发现种子主机应该包含其他节点的地址和端口。

  • 初始主节点 (cluster.initial_master_nodes): 所有节点的此设置应该包含集群中的一个或多个节点的名称,用于确定初始主节点。在上述配置中,node-1 是初始主节点。

以上由chat gpt生成,下面是踩的坑

实践中遇到的问题
bash 复制代码
can't add node 
{node-3}{O5Ruh7M4Q9qfab0KqZYQ5g}{T2m2C0h1TkitZVddABjv3A}{node-3}{127.0.0.1}{127.0.0.1:9302}{cdfhilmrstw}{ml.machine_memory=34221711360, ml.allocated_processors=12, ml.max_jvm_size=4294967296, ml.allocated_processors_double=12.0, xpack.installed=true}, 
found existing node 
{node-2}{O5Ruh7M4Q9qfab0KqZYQ5g}{vMqqqsdlS7aWl1T1jtCKTQ}{node-2}{127.0.0.1}{127.0.0.1:9301}{cdfhilmrstw}{ml.machine_memory=34221711360, ml.allocated_processors=12, ml.max_jvm_size=4294967296, ml.allocated_processors_double=12.0, xpack.installed=true} 
with the same id but is a different node instance
原因及解决办法

原因就是我在启动es两个节点启动成功之后,为了省事 ,复制 node-2的目录。

然后只修改了配置文件elasticsearch.yml,而没有删除node-2 启动时生成的数据。

导致集群中唯一标识节点node.id 重复了

node.id 是在es第一次启动时自动生成的uuid .

解决办法:删除es目录下的data目录,重新生成它的 node.id

相关推荐
Elasticsearch1 天前
对 OpenTelemetry Kafka 接收器的两项改动,避免一个缓慢的租户拖住其他租户
elasticsearch
全栈陈序员2 天前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
Percep_gan2 天前
Linux中安装gitea,很详细
linux·elasticsearch·gitea
木棉软糖3 天前
5 步确认 TiDB 历史抽数的 Logstash 有没有真的写进 ES
elasticsearch·oracle·tidb
全栈陈序员3 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
Elasticsearch3 天前
Elasticsearch:稠密向量字段类型
elasticsearch
全栈陈序员4 天前
【Git】从入门到精通(五)—— git add:将文件加入暂存区
大数据·git·elasticsearch
翊众建站4 天前
用 JSON-LD 给企业官网做结构化数据:LocalBusiness 与 FAQPage 实践笔记
人工智能·搜索引擎·json
全栈陈序员4 天前
【Git】从入门到精通(七)—— git status:查看仓库状态
大数据·git·elasticsearch
fengye2071614 天前
第三章 编译cpython
大数据·elasticsearch·搜索引擎