IPFS安装笔记
cd /home
mkdir ipfs
cd ipfs/
2. 下载go-ipfs_v0.6.0_linux-amd64.tar.gz
进入https://github.com/ipfs/go-ipfs/releases下载相应的版本
http://139.159.188.90:8080/s/x2cieDBAqoHXgqJ
3. 解压
tar -xzvf go-ipfs_v0.6.0_linux-amd64.tar.gz
-x:解开压缩文件
-z:用Gzip压缩或解压
-v:显示压缩或解压的过程
-f:目标文件名
./install.sh
或
sudo bash install.sh
出现:
6. 查看是否安装成功
看到以上提示,不要理睬,ipfs help查看是否安装成功,再查看ipfs版本
7. 使用ipfs
(1)初始化ipfs
[root@localhost go-ipfs]# ipfs init
initializing IPFS node at /root/.ipfs
generating 2048-bit RSA keypair…done
peer identity: QmSrzE3Ry4t8craUHNuv78ib4ovTTQ3xdMbtPwCy75iPz7
to get started, enter:
ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/readme
[root@localhost ~]# ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/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
QmSrzE3Ry4t8craUHNuv78ib4ovTTQ3xdMbtPwCy75iPz7为该结点ID,也可通过命令查看:ipfs id
[root@localhost go-ipfs]# ipfs id
{
“ID”: “QmSrzE3Ry4t8craUHNuv78ib4ovTTQ3xdMbtPwCy75iPz7”,
“PublicKey”: “CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCso3EZfeELK9NE5yQP/VxV8o3BzeYewCM+DOa2ZvOX0WyT/ZtrMpDSQXMRotADANdGDqqUe0tnqjcXh/X+Esf1h6PE0QOXpP3aukdr2OdZFh3b7rlIbIilUmlNMJ6WTmcd9TtsFHuEF8QgXg3pVSeb5LRpxGU2ZQPIMXg7CN8fMrE6j4TH1Jc2lIZKlyOGIN/408hCy3+1vn+a7BVSxJzQi/0fTKV8tNiGNJt/ewfTaDel6X7RRCJpm/I3njphfThjdehyewbpDy8uBppDTEDCpS695z0NCty1vNji+vkk3956n1/EyPVBb9LodEEiTYWMfLGcowRU6djiB36FA9yTAgMBAAE=”,
“Addresses”: null,
“AgentVersion”: “go-ipfs/0.6.0/”,
“ProtocolVersion”: “ipfs/0.1.0”
}
(2)查看配置
ipfs config show
(3)修改配置
[root@localhost go-ipfs]# ipfs config edit
Error: ENV variable $EDITOR not set
此时,需要为ipfs指定编辑器,本人指定vi
[root@bigdata1 go-ipfs]# export EDITOR=vi
[root@bigdata1 go-ipfs]# export EDITOR=/usr/bin/vim
[root@bigdata1 go-ipfs]# ipfs config edit
{
“Identity”: {
“PeerID”: “QmSrwirNYh8MEH4XsN5zNS5yepuSbRkswqrs6vQSmwhpxV”,
“PrivKey”: “CAASqAkwggSkAgEAAoIBAQDKYsH0fYoeVGgpFeRjMV0CxqPOpu3trvH1y9/sGHgrq89zWjfO9RH5Ev95Xq4vPTTjwaUzBMtwztomq/17QDQPCBO7ssiGm+z9ZitIsKUubkC2cJhHzgfWhLhjm/zx9hAjzU7EUt6TpsYM0UB3t+gdn6ikvZJSSLhFyJ4eutAXaE/gvET3serS5qjLovvaoLLkg/WKRX3bUn
R8badlbj37NpwNPNqQi4KWuisYJPl8l3gQq5YbqNuSuYf18bbRRnrJJmS58LdVCMUDZt9Tay35lAMcGEYNlkibE4vth3kmgYePBhppYmwc9Y8LKLEF7Fu2e+QXihtmOgniNTEQzPebAgMBAAECggEAGobjQ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uMYpp+qg0Tf+udG3ja23hYTjKcSlKY4cOENZyrbXHSjqP/msLEYsAuy0Jo0XxjihBlY/wWJWhiAy0nljjWb7QxnGnJDY9a+V9S1hEUEYB4dDDACK9bVob2Xf3h1hbv/BeZXQgRij”
},
修改配置:
[root@bigdata1 go-ipfs]# ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
[root@bigdata1 go-ipfs]# ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
[root@bigdata1 go-ipfs]# ipfs add hello.txt
added QmTLQVM77LytzM2NtJEHfgJVZDMmc74EreyehDAjfSbLaN hello.txt
19 B / 19 B [=============================================] 100.00%
[root@bigdata1 go-ipfs]# ipfs cat QmTLQVM77LytzM2NtJEHfgJVZDMmc74EreyehDAjfSbLaN
ipfs add hello.txt
[root@bigdata1 go-ipfs]# ipfs daemon
Initializing daemon…
go-ipfs version: 0.6.0
Repo version: 10
System version: amd64/linux
Golang version: go1.14.4
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/127.0.0.1/udp/4001/quic
Swarm listening on /ip4/192.168.85.101/tcp/4001
Swarm listening on /ip4/192.168.85.101/udp/4001/quic
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /ip6/::1/udp/4001/quic
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/127.0.0.1/udp/4001/quic
Swarm announcing /ip4/192.168.85.101/tcp/4001
Swarm announcing /ip4/192.168.85.101/udp/4001/quic
Swarm announcing /ip6/::1/tcp/4001
Swarm announcing /ip6/::1/udp/4001/quic
API server listening on /ip4/0.0.0.0/tcp/5001
WebUI: http://0.0.0.0:5001/webui
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
Daemon is ready
[root@bigdata1 go-ipfs]# ipfs config –json API.HTTPHeaders.Access-Control-Allow-Origin ‘[“http://192.168.85.101:5001”, “http://127.0.0.1:5001”, “https://webui.ipfs.io”]’
[root@bigdata1 go-ipfs]# ipfs config –json API.HTTPHeaders.Access-Control-Allow-Methods ‘[“PUT”, “POST”]’
[root@bigdata1 go-ipfs]# ipfs daemon
注意:其中 Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080 网关地址配置为127.0.0.1,只能本地访问,如果想远程访问,需要将其修改为0.0.0.0,修改方法,运行命令:
ipfs config edit
同时也可以修改8080端口。
“Addresses”: {
“Swarm”: [
“/ip4/0.0.0.0/tcp/4001”,
“/ip6/::/tcp/4001”
],
“Announce”: [],
“NoAnnounce”: [],
“API”: “/ip4/0.0.0.0/tcp/5001”,
“Gateway”: “/ip4/0.0.0.0/tcp/8080”
},
参考资料:
1、https://github.com/ipfs/kubo/releases
2、https://www.jianshu.com/p/d555f785ac10