私链搭建
生成私链的Swarm密钥
下载并编译工具
go get -u github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
生成Swarm密钥
./ipfs-swarm-key-gen > swarm.key
在全部三个节点运行以下内容
#下载文件https://dist.ipfs.io/#go-ipfs
#解压并安装
tar -zxf go-ipfs_v0.4.14_linux-amd64.tar.gz
cd go-ipfs/
sudo ./install.sh
#初始化节点
ipfs init
initializing IPFS node at /home/hiup/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmUYmog2D8gt7WCGUg76MZKESGSyZdSwwDPYaUaFEtjppJ
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
#部署swarm.key
cp swarm.key ~/.ipfs
#移除默认bootstrap节点
ipfs bootstrap rm --all
/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa
/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
在节点2、3将节点1添加为bootstrap节点
ipfs bootstrap add /ip4/172.16.172.81/tcp/4001/ipfs/QmUYmog2D8gt7WCGUg76MZKESGSyZdSwwDPYaUaFEtjppJ
开启三个节点
ipfs deamon &
在节点2上传文件
ipfs add heart.png
added QmWnt2azBmxL3Q6bZ9YpbnwHkreYbRoDzoRCKgX8HmFN6x heart.png
在节点3下载文件
ipfs get /ipfs/QmWnt2azBmxL3Q6bZ9YpbnwHkreYbRoDzoRCKgX8HmFN6x
最后更新于