IPFS ubuntu 搭建

1,IPFS ubuntu 搭建

  • 系统环境
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
# tar -zxvf go-ipfs_v0.4.22_linux-amd64.tar.gz
# cd go-ipfs/
# ./install.sh
Moved ./ipfs to /usr/local/bin
  • 初始化存储库
# ipfs init
initializing IPFS node at /root/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmQZhYTQTZwPPL6tvDRft3GCqFTgDC2vWJsj1sHECe8Jmf
to get started, enter:

	ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
# 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

2,运行ipfs守护程序

# ipfs daemon
Initializing daemon...
go-ipfs version: 0.4.22-
Repo version: 7
System version: amd64/linux
Golang version: go1.12.7
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/183.60.21.112/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/183.60.21.112/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
  • 查看连接节点
# ipfs swarm peers | wc -l
628

2.1,后台运行

  • 后台运行命令
nohup ipfs daemon >> /storage/ipfs.log 2>&1 &
  • 创建systemd服务,如果有设置环境变量添加变量Environment
# cd /lib/systemd/system/
# touch ipfs.service
# vim ipfs.service
[Unit]
Description=ipfs service
[Service]
Environment='IPFS_PATH=/storage/ipfs'

ExecStart=/usr/local/bin/ipfs daemon
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable ipfs.service
Created symlink from /etc/systemd/system/multi-user.target.wants/ipfs.service to /lib/systemd/system/ipfs.service.
# systemctl start ipfs.service
# systemctl status ipfs.service
  • web访问
http://ip地址:5001/webui

3,下文件

# ipfs get /ipns/proofs.filecoin.io -o /V20/
Saving file(s) to /V20/
 2.00 MiB / 61.75 GiB [>-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]   0.00% 5h16m55s

4,设置环境变量,改变ipfs目录

# vim /root/.bashrc
export IPFS_PATH=/storage/ipfs
# source /root/.bashrc
# echo $IPFS_PATH
/storage/ipfs
  • 初始化
# which ipfs
/usr/local/bin/ipfs
# ipfs init
initializing IPFS node at /storage/ipfs
# pwd
/storage/ipfs
# ls
blocks  config  datastore  datastore_spec  keystore  version

参考:

  1. IPFS Documentation - Install IPFS
  2. Command-line quick start
  3. 让IPFS处于后台服务中
  4. ubuntu 设置脚本开机启动
  5. Adding the Service ipfs
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值