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) -- 将碎片范围映射到群集中每个节点上的单个碎片副本
状态代码: - 200 OK -- 请求已成功完成
- 400 Bad Request -- 数据库名称无效
- 401 Unauthorized -- 需要读取权限
- 415 Unsupported Media Type -- 坏的 Content-Type 价值
- 500 Internal Server Error -- 内部服务器错误或超时
请求 :
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": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "20000000-3fffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "40000000-5fffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "60000000-7fffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "80000000-9fffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "a0000000-bfffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "c0000000-dfffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ], "e0000000-ffffffff": [ "couchdb@node1.example.com", "couchdb@node2.example.com", "couchdb@node3.example.com" ] } }
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) -- 为碎片副本提供服务的节点列表
状态代码: - 200 OK -- 请求已成功完成
- 401 Unauthorized -- 需要读取权限
- 404 Not Found -- 找不到数据库或文档
- 500 Internal Server Error -- 内部服务器错误或超时
请求 :
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": [ "node1@127.0.0.1", "node2@127.0.0.1", "node3@127.0.0.1" ] }
1.3.11. /db/_sync_shards
¶
2.3.1 新版功能.
-
POST
/{db}/_sync_shards
¶ 对于给定的数据库,force为所有数据库碎片的所有副本启动内部碎片同步。
这通常只在执行群集维护时使用,例如 moving a shard .
参数: - db -- 数据库名称
请求标头: - Accept --
- application/json
- text/plain
响应头: - Content-Type --
- application/json
- text/plain; charset=utf-8
响应JSON对象: - ok (boolean) -- 操作状态。成功时可用
- error (string) -- 类型错误。如果响应代码为
4xx
- reason (string) -- 错误描述。如果响应代码为
4xx
状态代码: - 202 Accepted -- 已接受请求
- 400 Bad Request -- 数据库名称无效
- 401 Unauthorized -- 需要CouchDB服务器管理员权限
- 404 Not Found -- 找不到数据库
- 500 Internal Server Error -- 内部服务器错误或超时
请求 :
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
值设置为碎片同步持续时间的较大数字。