centos安装部署IPFS

centos安装部署IPFS

下载IPFS

  • 官网(https://dist.ipfs.io/#go-ipfs) 下载Linux版本的ipfs(需要科学上网)
  • 使用wget下载
wget https://github.com/ipfs/go-ipfs/releases/download/v0.4.23/go-ipfs_v0.4.23_linux-amd64.tar.gz

在这里插入图片描述

解压文件

tar zxvf go-ipfs_v0.12.0_linux-amd64.tar.gz

在这里插入图片描述

进入主目录并进行安装

cd go-ipfs/
./install.sh

在这里插入图片描述
在这里插入图片描述

查看IPFS版本

ipfs version

在这里插入图片描述

初始化ipfs账户

ipfs init

在这里插入图片描述

查看配置文件

ipfs config show

在这里插入图片描述

修改配置文件

ipfs config edit

// 可能会出现下面的错误
// Error: ENV variable $EDITOR not set

// 为ipfs选择编辑器
export EDITOR=vi
ipfs config edit

在这里插入图片描述

新建文件并上传至本地ipfs中

vim test.txt
cat test.txt

// 上传文件
ipfs add test.txt

// 查看上传后的文件
ipfs cat QmSoASxb8aNVGk3pNWpZvXEZTQKxjGeu9bvpYHuo5bP1VJ

在这里插入图片描述

启动ipfs,并打开web页面

ipfs daemon

在这里插入图片描述

输入地址http://192.168.1.105:8088/ipfs/QmSoASxb8aNVGk3pNWpZvXEZTQKxjGeu9bvpYHuo5bP1VJ可查看刚才上传的文件
在这里插入图片描述

输入网址http://192.168.1.105:5001/webui进入可视化页面

在这里插入图片描述
在这里插入图片描述

java连接ipfs

导入与ipfs相关的依赖(https://download.csdn.net/download/qq_43707926/84228860)

// 实例化节点
private static IPFS ipfs = new IPFS("/ip4/192.168.1.105/tcp/5001");

// 添加文件
public static void add() throws IOException {
    
    
    NamedStreamable.FileWrapper saveFile = new NamedStreamable.FileWrapper(new File("D:\\abc.jpg"));
    MerkleNode result = ipfs.add(saveFile).get(0);
    System.out.println(result.hash.toString());
}

猜你喜欢

转载自blog.csdn.net/qq_43707926/article/details/123554936