shard未分配给具有docker的elasticsearch集群

时间:2016-07-07 17:02:18

标签: elasticsearch

这是我的撰写文件,escp是我的docker图像文件

[(x, y) for x, y in zip(myList, myList[1:]) if y==9]

这是配置文件

elasticsearch_master:
    #image: elasticsearch:latest
    image: escp
    command: "elasticsearch \
      -Des.cluster.name=dcluster \
      -Des.node.name=esmaster \
      -Des.node.master=true \
      -Des.node.data=true \    
      -Des.node.client=false \
      -Des.discovery.zen.minimum_master_nodes=1"

    volumes:
      - "${PWD}/es/config:/usr/share/elasticsearch/config"
      - "${PWD}/esdata/node:/usr/share/elasticsearch/data"
      - "${PWD}/es/plugins:/usr/share/elasticsearch/plugins"      
    environment:
       - ES_HEAP_SIZE=512m
    ports:
      - "9200:9200"
      - "9300:9300"

elasticsearch1:
    #image: elasticsearch:latest
    image: escp
    command: "elasticsearch \ 
      -Des.cluster.name=dcluster \
      -Des.node.name=esnode1 \
      -Des.node.data=true \
      -Des.node.client=false \
      -Des.node.master=false \
      -Des.discovery.zen.minimum_master_nodes=1 \
      -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
    links:
      - elasticsearch_master
    volumes:
      - "${PWD}/es/config:/usr/share/elasticsearch/config"
      - "${PWD}/esdata/node1:/usr/share/elasticsearch/data"
      - "${PWD}/es/plugins:/usr/share/elasticsearch/plugins"
    environment:
       - ES_HEAP_SIZE=512m

elasticsearch2:
    #image: elasticsearch:latest
    image: escp
    command: "elasticsearch \
      -Des.cluster.name=dcluster \
      -Des.node.name=esnode2 \
      -Des.node.data=true \
      -Des.node.client=false \
      -Des.node.master=false \
      -Des.discovery.zen.minimum_master_nodes=1 \
      -Des.discovery.zen.ping.unicast.hosts=elasticsearch_master"
    links:
      - elasticsearch_master
    volumes:
      - "${PWD}/es/config:/usr/share/elasticsearch/config"
      - "${PWD}/esdata/node2:/usr/share/elasticsearch/data"
      - "${PWD}/es/plugins:/usr/share/elasticsearch/plugins"
    environment:
       - ES_HEAP_SIZE=512m

运行后

index.number_of_shards: 1
index.number_of_replicas: 0
network.host: 0.0.0.0

但是当我创建新索引时,会显示UNASSIGNED ...

           Name                         Command               State                       Ports
--------------------------------------------------------------------------------------------------------------------
est_elasticsearch1_1         /docker-entrypoint.sh elas ...   Up      9200/tcp, 9300/tcp
est_elasticsearch2_1         /docker-entrypoint.sh elas ...   Up      9200/tcp, 9300/tcp
est_elasticsearch_master_1   /docker-entrypoint.sh elas ...   Up      0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp

检查节点

curl -s '192.168.99.100:9200/_cluster/health?pretty'
{
  "cluster_name" : "dcluster",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 1,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 0.0
}

检查分片

curl -s '192.168.99.100:9200/_cat/nodes?v'
host       ip         heap.percent ram.percent load node.role master name
172.17.0.2 172.17.0.2           13          33 0.00 d         *      esmaster
172.17.0.3 172.17.0.3           16          33 0.00 d         -      esnode1
172.17.0.4 172.17.0.4           13          33 0.00 d         -      esnode2

检查分配

curl -s '192.168.99.100:9200/_cat/shards'
abcq 0 p UNASSIGNED

检查设置

curl -s '192.168.99.100:9200/_cat/allocation?v'
shards disk.indices disk.used disk.avail disk.total disk.percent host       ip         node
     0           0b   223.4gb      9.5gb    232.9gb           95 172.17.0.4 172.17.0.4 esnode2
     0           0b   223.4gb      9.5gb    232.9gb           95 172.17.0.2 172.17.0.2 esmaster
     0           0b   223.4gb      9.5gb    232.9gb           95 172.17.0.3 172.17.0.3 esnode1
     1                                                                                 UNASSIGNED

启用重新路由

curl 'http://192.168.99.100:9200/_cluster/settings?pretty'
{
  "persistent" : { },
  "transient" : { }
}

重新路由索引abcq

curl 'http://192.168.99.100:9200/_cluster/settings?pretty'
{
  "persistent" : { },
  "transient" : {
    "cluster" : {
      "routing" : {
        "allocation" : {
          "enable" : "true"
        }
      }
    }
  }
}

得到错误

    curl -XPOST http://192.168.99.100:9200/_cluster/reroute?pretty -d '{ 
    "commands" : [ 
        { 
            "allocate" : {
                "index" : "abcq",
                "shard" : 0, 
                "node" : "esnode2", 
                "allow_primary" : true 
            } 
        } 
    ] 
}'

为什么我创建新索引获取未分配,任何人都可以帮忙吗?感谢。

1 个答案:

答案 0 :(得分:0)

这里的家伙是如何解决问题的。

more than allowed [90.0%] used disk on node

这意味着我的磁盘已满,没有太多空间用于分片分配。

shards disk.indices disk.used disk.avail disk.total disk.percent host       ip         node
     0           0b   223.4gb      9.5gb    232.9gb           95 172.17.0.4 172.17.0.4 esnode2

禁用磁盘检查或将其设置为低级

curl -XPUT localhost:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.disk.threshold_enabled" : false
    }
}'
curl -XPUT http://192.168.99.100:9200/_cluster/settings -d '
{
    "transient" : {
        "cluster.routing.allocation.disk.watermark.low": "10%",
        "cluster.routing.allocation.disk.watermark.high": "10gb",
        "cluster.info.update.interval": "1m"
    }
}'
希望这可以帮助哦,更多细节可以在这里查看。 https://www.elastic.co/guide/en/elasticsearch/reference/current/disk-allocator.html