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

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

问题描述

我的群集的运行状况为 yellow ,因为它只有一个节点,因此,由于没有其他节点可用于包含副本,因此副本保持未分配状态。

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.

I已经找到了很多具有一些信息的网站,但没有一个给我清楚我怎么能向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)确保结点启用

有一种踢节点的方法:

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)永不F ORGET,网络:

防火墙,网络...您能否到达端口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天全站免登陆