IPFS初探
背景:听说IPFS=bittorrent+bitcoin+git+afs,有可能取代http,好像厉害的不行,所以要研究一下。
编译参考:https://github.com/ipfs/go-ipfs 结果各种墙都翻好了,一切基础设施都到位了,还是没编译成功shit(最后还是编过了)。
退而求其次,直接用官方提供的先试验一下吧。
下载地址:https://ipfs.io/docs/install/

1.上传安装
下载相应的版本,我下载的是:go-ipfs_v0.4.14_linux-amd64.tar.gz,上传到服务器,解压。
someone@ipfs:~$ tar -zxvf go-ipfs_v0.4.14_linux-amd64.tar.gz
someone@ipfs:~$ cd go-ipfs/
someone@ipfs:~$ ./install.sh
someone@ipfs:~/package/go-ipfs$ ipfs
显示的结果如下:
USAGE
ipfs - Global p2p merkle-dag filesystem. ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ... SUBCOMMANDS
BASIC COMMANDS
init Initialize ipfs local configuration
add <path> Add a file to IPFS
cat <ref> Show IPFS object data
get <ref> Download IPFS objects
ls <ref> List links from an object
refs <ref> List hashes of links from an object DATA STRUCTURE COMMANDS
block Interact with raw blocks in the datastore
object Interact with raw dag nodes
files Interact with objects as if they were a unix filesystem
dag Interact with IPLD documents (experimental) ADVANCED COMMANDS
daemon Start a long-running daemon process
mount Mount an IPFS read-only mountpoint
resolve Resolve any type of name
name Publish and resolve IPNS names
key Create and list IPNS name keypairs
dns Resolve DNS links
pin Pin objects to local storage
repo Manipulate the IPFS repository
stats Various operational stats
p2p Libp2p stream mounting
filestore Manage the filestore (experimental) NETWORK COMMANDS
id Show info about IPFS peers
bootstrap Add or remove bootstrap peers
swarm Manage connections to the p2p network
dht Query the DHT for values or peers
ping Measure the latency of a connection
diag Print diagnostics TOOL COMMANDS
config Manage configuration
version Show ipfs version information
update Download and apply go-ipfs updates
commands List all available commands Use 'ipfs <command> --help' to learn more about each command. ipfs uses a repository in the local file system. By default, the repo is
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
environment variable: export IPFS_PATH=/path/to/ipfsrepo EXIT STATUS The CLI will exit with one of the following values: Successful execution.
Failed executions.
2. 初始化
someone@ipfs:~$ mkdir -p /ipfs/ /*很明显,根本不用执行这个命令,下面的/ipfs也不是指本地文件系统的/ipfs.*/
someone@ipfs:~$ ipfs init
initializing IPFS node at /home/someone/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmSuUJKAfxYamzekBT2ePfyypyTXP3DgEsGKPxiedUneGh
to get started, enter: ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme someone@ipfs:~/.ipfs$ ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
显示结果如下:
#这条命令只是查看行不行,其实没有别的作用
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
至此,所有的ipfs的内容都在 ~/.ipfs目录下了
someone@ipfs:~/.ipfs$ ls
api blocks config datastore datastore_spec keystore repo.lock version
3. 修改配置文件
可以使用如下命令
someone@ipfs:export EDITOR=/usr/bin/vim
someone@ipfs:ipfs config edit
查看节点ID
someone@ipfs:~$ ipfs id
{
"ID": "QmSuUJKAfxYamzekBT2ePfyypyTXP3DgEsGKPxiedUneGh",
"PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBTEUgY8FCDbZeV8+h1XdRivlUVRlVlNmwr0oFP1ceoBnbMXP5IJ9GSXXLVVwl4IPwFBEscMo1wo6NRz3oMDeQWEgi9x5wuEOYvlNUAzVbwFWb77AmW10oZpGz7oo45Fd37/jdU+6JcDKPc4o5sR9pJo8PddP3g7rphF7nHncf3vh4vNeCsu0DylxPh6CGHf6+8c50Vjl9iAwBZ9zES+QYT4kYHF3icX63p2B8B5C+7ZC9ISfD4ZiKTYBHDob/XLQc7g7gdEbGuxmXJE/iFzju2PoEe+Ob1QXCAabWq80F/oxCAdX+wLisgHE6FbeYp5RV7IRi7s3L3xpFnQPukswtAgMBAAE=",
"Addresses": null,
"AgentVersion": "go-ipfs/0.4.14/",
"ProtocolVersion": "ipfs/0.1.0"
}
跨域资源共享CORS配置
someone@ipfs:~$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
someone@ipfs:~$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
4. 启动服务器
someone@ipfs:~/.ipfs$ ipfs daemon
Initializing daemon...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.15.129/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmSuUJKAfxYamzekBT2ePfyypyTXP3DgEsGKPxiedUneGh
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.15.129/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
启动成功后就可以,查看UI界面了:
http://127.0.0.1:5001/webui
结果如下:

5. 编译失败后调试成功
按步骤编译,墙也是翻好的,每次都卡在类似的地方:
someone@ipfs:~$ make install
....
[get ] [fetch] go-libp2p-crypto QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo
[0 / 202] 392sERROR: [2 / 101 ] parallel fetch: failed to fetch package: QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8: Post https://ipfs.io/api/v0/get?arg=QmRb5jh8z2E8hMGN2txxxx1yHynUanqnZ3UeKwgN1i9P1F8&encoding=json&stream-channels=true: dial tcp 173.252.100.32:443: getsockopt: connection timed out
[0 / 202] 442s^Cmk/gx.mk:4: recipe for target 'gx-deps' failed
https再开一个终端,wget都可以访问。使用"make install_unsupported"也没卵用,然后再次"make install"还是不行。
结果,第二天,安装完官方的ipfs并启动后,再make install 源码,结果,编译通过了,难道这个编译是看天气的吗?
猜测编译可能和以下操作有关:
apt-get install libzip-dev
参考网址:
https://www.oschina.net/p/ipfs
https://raw.githubusercontent.com/ipfs/ipfs/master/papers/ipfs-cap2pfs/ipfs-p2p-file-system.pdf
IPFS初探的更多相关文章
- 初探领域驱动设计(2)Repository在DDD中的应用
概述 上一篇我们算是粗略的介绍了一下DDD,我们提到了实体.值类型和领域服务,也稍微讲到了DDD中的分层结构.但这只能算是一个很简单的介绍,并且我们在上篇的末尾还留下了一些问题,其中大家讨论比较多的, ...
- CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探
CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码 ...
- 从273二手车的M站点初探js模块化编程
前言 这几天在看273M站点时被他们的页面交互方式所吸引,他们的首页是采用三次加载+分页的方式.也就说分为大分页和小分页两种交互.大分页就是通过分页按钮来操作,小分页是通过下拉(向下滑动)时异步加载数 ...
- JavaScript学习(一) —— 环境搭建与JavaScript初探
1.开发环境搭建 本系列教程的开发工具,我们采用HBuilder. 可以去网上下载最新的版本,然后解压一下就能直接用了.学习JavaScript,环境搭建是非常简单的,或者说,只要你有一个浏览器,一个 ...
- .NET文件并发与RabbitMQ(初探RabbitMQ)
本文版权归博客园和作者吴双本人共同所有.欢迎转载,转载和爬虫请注明原文地址:http://www.cnblogs.com/tdws/p/5860668.html 想必MQ这两个字母对于各位前辈们和老司 ...
- React Native初探
前言 很久之前就想研究React Native了,但是一直没有落地的机会,我一直认为一个技术要有落地的场景才有研究的意义,刚好最近迎来了新的APP,在可控的范围内,我们可以在上面做任何想做的事情. P ...
- 【手把手教你全文检索】Apache Lucene初探
PS: 苦学一周全文检索,由原来的搜索小白,到初次涉猎,感觉每门技术都博大精深,其中精髓亦是不可一日而语.那小博猪就简单介绍一下这一周的学习历程,仅供各位程序猿们参考,这其中不涉及任何私密话题,因此也 ...
- Key/Value之王Memcached初探:三、Memcached解决Session的分布式存储场景的应用
一.高可用的Session服务器场景简介 1.1 应用服务器的无状态特性 应用层服务器(这里一般指Web服务器)处理网站应用的业务逻辑,应用的一个最显著的特点是:应用的无状态性. PS:提到无状态特性 ...
- NoSQL初探之人人都爱Redis:(3)使用Redis作为消息队列服务场景应用案例
一.消息队列场景简介 “消息”是在两台计算机间传送的数据单位.消息可以非常简单,例如只包含文本字符串:也可以更复杂,可能包含嵌入对象.消息被发送到队列中,“消息队列”是在消息的传输过程中保存消息的容器 ...
随机推荐
- GIT仓库如何恢复到前一次提交
GIT仓库如何恢复到前一次提交 通过使用Git版本恢复命令reset,可以回退版本.reset命令有3种方式: git reset –mixed:此为默认方式,不带任何参数的git reset,即 ...
- python之以字符串形式导入模块
示例 调用方法 class CorsMiddleware: def process(self): print('from auth.cors.CorsMiddleware.process') cors ...
- spring datasource 使用 proxool
XmlWebApplicationContext使用的xml配置如下: <?xml version="1.0" encoding="UTF-8"?> ...
- PowerBI更新 - 解决方案架构 - PowerBI Solution Architecture(一图胜万字!)
2019/04更新 参见这里 今天发福利啦!发福利啦!发福利啦! 企业的各种数据整合到PowerBI显示,浏览器,移动端显示关键指标. 一个很好的PowerBI解决方案的图!一图胜万字!你所需要知道的 ...
- shiro学习总结
首先4个比较好的例子供参考: 1.常规Spring MVC拦截器实现的认证和权限管理例子 https://blog.csdn.net/u013647382/article/details/539956 ...
- 微信小程序组件封装
第一步,在page下面新建一个template文件,如下图 第二部,在template.wxml中编写公用组件即要封装的代码模块 <!--pages/template/template.wxml ...
- JaCoCo在Tomcat服务器上监控代码覆盖率的使用方法
简介 Jacoco是一个开源的覆盖率工具.Jacoco可以嵌入到Ant .Maven中,并提供了EclEmma Eclipse插件,也可以使用JavaAgent技术监控Java程序.很多第三方的工具提 ...
- Select input 两个元素的宽度高度跟设定值不一致的问题
在做登录框的时候,需要一个select 元素作为账号输入,一个input作为密码输入框.在css 文件中,将这两个元素的position 设置为relative ,并且width 设置为100%.刷新 ...
- 《CSS世界》读书笔记(八)
<!-- <CSS世界>张鑫旭著 --> 替换元素和非替换元素的距离有多远? 观点1:替换元素和非替换元素之间只隔了一个src属性! 在Firefox浏览器下,没有src属性的 ...
- 剑指offer(36)两个链表中的第一个公共节点
题目描述 输入两个链表,找出它们的第一个公共结点. 题目分析 我发现关于链表的题都涉及双指针,大家做的时候记得用双指针. 题目理解了就很好做了,比较简单,先在长的链表上跑,知道长的和短的一样长,再一起 ...