搭建IPFS私有网络

一、安装IPFS
[root@myhost ~]# tar xzvf go-ipfs_v0.4.15_linux-amd64.tar.gz
go-ipfs/build-log
go-ipfs/install.sh
go-ipfs/ipfs
go-ipfs/LICENSE
go-ipfs/README.md
[root@myhost ~]# cp go-ipfs/ipfs /usr/bin/
安装包下载地址:https://dist.ipfs.io/#go-ipfs

二、初始化IPFS
[root@myhost ~]# ipfs init
initializing IPFS node at /root/.ipfs
generating 2048-bit RSA keypair…done
peer identity: QmTks2mpdcTJnaLLtjGkyqPWxuMy6WvZbDzkG6XTGRfYA3
to get started, enter:

ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

三、生成共享key
安装go语言环境:安装教程
#编译工具
go get github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
cd $GOPATH
cd src/github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen/
go build
#生成key
./ipfs-swarm-key-gen > /root/.ipfs/swarm.key

#将63上生成的key拷贝到64的相同目录下
scp /root/.ipfs/swarm.key root@192.168.1.64:/root/.ipfs

go语言安装包下载:https://golang.org/dl/

四、主、副节点移除默认boostrap节点
[root@myhost ~]# ipfs bootstrap rm --all
removed /dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
removed /dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa
removed /dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
removed /dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
removed /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
removed /ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
removed /ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
removed /ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
removed /ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
removed /ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
removed /ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
removed /ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
removed /ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd

五、主节点启动服务
[root@myhost ~]# ipfs daemon &
Initializing daemon…
Successfully raised file descriptor limit to 2048.
Swarm is limited to private network of peers with the swarm key
Swarm key fingerprint: 05196cc65b4e7633521d7357186a2951
Swarm listening on /ip4/10.0.3.15/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.63/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmTks2mpdcTJnaLLtjGkyqPWxuMy6WvZbDzkG6XTGRfYA3
Swarm announcing /ip4/10.0.3.15/tcp/4001
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.63/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

六、副节点添加boostrap信息
root@ubuntu:~# ipfs bootstrap add /ip4/192.168.1.63/tcp/4001/ipfs/QmTks2mpdcTJnaLLtjGkyqPWxuMy6WvZbDzkG6XTGRfYA3
added /ip4/192.168.1.63/tcp/4001/ipfs/QmTks2mpdcTJnaLLtjGkyqPWxuMy6WvZbDzkG6XTGRfYA3
root@ubuntu:~#

七、副节点启动服务
root@ubuntu:~# ipfs daemon &
Initializing daemon…
Successfully raised file descriptor limit to 2048.
Swarm is limited to private network of peers with the swarm key
Swarm key fingerprint: 05196cc65b4e7633521d7357186a2951
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.64/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmcgkHih714sZAbda3LDp7TF6A6oTXTuTe3QboSjkg3dNA
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.64/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

https://blog.csdn.net/chenmo187J3X1/article/details/80988140

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值