如何向我的 Elasticsearch 集群添加新节点 [英] How to add a new node to my Elasticsearch cluster

查看:114
本文介绍了如何向我的 Elasticsearch 集群添加新节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的集群具有黄色运行状况,因为它只有一个节点,因此副本保持未签名仅仅是因为没有其他节点可用于包含它们.

My cluster has a yellow health as it has only one single node, so the replicas remain unasigned simply because no other node is available to contain them.

所以我想创建/添加另一个节点,以便 Elasticsearch 可以开始向它分配副本.我只有一台机器并且我将 ES 作为服务运行.

So I want to create/add another node so Elasticsearch can begin allocating replica’s to it. I've only one machine and I'm running ES as a service.

我发现了大量包含一些信息的站点,但没有一个告诉我清楚如何向 ES 添加另一个节点.

I've found tons of site with some info but none of them is giving me clearly how can I add another node to ES.

有人可以向我解释我必须编辑哪些文件以及我必须启动哪些命令才能在我的集群中创建另一个节点吗?我必须运行两个 ES 实例吗?我该怎么做?

Can someone explain me which files do I've to edit and what commands do I've to launch in order to create another node in my cluster? Do I've to run two ES instance? How can I do this?

提前致谢.

推荐答案

添加另一个节点的提示:

1) 版本:

检查所有节点的状态是一个很好的建议:http://elastic-node1:9200/

It is a good advise to check all of your nodes for the status: http://elastic-node1:9200/

请记住,在大多数情况下:版本必须相同,甚至是次要的

Keep in mind that in most cases: VERSION NEED TO BE THE SAME, EVEN MINOR

{
"name" : "node2",
"cluster_name" : "xxxxxxxxxxx",
"cluster_uuid" : "n-xxxxxxxxxxxxxxx",
"version" : {
  "number" : "5.2.2",
  "build_hash" : "xxxx",
  "build_date" : "20-02-24T17:26:45.835Z",
  "build_snapshot" : false,
  "lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}

请记住,如果您在 node1 中看到不同的版本号,例如

Keep in mind that if you see a different version number in node1, e.g.

  "number" : "5.2.1"

在这种情况下,您必须将节点更新到版本 5.2.2(与 node1 相同).

you have to update your node in that case to version 5.2.2 (same as node1).

2) 节点和副本:

节点的用例是什么?对于 3 个节点,我会这样做:

What is the usecase of the node? For 3 nodes I would do this:

curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
  "transient": {
    "discovery.zen.minimum_master_nodes": 3
  }
}
'

更好的是更改 Elasticsearch 配置文件中的设置:

Even better is to change settings in Elasticsearch's configuration file:

/etc/elasticsearch/elasticsearch.yml 

# need to be changed on each node (has to be unique for each node):
node.name: node1

# need to be the same in all nodes:
cluster.name: my_cluster
discovery.zen.ping.unicast.hosts: ["IP_ADDRESS_OR_HOSTNAME1", "IP_ADDRESS_OR_HOSTNAME2", "IP_ADDRESS_OR_HOSTNAME3"]

如果你有 3 个节点,你想要两个副本和一个主节点吗?

And if you have 3 nodes, do you want two replicas and one primary?

curl -XPUT 'localhost:9200/_settings?pretty' -H 'Content-Type: application/json' -d'
{
    "index" : {
        "number_of_replicas" : 2
    }
}'

3) 确保节点已启用

有一种方法可以踢一个节点:

There is a way to kick a node:

curl -XPUT localhost:9200/_cluster/settings -d '{
  "transient" :{
      "cluster.routing.allocation.exclude._ip" : "NODE_TO_REMOVE_IP_ADDRESS_OR_HOSTNAME"
   }
}';echo

所以如果你这样做了,现在你想重新添加节点:https://www.elastic.co/guide/en/elasticsearch/guide/current/_rolling_restarts.html

So if you did that, and now you want to add the node back: https://www.elastic.co/guide/en/elasticsearch/guide/current/_rolling_restarts.html

您可以通过以下请求做到这一点(请仔细阅读上面提到的链接):

you can do that with following request (please read carefully mentioned link above):

curl -XPUT localhost:9200/_cluster/settings -d '{
  "transient" :{
        "cluster.routing.allocation.enable" : "all"
   }
}';echo

4) 永远不要忘记,网络:

防火墙、网络……你能在 9200 端口到达新节点吗?你能在你的网络浏览器上看到它吗?

Firewall, network... Can you reach the new node at port 9200? Can you see it on your web browser?

你可以吗

curl http://your-elasticsearch-hostname:9200/

?

1) 使用 API 删除

curl -XPUT 'http://localhost:9200/_cluster/settings?pretty' -d '
{
  "transient" : {
    "cluster.routing.allocation.exclude._name" : "node3"
  }
}'

2) 检查您的配置文件

检查下的配置文件:/etc/elasticsearch/elasticsearch.yml

Check config file under: /etc/elasticsearch/elasticsearch.yml

只留下你想保留的节点:

and leave only the nodes you want to keep:

discovery.zen.ping.unicast.hosts:["IP_ADDRESS_OR_HOSTNAME1", "IP_ADDRESS_OR_HOSTNAME2"]

* 检查您的状态 *

检查 http://elk-pipeline:9200/_cat/shards你的身份是什么?您可能会看到:正在初始化这可能意味着数据被传输.因此,如果您的数据很大(并且不在 SSD 上),请稍等.

Check http://elk-pipeline:9200/_cat/shards What is your status? You may see: INITIALIZING That probably means that data is transferred. So if your data is large, (and not on SSD), wait.

不要忘记

您可以通过键入以下内容查看您的数据当前是否正在移动:

You can see if your data is currently moving by typing:

[watch] du /var/lib/elasticsearch/

暂时就这些.我会不时尝试在此处添加更多信息.

That is all for now. I will try to add more information here from time to time.

请随时更改/添加.

这篇关于如何向我的 Elasticsearch 集群添加新节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆