【问题标题】:elasticsearch - moving from multi servers to one serverelasticsearch - 从多台服务器移动到一台服务器
【发布时间】:2020-07-23 20:12:17
【问题描述】:

我有一个包含 5 台用于 elasticsearch 的服务器的集群,所有服务器都使用相同版本的 elasticsearch。

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

我该怎么做?

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

在 _cluster/settings 更改后:

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

适用于:GET _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"
        }
      }
    },
...

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您可以使用shard allocation filtering 将所有数据移动到服务器 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
      }
    }
    

    【讨论】:

    • 使用 _host 我需要使用我通过 hostname linux 命令获得的内容。对吗?
    • 我做到了并得到了很好的响应,但是当我检查运行状况时,node.total 和 node.data 仍然得到 5
    • 这很正常,因为所有节点都还在。使用GET /_cat/allocation?v 验证您的所有分片都在 server1 上
    • 每个节点有 6 个分片。此外,在 PUT 命令之后我没有看到任何运行,我只得到了更改的快速响应。也许我需要重新启动系统?
    • 无需重启任何东西。请使用您从 _cat/allocation 命令中得到的内容更新您的问题。您还可以展示您从GET _cluster/settings?include_defaults 获得的信息吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多