当前位置:网站首页>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 )边栏推荐
- Uni app wechat official account (4) - address management page
- Uni app wechat official account (5) - add and modify addresses
- ethereum rpc
- 7 矩阵中战斗力最弱的 K 行
- How to use express and how to match and use routes
- 2022.7.7 summary of some errors
- axs火爆,还有哪些打金游戏(上)
- 紅日安全靶場3
- 走好数据中台最后一公里,为什么说数据服务API是数据中台的标配?
- NFT单月万倍神话,元宇宙之门的奥秘是什么?
猜你喜欢
随机推荐
JS高阶函数 filter/map/reduce
Array Operations - judgment, de duplication, consolidation, expansion
03 BTC agreement
Ansible
Classification and use of express Middleware
Today's code farmer girl did exercises on breathing lights, controlled components and high-level components
Database programming (MySQL) of node, adding, deleting, modifying and querying
03-BTC-协议
[ahu2021 school competition] EZ injection
何为“数字藏品”?
2022.7.7 summary of some errors
12 至少是其他数字两倍的最大数
El form special character verification
4 搜索插入位置
Router and keep alive
Redis+Caffeine两级缓存,让访问速度纵享丝滑
Punch in 10 interview questions every day - JVM article
Computed and watch, watcheffect
promise
Timestamp conversion time








