Ubuntu16.04安装运行go-ipfs

1.下载IPFS的安装包(tizi)

打开官网:https://ipfs.io/,根据平台下载相应安装包,针对Linux系统,下载go-ipfs的地址为:https://dist.ipfs.io/go-ipfs/v0.4.13/go-ipfs_v0.4.13_linux-amd64.tar.gz

2.安装步骤

sily@lyg-sily:~$ tar xvfz go-ipfs_v0.4.13_linux-amd64.tar.gz
sily@lyg-sily:~$ cd go-ipfs
sily@lyg-sily:~/go-ipfs$ ls
build-log  install.sh  ipfs  LICENSE  README.md
sily@lyg-sily:~/go-ipfs$ ./install.sh 
We cannot install ipfs in one of the directories /usr/local/bin /usr/bin
It seems that we do not have the necessary write permissions.
Perhaps try running this script as a privileged user:

    sudo ./install.sh

sily@lyg-sily:~/go-ipfs$ sudo ./install.sh
[sudo] password for sily: 
Moved ipfs to /usr/local/bin
sily@lyg-sily:~/go-ipfs$ ipfs help
USAGE
  ipfs - Global p2p merkle-dag filesystem.

  ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ...

SUBCOMMANDS
  BASIC COMMANDS
    init          Initialize ipfs local configuration
    add <path>    Add a file to IPFS
    cat <ref>     Show IPFS object data
    get <ref>     Download 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
    files         Interact with objects as if they were a unix filesystem
    dag           Interact with IPLD documents (experimental)

  ADVANCED COMMANDS
    daemon        Start a long-running daemon process
    mount         Mount an IPFS read-only mountpoint
    resolve       Resolve any type of name
    name          Publish and resolve IPNS names
    key           Create and list IPNS name keypairs
    dns           Resolve DNS links
    pin           Pin objects to local storage
    repo          Manipulate the IPFS repository
    stats         Various operational stats
    p2p           Libp2p stream mounting
    filestore     Manage the filestore (experimental)

  NETWORK COMMANDS
    id            Show info about IPFS peers
    bootstrap     Add or remove bootstrap peers
    swarm         Manage connections to the p2p network
    dht           Query the DHT for values or peers
    ping          Measure the latency of a connection
    diag          Print diagnostics

  TOOL COMMANDS
    config        Manage configuration
    version       Show ipfs version information
    update        Download and apply go-ipfs updates
    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

  EXIT STATUS

  The CLI will exit with one of the following values:

  0     Successful execution.
  1     Failed executions.
看到以上信息后,表明我们的IPFS已经成功安装。

3.创建ipfs节点

通过命令ipfs init,在本地建立一个IPFS节点。

sily@lyg-sily:~/go-ipfs$ ipfs init
initializing IPFS node at /home/sily/.ipfs
generating 2048-bit RSA keypair...done
peer identity: Qmb6u9rwNXNnWP8rMa8xAWsRQs3bF2zXa8wJ36boGQgJaH
to get started, enter:

    ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

sily@lyg-sily:~/go-ipfs$ ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
Hello and Welcome to IPFS!

██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗  ███████╗
██║██╔═══╝ ██╔══╝  ╚════██║
██║██║     ██║     ███████║
╚═╝╚═╝     ╚═╝     ╚══════╝

If you're seeing this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!

 -------------------------------------------------------
| Warning:                                              |
|   This is alpha software. Use at your own discretion! |
|   Much is missing or lacking polish. There are bugs.  |
|   Not yet secure. Read the security notes for more.   |
 -------------------------------------------------------

Check out some of the other files in this directory:

  ./about
  ./help
  ./quick-start     <-- usage examples
  ./readme          <-- this file
  ./security-notes

执行ipfs init命令后,会在根目录生成一个.ipfs的文件夹存储节点数据。

可以通过ipfs id查看节点id信息:

sily@lyg-sily:~/.ipfs$ ipfs id
{
    "ID": "Qmb6u9rwNXNnWP8rMa8xAWsRQs3bF2zXa8wJ36boGQgJaH",
    "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6d3cfeSCYyI7X4I7hk9EIiZQi7U4t/WpyePqaoTZW7dUkzhlKn5lT745d4aoNE2ddYYynzUhXWj9w+xjQxql3VcO6rO7YLIUvie0mcT36001Cv3CJ3snqMtJXopByBRUp9zasx8yj4Yfb6TQkhbxaz4Wza505LgxoinXZO0CjHM2dp7rQSDxTPmf/SUZBGiwSAvoXyKEaBHS+xFtTXaRRYtoAtIZNnuhKN92PK/8Tz+kr43+vTI6psyCXd8XsueQ5/q8m7Ev+k0SLq75kYFrUZBxnASPdCV7i8415CxhMzfWocKvctCwdupOXxB5LwvBm5IWAiRwiLocZareI0ZP7AgMBAAE=",
    "Addresses": null,
    "AgentVersion": "go-ipfs/0.4.13/",
    "ProtocolVersion": "ipfs/0.1.0"
}

4.启动节点服务器

sily@lyg-sily:~/.ipfs$ ipfs daemon
Initializing daemon...
Adjusting current ulimit to 2048...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/10.0.2.15/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/Qmb6u9rwNXNnWP8rMa8xAWsRQs3bF2zXa8wJ36boGQgJaH
Swarm announcing /ip4/10.0.2.15/tcp/4001
Swarm announcing /ip4/127.0.0.1/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

此时,我们可以通过本地浏览器输入地址:http://localhost:5001/webui 看到一个UI界面,说明节点服务器启动成功。

6.常用命令

  • 查看是否安装完成(readme):
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

在这里插入图片描述

  • 查看本地节点初始目录中的文件
ipfs file ls /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/

在这里插入图片描述

  • 查看本地已经存储的所有文件
ipfs pin ls

在这里插入图片描述

  • 查看某个文件的内容
ipfs cat QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V

在这里插入图片描述

  • 使用ipfs commands可以看到所有的可用命令
ipfs commands

在这里插入图片描述

  • 给本地节点添加文件(当前目录下存在的一个文件)
ipfs add test.txt

在这里插入图片描述
可以通过在浏览器中输入以下网址进行查看ipfs中文件的内容QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG是文件的哈希值

http://127.0.0.1:8080/ipfs/QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG
  • 从本地节点中删除文件
ipfs pin rm QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH
  • 启动服务器节点
ipfs daemon

在这里插入图片描述

随后:

在浏览器中输入:

http://localhost:5001/webui

看到以下情况说明节点服务器启动成功

参考:1
2

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

世事慕竹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值