搭建私有ipfs网络

搭建私有ipfs网络

生成key,只有key相同的ipfs节点才能连接上
删除种子节点,这样就不回连上其他节点了
添加自己的节点,这样自己的节点就可以形成一个ipfs网了

//到github上面下载秘钥生成工具go-ipfs-swarm-key-gen
//克隆代码
$git clone https://github.com/Kubuxu/go-ipfs-swarm-key-gen.git
//编译代码, 不用进入目录$go build -o ipfs-swarm-key-gen go-ipfs-swarm-key-gen/ipfs-swarm-key-gen/main.go//会生成一个ipfs-swarm-key-gen文件
//生成key
$./ipfs-swarm-key-gen > swarm.key
//将swarm.key 移动到ipfs存放数据的根目录下$cp swarm.key ~/.ipfs/
//查看种子节点
//ipfs bootstrap
//移除所有的种子节点
$ ipfs bootstrap rm all
//查看自己节点的id
$ipfs id{
 "ID": "QmbUTCWxFZn3RwBaoux1uuL3dM3VzmZzUKcoHcWpAzpj2y",
 "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAiBDJuyMAb72Gh+y/8oMDItWtB2QcgYQYRC6qqJncS7xqf0wjHSny+nnJlUx/YIyIqbB+K69M9kMqLuF8lv8OcE45KU1pP6PHDoFdEac2Icv0S76HG2Pxyh5z/SmNn+M0g88Cpl6taJH83iHO80+t+XirJBoNSL6A92A/Lf3zsu+YT2k6BZ6m+2vXwXVmzoqid1nFqtu1htOvCQUR4O2N1YccBfw8o6MmLS91mzqYb1MASPBMib+UVmnwQY74tKeCvsL0r4f1H1I0bF61IkrCxIUHUj5m5nvSscH1t89JFQz4hUR/FdCIi/FpJCv14h+T45LCNDFD8hWZEfHtIzErAgMBAAE=",
 "Addresses": [
 "/ip4/127.0.0.1/tcp/4001/ipfs/QmbUTCWxFZn3RwBaoux1uuL3dM3VzmZzUKcoHcWpAzpj2y", "/ip4/192.168.0.131/tcp/4001/ipfs/QmbUTCWxFZn3RwBaoux1uuL3dM3VzmZzUKcoHcWpAzpj2y", "/ip6/::1/tcp/4001/ipfs/QmbUTCWxFZn3RwBaoux1uuL3dM3VzmZzUKcoHcWpAzpj2y" ], "AgentVersion": "go-ipfs/0.4.22/",
 "ProtocolVersion": "ipfs/0.1.0"
}
//添加种子节点
$ipfs bootstrap add /ip4/被添加节点的ip地址/tcp/4001/ipfs/被添加节点的ID值
//重新启动ipfs

你可能感兴趣的:(区块链)