您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页IPFS安装编译

IPFS安装编译

来源:二三娱乐

安装

参考:

如果没有Go环境,首先需要安装Go环境:

brew install go

配置Go环境变量:
执行sudo vi /etc/profile加入

#go config
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin

执行wq!强制保存退出。

下载并编译IPFS

go get -u -d 

cd 
make install

❌出现error

ERROR: from shell.Get(): Post https://ipfs.io/api/v0/get?arg=QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo&encoding=json&stream-channels=true: dial tcp 173.252.102.16:443: getsockopt: operation timed out

预编译安装包安装IPFS

上述这个问题暂时还没解决,gx依赖以及中国网关的问题。那么通过👇安装包的方式来安装运行IPFS:

  1. 使用tar xvfz go-ipfs_v0.4.14_darwin-amd64.tar.gz解压安装包。

  2. 运行项目,通过ipfs init在本地计算机建立一个IPFS节点。

  3. 测试一下,使用ipfs id查看节点id。

    {
    "ID": "QmZXXApnUUTD75bph88eNii3Sc97fiumTX7AMBv5CKHGdf",
    "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCmeja+Xls57HMzJdpyk2uutamqNf0zwKUIde6AmK/qtneFSszEr7fwPZ6lE2KUxlaIdDelBpYLWKgwnJA89vWVDcFElXbgmLEwjlWeAnjR3EWLSQcmVGifB7jKrSG0VNeZdRv4Pj/i75zSdxAujZ0EwY6TpN6ZNaXX3BI/8owLlZAVq2wAKjFhjOtSfdGd5Tm61tN4q0EfPPHnU/kC9kr+HQkJm9h71pIL2Uu6LhoRQNpx/ZTnTXm6L0pxzEQSzal7lYsBQGiBKzzaL7PhZtZ6kY6atALRiiFj7ID8rbE03LrOQw4xoFjo3UBardTy1gQVflyqsysCi1DIStzn8qKNAgMBAAE=",
    "Addresses": null,
    "AgentVersion": "go-ipfs/0.4.14/",
    "ProtocolVersion": "ipfs/0.1.0"
    }
    
  4. 使用ipfs daemon启动节点服务器

  5. 新建终端执行命令ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

image

更新

使用IPFS下载IPFS构建

列出go-ipfs的可用版本:

ipfs cat /ipns/dist.ipfs.io/go-ipfs/versions

然后,查看以前命令($ VERSION)中版本的可用版本:

ipfs ls /ipns/dist.ipfs.io/go-ipfs/$VERSION

下载一个版本的给定版本:

ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_darwin-386.tar.gz # darwin 32-bit build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_darwin-amd64.tar.gz # darwin 64-bit build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_freebsd-amd64.tar.gz # freebsd 64-bit build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_linux-386.tar.gz # linux 32-bit build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_linux-amd64.tar.gz # linux 64-bit build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_linux-arm.tar.gz # linux arm build
ipfs get /ipns/dist.ipfs.io/go-ipfs/$VERSION/go-ipfs_$VERSION_windows-amd64.zip # windows 64-bit build

用法

  ipfs - Global p2p merkle-dag filesystem.

  ipfs [<flags>] <command> [<arg>] ...

SUBCOMMANDS
  BASIC COMMANDS
    init          Initialize ipfs local configuration     # 初始化ipfs本地配置
    add <path>    Add a file to ipfs      # 向ipfs添加文件
    cat <ref>     Show ipfs object data      # 显示ipfs object数据
    get <ref>     Download ipfs objects      # 下载ipfs objects
    ls <ref>      List links from an object     # 一个对象链接的列表
    refs <ref>    List hashes of links from an object   # 一个对象链接的哈希列表

  DATA STRUCTURE COMMANDS
    block         Interact with raw blocks in the datastore     # 与数据存储中的原始块交互
    object        Interact with raw dag nodes      # 与原始dag节点交互
    files         Interact with objects as if they were a unix filesystem      # 与objects交互,就好像它们是unix文件系统一样

  ADVANCED COMMANDS
    daemon        Start a long-running daemon process      # 启动一个长时间运行的守护进程
    mount         Mount an ipfs read-only mountpoint      # 安装一个ipfs只读挂载点
    resolve       Resolve any type of name          # 解析任何类型的名称
    name          Publish or resolve IPNS names      # 发布或解析IPNS名称
    dns           Resolve DNS links       # 解析DNS链接
    pin           Pin objects to local storage      # 将object定位到本地存储
    repo          Manipulate an IPFS repository      # 操作一个ipfs仓库

  NETWORK COMMANDS
    id            Show info about ipfs peers        # 显示ipfs 节点的信息
    bootstrap     Add or remove bootstrap peers       # 添加或删除bootstrap节点
    swarm         Manage connections to the p2p network      # 管理与p2p网络的连接
    dht           Query the DHT for values or peers      # 为values或者节点查询DHT
    ping          Measure the latency of a connection     # 测量连接的延迟
    diag          Print diagnostics     # 打印诊断信息

  TOOL COMMANDS
    config        Manage configuration     # 管理配置
    version       Show ipfs version information    # 显示ipfs版本信息
    update        Download and apply go-ipfs updates     # 下载并应用go-ipfs更新 
    commands      List all available commands      # 所有可用的命令列表

  Use 'ipfs <command> --help' to learn more about each command.

  ipfs uses a repository in the local file system. By default, the repo is located
  at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable:

    export IPFS_PATH=/path/to/ipfsrepo

要开始使用IPFS,您必须首先在您的系统上初始化IPFS的配置文件,这是通过ipfs init。查看ipfs init --help它所需的可选参数的信息。初始化完成后,就可以使用ipfs mountipfs add或其他任何命令来探索!

本地'ipfs working'基本使用:

echo "hello world" > hello
ipfs add hello
# This should output a hash string that looks something like:
# QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
ipfs cat <that hash>

使用Docker

export ipfs_staging=</absolute/path/to/somewhere/>
export ipfs_data=</absolute/path/to/somewhere_else/>

启动运行ipfs的容器并公开端口4001,50018080

docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest

观看ipfs日志:

docker logs -f ipfs_host

等待ipfs启动。看到以下内容时,ipfs正在运行:

Gateway (readonly) server
listening on /ip4/0.0.0.0/tcp/8080

现在可以停止观看日志。
运行ipfs命令:

docker exec ipfs_host ipfs <args...>

例如:连接到节点

docker exec ipfs_host ipfs swarm peers

添加文件:

cp -r <something> $ipfs_staging
docker exec ipfs_host ipfs add -r /export/<something>

停止正在运行的容器:

docker stop ipfs_host

⚠️:如果您之前已经安装过IPFS,并且遇到了使新版本工作的问题,请尝试删除(或备份其他位置)IPFS配置目录(默认为〜/ .ipfs)并重新运行ipfs init。这会将配置文件重新初始化为其默认值,并清除任何错误条目的本地数据存储区。

扩展链接

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务