by Niharika Singh

由Niharika Singh

边做边学:《 Inter Planetary File System》简介 (Learn by doing: a nice and easy intro to the Inter Planetary File System)

IPFS入门 (Primer on IPFS)

IPFS is short for Inter Planetary File System. It is a peer-to-peer, distributed file system to make the web faster, safer, and more open. To shift from the present version of the web to a distributed version of the web, we need the IPFS. Essentially, the aim is to replace HTTP.

IPFS是“行星际文件系统”的缩写。 它是一个点对点的分布式文件系统,可以使Web更快,更安全,更开放。 为了从网络的当前版本转换为网络的分布式版本,我们需要IPFS。 本质上,目标是替换HTTP。

There are NO centralised servers. Everything is decentralised. Let’s see how this works by doing it.

没有集中式服务器。 一切都是分散的。 让我们看看它是如何工作的。

I wrote an article about how IPFS uses MerkleDAG, which can be found here.

我写了一篇关于IPFS如何使用MerkleDAG的文章,可以在这里找到。

步骤1:安装IPFS (STEP 1: Install IPFS)

IPFS alpha version is written in GoLang. You’ll need to download it for your platform from this link.

IPFS alpha版本用GoLang编写。 您需要从此链接为您的平台下载它。

To check that you’ve successfully installed IPFS, open the command console and enter the following command.

要检查您是否已成功安装IPFS,请打开命令控制台并输入以下命令。

$ ipfs help

If you see something which starts like this:

如果您看到类似这样的内容:

USAGE
ipfs - Global p2p merkle-dag filesystem.
ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ...

Then you’re good to go!

那您就可以出发了!

步骤2:初始化IPFS节点 (Step 2: Initialize IPFS Node)

To initialize your local machine as an IPFS node, run the following command:

要将本地计算机初始化为IPFS节点,请运行以下命令:

$ ipfs init

This command initializes IPFS configuration files and generates a new keypair using 2048 bit-RSA. This will produce your peer identity as an output.

该命令初始化IPFS配置文件,并使用2048位RSA生成新的密钥对。 这将产生您的对等身份作为输出。

You’ll see something like this:

您会看到以下内容:

initializing IPFS node at /Users/niharikasingh/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmTo1oMgGEH6Ym3H1xF55U7q4bexd5288YmEJjubDqVmKn
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

You’ll have a different peer identity than mine.

您将拥有与我不同的对等身份。

Now run the following command to see the hello message:

现在运行以下命令以查看问候消息:

$ ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

You’ll see a result that looks something like this:

您会看到类似以下内容的结果:

Hello and Welcome to IPFS!
██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗  ███████╗
██║██╔═══╝ ██╔══╝  ╚════██║
██║██║     ██║     ███████║
╚═╝╚═╝     ╚═╝     ╚══════╝
If you're seeing this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!
-------------------------------------------------------
| Warning:                                              |
|   This is alpha software. Use at your own discretion! |
|   Much is missing or lacking polish. There are bugs.  |
|   Not yet secure. Read the security notes for more.   |
-------------------------------------------------------
Check out some of the other files in this directory:
./about
./help
./quick-start     <-- usage examples
./readme          <-- this file
./security-notes

Voilà!

瞧!

步骤3:将一些文件添加到IPFS (Step 3: Add some files to IPFS)

Create a demo folder anywhere on your machine and throw in a couple of files. Any type of files: images, videos, music…literally anything. You can even add another folder within this folder.

在计算机上的任何位置创建一个演示文件夹,并放入几个文件。 任何类型的文件:图像,视频,音乐……实际上是任何东西。 您甚至可以在此文件夹中添加另一个文件夹。

Suppose the folder is named “test-ipfs”. So to push these files, first navigate into this folder on your command line and then run the following command:

假设该文件夹名为“ test-ipfs”。 因此,要推送这些文件,请首先在命令行上导航到该文件夹​​,然后运行以下命令:

$ ipfs add -r .

This command adds all files/directories present in the folder to IPFS recursively to create the IPFS MerkleDAG. You can even add a single file by using the following command: $ ipfs add <filename.extension>

此命令将文件夹中存在的所有文件/目录递归添加到IPFS,以创建IPFS MerkleDAG。 您甚至可以使用以下命令添加单个文件: $ ipfs add <filename.extensi on>

This creates the following output:

这将创建以下输出:

added QmSTuTEThyESvDgmYdao2HK6kurXe2pqjA1KHPD8wSHVy7 test-ipfs/donut.jpeg
added QmSR9MJ5resQLjwqy7kEVVKJwTvDG53Npt9i1c6jZeZDtW test-ipfs/purse.jpeg
added QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn test-ipfs/folder1
added QmaKZ3dnc9ejBdGgEDCRtsLFNRxcY67HLjk6gXUnk9sdM9 test-ipfs

You’ll notice this long thing is the unique hash of that particular file. All the files and directories, as well as the parent folder, will have their unique hash.

您会注意到,这件事很长,是该特定文件的唯一哈希。 所有文件和目录以及父文件夹将具有其唯一的哈希。

$ ipfs ls QmaKZ3dnc9ejBdGgEDCRtsLFNRxcY67HLjk6gXUnk9sdM9

This works exactly like the UNIX file system. The expected output will show the following:

这与UNIX文件系统完全一样。 预期的输出将显示以下内容:

QmSTuTEThyESvDgmYdao2HK6kurXe2pqjA1KHPD8wSHVy7 219859 donut.jpeg
QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn 4      folder1/
QmSR9MJ5resQLjwqy7kEVVKJwTvDG53Npt9i1c6jZeZDtW 110254 purse.jpeg

The file size is shown at the end of the hash string. For example, 219859 is the file size of donut.jpeg.

文件大小显示在哈希字符串的末尾。 例如,219859是donut.jpeg的文件大小。

步骤4:在线访问文件 (Step 4: Access files online)

To access files online, first we’ve got to connect our node to the IPFS network. To do that, we’ve got to run the IPFS daemon.

要在线访问文件,首先我们必须将节点连接到IPFS网络。 为此,我们必须运行IPFS守护程序。

$ ipfs daemon

This will produce the following output:

这将产生以下输出:

Initializing daemon...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/169.254.100.132/tcp/4001
Swarm listening on /ip4/192.168.1.3/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmTo1oMgGEH6Ym3H1xF55U7q4bexd5288YmEJjubDqVmKn
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/169.254.100.132/tcp/4001
Swarm announcing /ip4/192.168.1.3/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

Now that you’ve pushed the files to IPFS, let’s see how can you access them.

现在您已将文件推送到IPFS,让我们看看如何访问它们。

localhost:8080/ipfs/hashOfTheFileYouWantToOpen

Suppose I wish to open purse.jpeg. I’ll copy the hash of purse.jpeg and hit the browser with the above syntax.

假设我要打开purse.jpeg。 我将复制purse.jpeg的哈希,并使用上述语法访问浏览器。

Likewise, you can even hear your music, video, and so on.

同样,您甚至可以听到您的音乐,视频等。

You can even access your content using the IPFS gateway:

您甚至可以使用IPFS网关访问内容:

gateway.ipfs.io/ipfs/hashOfTheFile

You’re about to see real magic now!

您现在将要看到真正的魔术!

Point your browser to:

将浏览器指向:

127.0.0.1:5001/webui

You’ll see this screen:

您会看到以下屏幕:

Feel free to play around.

随意玩。

Connections: Will show you your peers all over the world.

人脉关系:将向您展示世界各地的同行。

Files: You can push files using the webUI.

文件:您可以使用webUI推送文件。

DAG: Will show you the MerkleDAG and show related info about the file when its hash is entered.

DAG:将显示MerkleDAG,并在输入其哈希值时显示有关文件的相关信息。

Config: This will show you configurations about your own machine.

配置:这将显示有关您自己计算机的配置。

步骤5:从您的同伴访问文件 (Step 5: Access files from your peers)

IPFS promises that there is no central server that is giving you the files. So what if I tell you that you can stream video from my laptop also even if IPFS daemon isn’t running on my computer?

IPFS保证没有中央服务器为您提供文件。 那么,如果我告诉你即使我的计算机上没有运行IPFS守护程序,也可以从笔记本电脑中传输视频怎么办?

I’ve uploaded Katy Perry’s Roar video online. You can access it from me rather than hitting YouTube.

我已经在线上传了凯蒂·佩里的咆哮视频。 您可以从我这里访问它,而无需访问YouTube。

Go to:

去:

localhost:8080/ipfs/QmWPCbXCK4NGXKac1QoKHdW7Qqud481T5FLHzu7RnSRDGR/

And enjoy!

享受吧!

You’ll be streaming this video on IPFS.

您将在IPFS上流播此视频。

You can even use VLC Media Player for this.

您甚至可以为此使用VLC Media Player。

URL used:

使用的网址:

http://localhost:8080/ipfs/QmWPCbXCK4NGXKac1QoKHdW7Qqud481T5FLHzu7RnSRDGR/Katy%20Perry%20-%20Roar%20%28Official%29.mp4

Feel free to play around with IPFS. This was a very brief overview. But I hope you got a basic idea about what IPFS is!

随时使用IPFS。 这是一个非常简短的概述。 但我希望您对IPFS是个基本概念!

翻译自: https://www.freecodecamp.org/news/ipfs-101-understand-by-doing-it-9f5622c4d4ed/

边做边学:《 Inter Planetary File System》简介相关推荐

  1. Hadoop Distributed File System 简介

    HDFS 是一个 Apache Software Foundation 项目,是 Apache Hadoop 项目的一个子项目(参见 参考资料).Hadoop 非常适于存储大型数据(比如 teraby ...

  2. Linux操作系统报:read-only file system

    在对集群测试过程中发现系统中某一节点中的磁盘变成read-only file system,从而导致测试任务出错,从网上查找资料,找到以下解决方案: 这个报错的意思是硬盘属性变成只读,不可写入: VO ...

  3. 转:经典论文翻译导读之《Google File System》

    首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 Java小组 工具资源 - 导航条 -首页所有文章资讯Web架构基础技术书籍教程Java小组工具资源 经典论文翻译导读之<Google ...

  4. 【转】The Google File System 中文版

    原文链接 http://www.cnblogs.com/lijunjie/archive/2011/03/08/1976660.html#top 摘要 我们设计并实现了Google GFS文件系统,一 ...

  5. GFS架构启示 | Google File System

    第一篇,GFS(Google File System)架构启示. GFS是什么? Google早期研发的分布式文件系统. 画外音:与分布式文件系统对应的,是单机文件系统,Windows和Linux操作 ...

  6. NFS服务器是什么?(Network File System 网络文件系统)(远程主机间 mount 挂载目录)(ubuntu:nfs-kernel-server)

    NFS 是 Network File System的简写.NFS 是由Sun公司发展, 并於1984年推出, NFS是一个RPC service ,它使我们能够达到档案的共享, 它的设计是为了在不同的 ...

  7. GFS - The Google File System

    The Google File System http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.125.789&rep=rep1 ...

  8. 日常问题——Mac下新建目录报Read-only file system

    问题描述: 今天在根目录下,新建目录时出现了Read-only file system提示为只读的错误.电脑最近并没有非正常关机之类可能导致文件损伤的操作,但是最近倒是进行了一次系统更新. 解决方案( ...

  9. The Google File System

    摘要 我们设计并实现了Google GFS文件系统,一个面向大规模数据密集型应用的.可伸缩的分布式文件系统.GFS虽然运行在廉价的普遍硬件设备上,但是它依然了提供灾难冗余的能力,为大量客户机提供了高性 ...

最新文章

  1. Mysql主从同步延迟问题及解决方案
  2. 【业界】开源大势降低技术门槛,人工智能企业更依赖大数据
  3. WatchDog工作原理
  4. 前端学习(2346):使用脚手架工具
  5. php类中双冒号和-的区别
  6. php http/1.1 403 forbidden in,http常用方法有哪些
  7. 国庆,用Python 带你在家来一次环球旅行打卡!
  8. matlab三角函数默认角度还是弧度,matlab 解三角函数方程弧度与角度问题
  9. Google map根据经纬度获取地址信息
  10. 怎样设置电脑桌面共享计算机,局域网共享设置,小编教你电脑怎么设置局域网共享...
  11. 换一种视角看《百度SEM竞价推广》
  12. 如何通过SEO思维收割各大平台的流量?
  13. WOFF2与icon字体化
  14. 基于FTP协议实现FTP客户端和服务端程序
  15. 举头望明月打计算机术语,关于月亮的谜语
  16. win11重启键在哪 windows11关机重启的设置方法
  17. python爬虫中文不能正常显示问题的解决
  18. C语言面试题--已知整形变量在内存中占4个字节的空间,现有一无符号整形变量a = 0x20190125,请编写函数求出变量a所占内存每个字节的值是多少?
  19. 用友NC 财务核算账簿启用时 提示选中的科目表不是当前集团的账簿类型对应科目体系下的政策性科目表或其派生的科目表
  20. 利用MATLAB绘制厄尔尼诺-南方涛动指数(SOI)近20年的变化曲线

热门文章

  1. 教资科目一要背的内容 0303
  2. 默写标准答案0917
  3. 爬虫时安装的newspaper 新闻包
  4. Symfony 框架实战教程——第一天:创建项目(转)
  5. PHP依赖注入(DI)和控制反转(IoC)详解
  6. XML与HTML的作用不同
  7. Linux运维常见问题解决集锦【转】
  8. 朝鲜不小心泄漏了它的.kp域名DNS数据
  9. 导致Oracle性能抖动的参数提醒
  10. linux设备驱动之USB主机控制器驱动分析 【转】