IPFS ubuntu 搭建

IPFS ubuntu 搭建

  • 1,IPFS ubuntu 搭建
  • 2,运行ipfs守护程序
    • 2.1,后台运行
  • 3,下文件
  • 4,设置环境变量,改变ipfs目录

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
  • go-ipfs 二进制包下载v0.4.22
# 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

你可能感兴趣的:(IPFS,ipfs,ubuntu)