当前位置:网站首页>IPFs file persistence operation
IPFs file persistence operation
2022-07-19 01:46:00 【Long Yehua】
IPFS As a pioneering project of blockchain distributed storage sector, it has experienced 6 Constantly improve and perfect , Mature data storage mechanisms have long been available . In fact, in the eyes of many people ,IPFS Distributed storage network can permanently ensure the safety of human data , Of course, some people say that once files are stored in ipfs This statement is wrong , because ipfs Nodes may also cause data loss for various reasons .
If a data object is ipfs Accessed by multiple nodes in the network , Multiple backups will be generated at the access node , The backed up data object will not be permanently saved , When nodes execute GC In operation , The backup data will be cleared . A piece of data can be permanently saved by the node , You need to execute pin operation . Here's the right ipfs Explain the operation of data object persistence .
The server Get ready
Prepare two servers node1 and node2, Install on two servers respectively ipfs, start-up ipfs Daemon (ipfs daemon), Installation and startup will not be explained here .
Data preparation
node1 Prepare a copy of the data
[[email protected] ~]# echo "node-1" | ipfs add
added QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsinode2 Prepare the data
[[email protected] ~]# echo "node-2" | ipfs add
added QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bDDo not make persistent observations
node1 through ipfs pin ls You can see the new data object , Out of sight node2 New data objects on . On the contrary, in node2 It's the same with me
[[email protected] ~]# ipfs pin ls
QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi recursive
[[email protected] ~]# ipfs pin ls
QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD recursivestay node1 Visit node2 Data objects for , Be able to read the contents of the file , But when accessing the persistence area ,pin There is no node2 Data object hash It's worth it
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
node-2
[[email protected] ~]# ipfs pin ls
QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi recursiveStop at this time node2 Of daemon Daemon , Revisit node2 Data objects for , Still able to read the content , This is because the node did not execute GC operation , perform GC After the operation ,node2 Data can no longer be accessed .
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
node-2
[[email protected] ~]# ipfs repo gc
removed bafkreibhk7az6hwkh6qbluusf35olnm4shzr7loyasbgbnmrkvi2hsfv5a
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
.............................( Can't get , Long wait )Persistence operation
restart node2 Of daemon Daemon , stay node1 Pull up again node2 Data objects for , And add it to persistence , You can see in the persistence list node2 Data object hash value .
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
node-2
[[email protected] ~]# ipfs pin add QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
pinned QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD recursively
[[email protected] ~]# ipfs pin ls
QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi
QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bDStop node2 Of daemon Daemon , perform GC After the operation , Revisit node2 Data objects for , You can see that the data content can still be accessed , And node2 The data of has been added to node1 Data persistence storage .
[[email protected] ~]# ipfs repo gc
removed bafkreibhk7az6hwkh6qbluusf35olnm4shzr7loyasbgbnmrkvi2hsfv5a
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
node-2Delete persistence
ipfs Persistent storage can be deleted ,pin rm After the operation is deleted , You need to perform GC Operation can completely delete , Deleted data can no longer be accessed
[[email protected] ~]# ipfs pin rm QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
unpinned QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
[[email protected] ~]# ipfs pin ls
QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi recursive
[[email protected] ~]# ipfs repo gc
removed bafkreibhk7az6hwkh6qbluusf35olnm4shzr7loyasbgbnmrkvi2hsfv5a
[[email protected] ~]# ipfs cat QmQzEDpiVMsMePtGZYUR2ee8Ve5rTsF771RHyuewmYx9bD
.............................( Can't get , Long wait )Again , Local data objects can also be permanently deleted
[[email protected] ~]# ipfs pin rm QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi
unpinned QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi
[[email protected] ~]# ipfs pin ls
[[email protected] ~]# ipfs repo gc
removed bafkreifwwxnupxybxrlpxchyty5llinjqqolyvatf4rwspytgvjagzketu
[[email protected] ~]# ipfs cat QmadskBmtG5Fwux8mnBPacme9Ebwep6zEfVsaW3T2QEKsi
.............................( Can't get , Long wait )边栏推荐
猜你喜欢

Cento7 installs mysql5.5 and upgrades 5.7

何为“数字藏品”?

手把手带你从零开始完整开发经典游戏【俄罗斯方块】,全部逻辑只用不到200行代码。

深拷贝与浅拷贝

解决scala无法对Native进行类的初始化

06 BTC mining difficulty

NFT-数字藏品之库里为何花116万买一个NFT头像?回顾NFT头像的“发迹史”或许能找到答案

知名啤酒百威布局NFT,试图揭开“蓄谋已久”的上链面纱?

How does the website count the number of visitors? How to install and use 51la?

每日10道面试题打卡——JVM篇
随机推荐
V-cloak and v-bind bind bind classes
数字藏品NFT“无聊猿”BAYC的内忧与外患
The interviewer asked: how to check if redis suddenly slows down?
03_ Two ways of writing el and data
普通异步发送代码编写
Uni app wechat official account (4) - address management page
05 BTC network
10 完成一半题目
Countless times of stepping on the pit to install awvs
01_模板语法
手把手带你从零开始完整开发经典游戏【俄罗斯方块】,全部逻辑只用不到200行代码。
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
What is the QS module?
Router and keep alive
Promise的基本使用
Basic use of promise
Redis 突然变慢了?
Mysql 安装(rpm包方式)
CheckPoint and DataNode
How to use express and how to match and use routes