【IPFS】IPFS部署分布式项目到开发机的基础实践
2017-08-14 23:37
381 查看
什么是IPFS
IPFS 是一个点对点的分布式文件系统,它希望将所有的计算设备都连接到同一个文件系统中。IPFS能做到去中心化的分布式部署
IPFS旨在替代HTTP和为我们所有人建立更好的网络。
安装
以下地址进行下载https://dist.ipfs.io/go-ipfs/v0.4.10/go-ipfs_v0.4.10_darwin-amd64.tar.gz
wget https://dist.ipfs.io/go-ipfs/v0.4.10/go-ipfs_v0.4.10_darwin-amd64.tar.gz
tar xvfz go-ipfs_v0.4.10_darwin-amd64.tar.gz
mv go-ipfs/ipfs /usr/local/bin/ipfs
GO环境
https://storage.googleapis.com/golang/go1.8.3.darwin-amd64.pkg
go version
go version go1.8.3 darwin/amd64
实践
初始化ipfs init initializing IPFS node at /Users/xiaoyu/.ipfs generating 2048-bit RSA keypair...done peer identity: QmSTt7gDRf5RhWDQRAp516d9hDf5ZTeyi5mcjqnL61n9ok to get started, enter: ipfs cat /ipfs/QmVLDAhCY3X9P2uRudKAryuQFPM5zqA3Yij1dY8FpGbL7T/readme ipfs cat /ipfs/QmVLDAhCY3X9P2uRudKAryuQFPM5zqA3Yij1dY8FpGbL7T/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
也就是这个文档,我们可以访问下面的文件进行访问
./about
./help
./quick-start
./readme
./security-notes
quick-start
ipfs cat /ipfs/QmVLDAhCY3X9P2uRudKAryuQFPM5zqA3Yij1dY8FpGbL7T/quick-start
# 0.1 - Quick Start //快速开始 This is a set of short examples with minimal explanation. It is meant as a "quick start". Soon, we'll write a longer tour :-) Add a file to ipfs://添加文件 echo "hello world" >hello ipfs add hello View it: //查看文件 ipfs cat <the-hash-you-got-here> Try a directory: //添加文件夹 mkdir foo mkdir foo/bar echo "baz" > foo/baz echo "baz" > foo/bar/baz ipfs add -r foo View things: //列出查看文件和文件夹 ipfs ls <the-hash-here> ipfs ls <the-hash-here>/bar ipfs cat <the-hash-here>/baz ipfs cat <the-hash-here>/bar/baz ipfs cat <the-hash-here>/bar ipfs ls <the-hash-here>/baz References: //重定向 ipfs refs <the-hash-here> ipfs refs -r <the-hash-here> ipfs refs --help Get://对比文件 ipfs get <the-hash-here> -o foo2 diff foo foo2 Objects://列出对象 ipfs object get <the-hash-here> ipfs object get <the-hash-here>/foo2 ipfs object --help Pin + GC: ipfs pin add <the-hash-here> ipfs repo gc ipfs ls <the-hash-here> ipfs pin rm <the-hash-here> ipfs repo gc Daemon: ipfs daemon (in another terminal) ipfs id Network: (must be online) ipfs swarm peers ipfs id ipfs cat <hash-of-remote-object> Mount: (warning: fuse is finicky!) ipfs mount cd /ipfs/<the-hash-here> ls Tool: //工具 ipfs version ipfs update ipfs commands ipfs config --help open http://localhost:5001/webui Browse: webui: http://localhost:5001/webui video: http://localhost:8080/ipfs/QmVc6zuAneKJzicnJpfrqCH9gSy6bz54JhcypfJYhGUFQu/play#/ipfs/QmTKZgRNwDNZwHtJSjCp6r5FYefzpULfy37JvMt9DwvXse images: http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs markdown renderer app: http://localhost:8080/ipfs/QmX7M9CiYXjVeFnkfVGf3y5ixTZ2ACeSGyL1vBJY1HvQPp/mdown[/code]尝试运行
ipfs daemon Initializing daemon... Adjusting current ulimit to 2048... Successfully raised file descriptor limit to 2048. Swarm listening on /ip4/127.0.0.1/tcp/4001 Swarm listening on /ip4/192.168.0.106/tcp/4001 Swarm listening on /ip4/192.168.1.5/tcp/50092 Swarm listening on /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
注意此时终端的命令没有结束,也就是说目前的启动是不能关闭终端的
此时访问之前的图片网址http://localhost:8080/ipfs/QmZpc3HvfjEXvLWGQPWbHk3AjD5j8NEN4gmFN8Jmrd5g83/cs,展示效果如下,文件访问成功。
同理,访问视频文件和markdown文件也能正常访问。
在demo中给的webui实际上是一个管理后台,可以查看这个项目被放到了全球多少个节点上。出现的报错
ERROR core/serve: ipfs resolve -r /ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ/locale/webui-zh.json: no link named "webui-zh.json" under Qmc6bAsXTFFdvV3RoLuf6jjV3jzsRLntfsivWQZ75s8QaL gateway_handler.go:584ERROR flatfs: too many open files, retrying in 100ms flatfs.go:180ERROR mdns: mdns lookup error: failed to bind to any unicast udp port mdns.go:135总结
了解了IPFS的安装
本机成功启动了demo
遇到了一些小问题参考资料
https://ipfs.io/
相关文章推荐
- 【G】开源的分布式部署解决方案(二) - 好项目是从烂项目基础上重构出来的
- 【云星数据---Apache Flink实战系列(精品版)】:Apache Flink实战基础006--flink分布式部署001
- 手把手教你实践Service Mesh微服务架构 - 基础部署部分
- 《分布式java运用:基础与实践》笔记2
- ubuntu配置jdk和tomcat+部署java项目[最佳实践]
- 零基础在Linux服务器上部署javaweb项目
- Maven多模块,Dubbo分布式服务框架,SpringMVC,前后端分离项目,基础搭建,搭建过程出
- 用Ant实现Java项目的自动构建和部署入门基础
- 从写项目到部署linux服务器全过程-linux固定IP配置篇
- NET5实践:项目创建-结构概述-程序运行-发布部署
- IPFS + 区块链 系列】 入门篇 - IPFS + Ethereum (中篇)-js-ipfs-api - 图片上传到IPFS以及下载
- 微信公众号基础05_公众号项目部署
- Jenkins使用FTP进行一键部署及回滚2(Windows)(项目实践)
- Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)
- java访问修饰符详解——学java,零基础不怕,不只要理论,更要实践+项目,<a href=...
- 成功部署SOA项目的八个最佳实践
- 第八周上机实践项目1-实现复数类中的运算符重载(可与double型运算的“基础工程”)
- 信息化基础建设系列文章汇总 .NET 平台业务项目实践
- [课本划重点]分布式java应用基础和实践-第四章 分布式java应用与sun jdk类库(1)