添加另一个节点的提示:
1) 版本:
最好检查所有节点的状态:
http://elastic-node1:9200/
请记住,在大多数情况下:版本需要相同,即使是次要的
{
"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 中看到不同的版本号,例如
"number" : "5.2.1"
在这种情况下,您必须将您的节点更新到版本 5.2.2(与 node1 相同)。
2) 节点和副本:
节点的用例是什么?对于 3 个节点,我会这样做:
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"transient": {
"discovery.zen.minimum_master_nodes": 3
}
}
'
更好的是更改 Elasticsearch 的配置文件中的设置:
/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 个节点,你想要两个副本和一个主节点吗?
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
您可以通过以下请求做到这一点(请仔细阅读上面提到的链接):
curl -XPUT localhost:9200/_cluster/settings -d '{
"transient" :{
"cluster.routing.allocation.enable" : "all"
}
}';echo
4) 永远不要忘记,网络:
防火墙、网络...你能到达端口 9200 的新节点吗?
你能在你的网络浏览器上看到它吗?
可以吗
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
只留下你想保留的节点:
discovery.zen.ping.unicast.hosts:["IP_ADDRESS_OR_HOSTNAME1", "IP_ADDRESS_OR_HOSTNAME2"]
* 检查您的状态 *
检查http://elk-pipeline:9200/_cat/shards
你的状态是什么?您可能会看到:正在初始化
这可能意味着数据被传输。因此,如果您的数据很大(而不是在 SSD 上),请稍候。
不要忘记
您可以通过键入以下内容查看您的数据当前是否正在移动:
[watch] du /var/lib/elasticsearch/
暂时就这些了。我会不时尝试在此处添加更多信息。
请随时更改/添加。