下表显示了可用的复制目标命令。
|
下表显示了复制目标的属性。
|
列出系统上所有可用的复制目标。
请求示例:
GET /api/storage/v2/replication/targets HTTP/1.1 Host: zfs-storage.example.com:215 Authorization: Basic Tm8gcGVla2luZyE= Accept: application/json
结果示例:
HTTP/1.1 200 OK X-Zfssa-Replication-Api: 1.0 Content-Type: application/json Content-Length: 529 { "targets": [{ "address": "ipaddr-1", "label": "zfs-storage-1", "hostname": "ipaddr-2", "asn": "9d7a7543-ca83-68f5-a8fc-f818f65e1cfc", "actions": 0, "target": "target-000", "href": "/api/storage/v2/replication/targets/zfs-storage-1" }, { "address": "ipaddr-3", "label": "zfs-storage-2", "hostname": "ipaddr-4", "asn": "16a4c82c-26c1-4a50-e317-ac53181f2e86", "actions": 0, "target": "target-001", "href": "/api/storage/v2/replication/targets/zfs-storage-2" }] }
此命令列出单个复制目标的详细信息。目标通过其主机名访问。
请求示例:
GET /api/storage/v2/replication/targets/zfs-storage-1 HTTP/1.1 Authorization: Basic Tm8gcGVla2luZyE= Host: zfs-storage.example.com:215 Accept: application/json
结果示例:
HTTP/1.1 200 OK X-Zfssa-Replication-Api: 1.0 Content-Type: application/json Content-Length: 337 { "target": { "href": "/api/storage/v2/replication/targets/zfs-storage-1", "address": "ipaddr-1", "label": "zfs-storage-1", "hostname": "ipaddr-2", "asn": "9d7a7543-ca83-68f5-a8fc-f818f65e1cfc", "actions": 0 } }
targets 命令用于为远程复制创建新的复制目标。
如果您需要确保复制通信通过特定的网络接口,请为目标设置一个静态路由,以指定该接口,如添加路由中所示。
请求示例:
有关 hostname 和 auto_accept_cert 属性的信息,请参见验证目标证书。
POST /api/replication/v2/targets HTTP/1.1 Authorization: Basic Tm8gcGVla2luZyE= Host: zfs-storage.example.com:215 Accept: application/json Content-Type: application/json Content-Length: 54 { "label":"zfs-storage-3", "hostname":"zfs-storage-3.example.com", "root_password":"root-password", "auto_accept_cert":true }
结果示例:
HTTP/1.1 201 Created Content-Length: 135 Content-Type: application/json Location: /service/v2/services/replication/targets/target-000 X-Zfssa-Replication-Api: 1.0 { "target": { "actions": 0, "address": "123.45.78.9:216", "asn": "fa5bf303-0dcb-e20d-ac92-cd129ccd2c81", "auto_accept_cert": true, "hostname": "zfs-storage-3.example.com", "href": "/service/v2/services/replication/targets/target-000", "label": "zfs-storage-3" } }
创建复制目标时,将会执行证书验证。证书验证包括以下步骤:
证书主机名检查
证书信任检查
如果主机名检查或证书信任检查失败,则不会创建目标。
主机名检查
hostname 属性的值可以为全限定域名或 IPv4 地址。建议使用的值为目标的全限定域名。
主机名检查验证目标的 hostname 属性中指定的主机名是否与证书中指定的主机匹配。如果您为 hostname 指定 IP 地址或非限定域名,而证书只有全限定域名,则主机名检查会失败,并且不会创建目标。
如果目标使用的是基于 ASN 的证书,请为 hostname 属性的值指定目标的全限定域名。
默认情况下执行主机名检查。如果将 host_match 属性设置为 false,将不执行主机名检查。
为了提高安全性,请将 hostname 属性的值设置为目标的全限定域名,并确保 host_match 属性设置为 true。
证书信任检查
证书信任检查验证以下证书之一是否已添加到源的可信证书列表,以及是否可供对等设备使用:
目标设备的证书。
颁发目标设备证书的证书颁发机构的证书。
如果证书不可信,则返回 HTTP 状态 409 (Conflict),并且不会创建目标。在以下示例中,为提高可读性,对消息行进行了断行:
{ "fault": { "code": 409, "name": "ERR_ILLEGAL_STATE", "message": "operation failed due to illegal state (Certificate is not trusted (encountered while attempting to run command \"commit\"))" } }
首次为该源创建此目标时,不知道目标主机的证书是否可信。由于 RESTful API 无法提示您确认证书,因此请将 auto_accept_cert 属性设置为 true 以自动接受目标的证书。
创建目标后,其证书可能会变得不可信。例如,源的管理员可能从可信证书列表中删除证书,或者目标的管理员可能替换证书。修改目标以将 auto_accept_cert 属性设置为 true,以告知源接受此证书为可信证书。
将会对每个对等设备和复制连接执行证书信任检查。如果证书不可信,则源将拒绝建立连接。
要检查证书的属性(如指纹或颁发者 commonName 或 SubjectAltName),上载证书或者删除证书,请参见管理证书。
此命令修改复制目标的属性。
请求示例:
PUT /api/replication/v2/targets/target-001 HTTP/1.1 Authorization: Basic Tm8gcGVla2luZyE= Host: zfs-storage.example.com:215 Accept: application/json Content-Type: application/json Content-Length: 78 { "hostname": "zfs-storage-3.example.com" }
此命令可删除现有的复制目标。
请求示例:
DELETE /service/v2/services/replication/targets/target-000 HTTP/1.1 Host: zfs-storage.example.com:215 Authorization: Basic Tm8gcGVla2luZyE=
成功删除后将返回 HTTP 状态 204 (No Content)。