ipfs-cluster-ctl
是用于管理节点节点和执行操作的客户端应用程序。 ipfs-cluster-ctl
使用节点提供的HTTP API,它与集群服务完全分开。
用法
使用信息可以通过运行获得:
$ ipfs-cluster-ctl --help
您还可以获取特定于命令的帮助 ipfs-cluster-ctl help [cmd]
。(--host
)可用于与任何远程集群对等节点通信(localhost
默认情况下使用)。总之,它的工作原理如下:
$ ipfs-cluster-ctl id # show cluster peer and ipfs daemon information
$ ipfs-cluster-ctl peers ls # list cluster peers
$ ipfs-cluster-ctl peers rm <peerid> # remove a cluster peer
$ ipfs-cluster-ctl add myfile.txt http://domain.com/file.txt # adds content to the cluster
$ ipfs-cluster-ctl pin add Qma4Lid2T1F68E3Xa3CpE6vVJDLwxXLD8RfiB9g1Tmqp58 # pins a CID in the cluster
$ ipfs-cluster-ctl pin rm Qma4Lid2T1F68E3Xa3CpE6vVJDLwxXLD8RfiB9g1Tmqp58 # unpins a CID from the clustre
$ ipfs-cluster-ctl pin ls [CID] # list tracked CIDs (shared state)
$ ipfs-cluster-ctl status [CID] # list current status of tracked CIDs (local state)
$ ipfs-cluster-ctl sync Qma4Lid2T1F68E3Xa3CpE6vVJDLwxXLD8RfiB9g1Tmqp58 # re-sync seen status against status reported by the IPFS daemon
$ ipfs-cluster-ctl recover Qma4Lid2T1F68E3Xa3CpE6vVJDLwxXLD8RfiB9g1Tmqp58 # attempt to re-pin/unpin CIDs in error state
认证
可以使用基本身份验证支持配置IPFS集群API。
ipfs-cluster-ctl --basic-auth <username:password>
将使用给定的凭据来执行请求。
请注意,除非--force-http
传递, 否则 basic-auth
仅在使用--https
或使用libp2p API端点的请求上使用。
使用libp2p API端点
从 0.3.5
版本,IPFS集群为HTTP API提供了一个libp2p端点,通过重新使用对等的libp2p主机或通过在API配置中设置具有给定参数的新主机,无需配置SSL证书即可提供通道安全性。
为了 ipfs-cluster-ctl
使用libp2p端点,请提供 --host
如下标志:
ipfs-cluster-ctl --host /ip4/<ip>/ipfs/<peerID> ...
或者
ipfs-cluster-ctl --host /dnsaddr/mydomain.com ...
(在你的dns中设置一个_dnsaddr TXT dnsaddr=peer_multiaddress
文件)。
如果您正在联系的libp2p对等节点使用 集群密钥 (专用网络密钥),则还需要提供 --secret <32 byte-hex-encoded key>
到该命令。
我们建议您在shell中使用ipfs-cluster-ctl
命令。
退出代码
ipfs-cluster-ctl
将退出:
0
:请求/操作成功。输出包含响应数据。1
:参数错误,网络错误或阻止应用程序执行请求并从IPFS Cluster API获取响应的任何其他错误。在这种情况下,输出包含错误的内容和HTTP代码0
。2
:IPFS集群对等节点错误。请求已正确执行但响应是错误(HTTP状态4xx或5xx)。在这种情况下,输出包含错误的内容和与之关联的HTTP代码。
调试
ipfs-cluster-ctl
采用一个 --debug
标志,允许检查请求路径和原始响应主体。