1.3.9. /db/_shards

2.0 版本新增。

GET /{db}/_shards

响应将包含数据库分片的列表。每个分片将包含其内部数据库范围,以及存储这些分片副本的节点。

参数:
  • db – 数据库名称

请求头:
  • Accept

    • application/json

    • text/plain

响应头:
  • Content-Type

    • application/json

    • text/plain; charset=utf-8

响应 JSON 对象:
  • shards (object) – 将分片范围映射到集群中每个节点上的单个分片副本

状态码:

请求:

GET /db/_shards HTTP/1.1
Accept: */*
Host: localhost:5984

响应:

HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Length: 621
Content-Type: application/json
Date: Fri, 18 Jan 2019 19:55:14 GMT
Server: CouchDB/2.4.0 (Erlang OTP/19)

{
  "shards": {
    "00000000-1fffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "20000000-3fffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "40000000-5fffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "60000000-7fffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "80000000-9fffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "a0000000-bfffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "c0000000-dfffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ],
    "e0000000-ffffffff": [
      "[email protected]",
      "[email protected]",
      "[email protected]"
    ]
  }
}

1.3.10. /db/_shards/doc

GET /{db}/_shards/{docid}

返回有关特定文档存储到的特定分片的信息,以及有关该分片在哪些节点上具有副本的信息。

参数:
  • db – 数据库名称

  • docid – 文档 ID

请求头:
  • Accept

    • application/json

    • text/plain

响应头:
  • Content-Type

    • application/json

    • text/plain; charset=utf-8

响应 JSON 对象:
  • range (string) – 文档存储的分片范围

  • nodes (array) – 为分片副本提供服务的节点列表

状态码:

请求:

HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Length: 94
Content-Type: application/json
Date: Fri, 18 Jan 2019 20:08:07 GMT
Server: CouchDB/2.3.0-9d4cb03c2 (Erlang OTP/19)

响应:

HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Length: 94
Content-Type: application/json
Date: Fri, 18 Jan 2019 20:26:33 GMT
Server: CouchDB/2.3.0-9d4cb03c2 (Erlang OTP/19)

{
  "range": "e0000000-ffffffff",
  "nodes": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ]
}

1.3.11. /db/_sync_shards

2.3.1 版本新增。

POST /{db}/_sync_shards

对于给定的数据库,强制启动所有数据库分片的所有副本的内部分片同步。

这通常仅在执行集群维护时使用,例如 移动分片

参数:
  • db – 数据库名称

请求头:
  • Accept

    • application/json

    • text/plain

响应头:
  • Content-Type

    • application/json

    • text/plain; charset=utf-8

响应 JSON 对象:
  • ok (boolean) – 操作状态。在成功的情况下可用

  • error (string) – 错误类型。如果响应代码为 4xx,则可用

  • reason (string) – 错误描述。如果响应代码为 4xx,则可用

状态码:

请求:

POST /db/_sync_shards HTTP/1.1
Host: localhost:5984
Accept: */*

响应:

HTTP/1.1 202 Accepted
Cache-Control: must-revalidate
Content-Length: 12
Content-Type: application/json
Date: Fri, 18 Jan 2019 20:19:23 GMT
Server: CouchDB/2.3.0-9d4cb03c2 (Erlang OTP/19)
X-Couch-Request-ID: 14f0b8d252
X-CouchDB-Body-Time: 0

{
    "ok": true
}

注意

管理员可能希望在分片同步期间将他们的 [mem3] sync_concurrency 值提高到更大的数字。