首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >elasticsearch -从多个服务器转移到一个服务器

elasticsearch -从多个服务器转移到一个服务器
EN

Stack Overflow用户
提问于 2020-07-23 08:42:57
回答 1查看 248关注 0票数 2

我为elasticsearch提供了一个由5台服务器组成的集群,所有服务器都具有相同版本的elasticsearch。

我需要将所有数据从服务器2、3、4、5移动到服务器1。

我该怎么做呢?

我怎么知道哪台服务器有数据呢?

在更改_群集/设置后,使用:

代码语言:javascript
复制
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.require._host" : "server1"
  }
}

我得到的是:curl -GET cat/分配?

以下内容如下:

代码语言:javascript
复制
shards disk.indices disk.used disk.avail disk.total disk.percent host    ip      node
     6       54.5gb   170.1gb      1.9tb      2.1tb            7 *.*.*.* *.*.*.* node-5
     6       50.4gb   167.4gb      1.9tb      2.1tb            7 *.*.*.* *.*.*.* node-3
     6       22.6gb   139.8gb        2tb      2.1tb            6 *.*.*.* *.*.*.* node-2
     6       49.8gb   166.6gb      1.9tb      2.1tb            7 *.*.*.* *.*.*.* node-4
     6       54.8gb   172.1gb      1.9tb      2.1tb            7 *.*.*.* *.*.*.* node-1

还有:_cluster/settings?include_defaults GET

以下内容如下:

代码语言:javascript
复制
#! Deprecation: [node.max_local_storage_nodes] setting was deprecated in Elasticsearch and will be removed in a future release!
{
  "persistent" : {
    "cluster" : {
      "routing" : {
        "allocation" : {
          "require" : {
            "_host" : "server1"
          }
        }
      }
    }
  },
  "transient" : { },
  "defaults" : {
    "cluster" : {
      "max_voting_config_exclusions" : "10",
      "auto_shrink_voting_configuration" : "true",
      "election" : {
        "duration" : "500ms",
        "initial_timeout" : "100ms",
        "max_timeout" : "10s",
        "back_off_time" : "100ms",
        "strategy" : "supports_voting_only"
      },
      "no_master_block" : "write",
      "persistent_tasks" : {
        "allocation" : {
          "enable" : "all",
          "recheck_interval" : "30s"
        }
      },
      "blocks" : {
        "read_only_allow_delete" : "false",
        "read_only" : "false"
      },
      "remote" : {
        "node" : {
          "attr" : ""
        },
        "initial_connect_timeout" : "30s",
        "connect" : "true",
        "connections_per_cluster" : "3"
      },
      "follower_lag" : {
        "timeout" : "90000ms"
      },
      "routing" : {
        "use_adaptive_replica_selection" : "true",
        "rebalance" : {
          "enable" : "all"
        },
        "allocation" : {
          "node_concurrent_incoming_recoveries" : "2",
          "node_initial_primaries_recoveries" : "4",
          "same_shard" : {
            "host" : "false"
          },
          "total_shards_per_node" : "-1",
          "shard_state" : {
            "reroute" : {
              "priority" : "NORMAL"
            }
          },
          "type" : "balanced",
          "disk" : {
            "threshold_enabled" : "true",
            "watermark" : {
              "low" : "85%",
              "flood_stage" : "95%",
              "high" : "90%"
            },
            "include_relocations" : "true",
            "reroute_interval" : "60s"
          },
          "awareness" : {
            "attributes" : [ ]
          },
          "balance" : {
            "index" : "0.55",
            "threshold" : "1.0",
            "shard" : "0.45"
          },
          "enable" : "all",
          "node_concurrent_outgoing_recoveries" : "2",
          "allow_rebalance" : "indices_all_active",
          "cluster_concurrent_rebalance" : "2",
          "node_concurrent_recoveries" : "2"
        }
      },
     ...
      "nodes" : {
        "reconnect_interval" : "10s"
      },
      "service" : {
        "slow_master_task_logging_threshold" : "10s",
        "slow_task_logging_threshold" : "30s"
      },
      ...
      "name" : "cluster01",
      ...
      "max_shards_per_node" : "1000",
      "initial_master_nodes" : [ ],
      "info" : {
        "update" : {
          "interval" : "30s",
          "timeout" : "15s"
        }
      }
    },
...
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-23 08:53:21

您可以使用碎片分配滤波将所有数据移动到服务器1。

只需运行以下命令:

代码语言:javascript
复制
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.require._name" : "node-1",
    "cluster.routing.allocation.exclude._name" : "node-2,node-3,node-4,node-5"
  }
}

_name不同,您还可以使用_ip_host,这取决于什么对您更实用。

运行此命令后,所有主碎片将迁移到server1 (副本将被取消分配)。您只需要确保server1有足够的存储空间来存储所有主碎片。

如果您想摆脱未分配的副本(并返回到绿色状态),只需运行以下命令:

代码语言:javascript
复制
PUT _all/_settings
{
  "index" : {
    "number_of_replicas" : 0
  }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63050288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档