elasticsearch-从多台服务器迁移到一台服务器

时间:2020-07-23 08:42:57

标签: elasticsearch

我有5个用于Elasticsearch的服务器集群,所有服务器都具有相同版本的Elasticsearch。

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

我该怎么办?

我怎么知道哪个服务器上有数据?

使用以下方法更改_cluster /设置后:

PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.require._host" : "server1"
  }
}

我得到: curl -GET http:// localhost:9200 / _cat / allocation?v

以下内容:

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

以下内容:

#! 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"
        }
      }
    },
...

1 个答案:

答案 0 :(得分:2)

您可以使用Resource>videos,Method>update将所有数据移至服务器1。

只需运行:

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有足够的存储空间来存储所有主要分片即可。

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

PUT _all/_settings
{
  "index" : {
    "number_of_replicas" : 0
  }
}