当前位置:网站首页>ipfs挂载到本地磁盘
ipfs挂载到本地磁盘
2022-07-17 00:07:00 【龙烨华】
ipfs可以像传统的文件系统一样,将服务上的目录挂载在本地文件系统,方便用户浏览目录内容。网上对于ipfs mount指令的使用没有找到一个完整的教程,因此,在这里写一篇文章分享给大家。
我使用的是操作系统是centos7.9,ipfs使用的是0.13.0
创建文件并上传到ipfs
[[email protected] study]# mkdir ipfs-test & cd ipfs-test
[[email protected] ipfs-test]# echo "This first test file" > ipfs-1.txt
[[email protected] ipfs-test]# echo "This second test file" > ipfs-2.txt
[[email protected] ipfs-test]# ipfs add -r .
added QmXLe1PCnMhVBDwbuVr4tMhH62J5gjHMEiuw94cx2FM3pK ipfs-test/ipfs-1.txt
added QmZWra4FQSqhkMgPPGfimntoLN7LXan2chc4Voh6WFsiHe ipfs-test/ipfs-2.txt
added QmVrtr5DoFYBBc22MLe9rXWHJF9TtgcSSa9uNiZxCHGmuU ipfs-test启动ipfs daemon服务
[[email protected] ipfs-test]# ipfs daemon --mount
Initializing daemon...
go-ipfs version: 0.13.0
Repo version: 12
System version: amd64/linux
Golang version: go1.18.3
......
2022-07-04T11:12:16.596+0800 ERROR fuse/ipns ipns/ipns_unix.go:100 looking up /ipns/k51qzi5uqu5dlca4efnsxpum66zvctp8ptzr58zhre721prvr0hcmk96dqx0n9: could not resolve name
2022-07-04T11:12:16.599+0800 ERROR node node/mount_unix.go:92 error mounting: mountpoint does not exist: /ipfs
2022-07-04T11:12:16.599+0800 ERROR node node/mount_unix.go:96 error mounting: could not resolve name按照上面的操作,会出现ERROR错误,ipfs服务不能起来,这里需要将上一步产生的目录发布到IPNS。在发布之前还要创建ipfs, ipns的映射目录。再执行ipfs daemon --mount,出现Daemon is ready则可认为成功。
[[email protected] ipfs-test]# mkdir /ipfs /ipns
[[email protected] ipfs-test]# ipfs name publish --allow-offline QmVrtr5DoFYBBc22MLe9rXWHJF9TtgcSSa9uNiZxCHGmuU
[[email protected] ipfs-test]# ipfs daemon --mount
[[email protected] ipfs-test]# ipfs daemon --mount
Initializing daemon...
go-ipfs version: 0.13.0
Repo version: 12
System version: amd64/linux
Golang version: go1.18.3
......
IPFS mounted at: /ipfs
IPNS mounted at: /ipns
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
Daemon is ready挂载
另起来一个终端,执行ipfs mount命令,如果执行成功,会在/ipfs目录下出现QmVrtr5DoFYBBc22MLe9rXWHJF9TtgcSSa9uNiZxCHGmuU的目录,下面有第一步创建的两个文件,即挂载成功。
[[email protected] ipfs-test]# ipfs mount
IPFS mounted at: /ipfs
IPNS mounted at: /ipns
[[email protected] ipfs-test]# ls /ipfs/QmVrtr5DoFYBBc22MLe9rXWHJF9TtgcSSa9uNiZxCHGmuU
ipfs-1.txt ipfs-2.txt注意,直接在/ipfs上查看是没有权限的,会报错,因此要指定挂载的目录
[[email protected] ipfs-test]# ls /ipfs/
ls: 正在读取目录/ipfs/: 不允许的操作边栏推荐
猜你喜欢
随机推荐
07-BTC-挖矿
二分法查找
TCP与UDP,TCP服务器与客户端,UDP服务器与客户端
uni-app微信小程序——商城(8)——订单详情
Cento7安装mysql5.5以及升级5.7
Uni app wechat applet - Mall (4) - merchants
uni-app微信小程序——商城(6)——我的主页
记一次用canvas做出腾讯云首页banner流光效果的经历
2022.7.7 summary of some errors
同学们 小组作业记得别抄哈 幸好只传了两道题 不要出事了
ES6 map extract array object
nft发行价格是多少(解读NFT建立起NFT世界观)
14 检查整数及其两倍数是否存在
06-BTC-挖矿难度
07_ Basic use of events
Express的使用方法,路由的匹配与使用
The difference between let and VaR
2022年暑假ACM热身练习1(总结)
JS string to object JS object to string JS string to object
05_ Review object defineProperty









