使用IPFS集群搭建创建私有IPFS网络

基本介绍


IPFS 网络分两类:

  1. 公有
  2. 私有

对于大多数商用应用尤其是企业级解决方案而言,需要对自身数据有完全的控制,这种场合公有IPFS网络并不适用,搭建私有IPFS往往是这类应用的必要需求。

本文我们讲解创建一个私有 IPFS 网络的过程:

创建一个 IPFS集群的私有 IPFS网络用于数据复制。

IPFS 本身不提供节点间数据复制,为了在 IPFS网络中复制数据有两个选择:

  1. Filecoin
  2. IPFS-Cluster。

本文中我们使用 IPFS-Cluster 。

我们通过三个虚拟机器实现私有网络,以下是相关的参考文档:

  1. IPFS: A protocol and network designed to create a content-addressable, peer-to-peer method of storing and sharing hypermedia in a distributed file system. Read more

  2. Private IPFS: 私有网络中的用户(peers)使用同一个共享私钥、此时所有用户只能在私有IPFS网络中通讯, Read more

  3. IPFS-Cluster: 一个 IPFS集群是一个独立的程序和一个 CLI 客户端。通过一组IPFS守护进程负责分配、复制以及跟踪 pins 。 IPFS-Cluster uses a leader-based consensus algorithm Raft to coordinate storage of a pinset, distributing the set of data across the participating nodes.

    • A cluster peer application: ipfs-cluster-service, to be run along with go-ipfs.
    • A client CLI application: ipfs-cluster-ctl, which allows easily interacting with the peer's HTTP API.
    • An additional "follower" peer application: ipfs-cluster-follow, focused on simplifying the process of configuring and running follower peers.

    Read more

需要注意:

  1. IPFS 的核心功能中,私有网络是其默认特征,同时 IPFS-Cluster 是一个独立的应用。
  2. IPFSIPFS-Cluster 程序是作为不同包来安装的、分别以不同进程启动。
  3. IPFSIPFS-Cluster 具有不同的 peer IDs、不同的API endpoints 、使用不同的端口。
  4. IPFS-Cluster 守护进程是依赖于 IPFS 守护进程,启动 IPFS 守护进程后才可以启动 IPFS-Cluster 守护进程。

搭建 IPFS 私有网络


默认 IPFSIPFS-Cluster 使用以下端口:

IPFS 4001 – Communication with other nodes 5001 – API server 8080 – Gateway server

IPFS-CLUSTER 9094 – HTTP API endpoint 9095 – IPFS proxy endpoint 9096 – Cluster swarm, used for communication between cluster nodes

We will use recently created three virtual machines (in my case I used DigitalOcean) with installed Linux Ubuntu Distributive version 16.04 and command line as the main tool for installing necessary packages and settings. Depending on your cloud provider (AWS, Azure, Google, etc.), you may need to look at some additional settings, like firewall or security group configuration, to let your peers see each other.

Let’s suppose that we have three VMs with the following IP addresses: Node0: 192.168.10.1 Node1: 192.168.10.2 Node2: 192.168.10.3

Let’s start with the zero node (Node0) which will be our bootstrap node.

Step 1: 安装 Go

First of all, let’s install Go as we will need it during our deployment process. Update Linux packages and dependencies:

1 sudo apt-get update
2 sudo apt-get -y upgrade

Download the latest version and unzip Go

1 wget https:``//dl.google.com/go/go1.11.4.linux-amd64.tar.gz
2 sudo tar -xvf go1.11.4.linux-amd64.tar.gz
3 sudo mv go /usr local

Create Path for Go and set environment variables. \1. Create folder:

1 mkdir $HOME``/gopath

Open .bashrc file and add to the end three variables GOROOT, GOPATH, PATH. Open file:

1 sudo nano ``$HOME``/.bashrc

Insert to the end of the .bashrc file:

1 export GOROOT=/usr/local/go
2 export GOPATH=``$HOME``/gopath
3 export PATH=``$PATH``:``$GOROOT``/bin:``$GOPATH``/bin

\2. Update .bashrc file and check Go version:

1 source ~/.bashrc
2 go version

Step 2: 安装 IPFS

We will install the latest version of the go-IPFS. At the moment of writing this article, it was v0.4.18 for Linux. You can check for the lat

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

青年夏日科技

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值