1 關(guān)于ipfs
- 官方網(wǎng)站:https://ipfs.io/
- github: https://github.com/ipfs/
- 中國官方社區(qū):http://ipfser.org/
2 安裝ipfs
具體安裝過程可以參照如下鏈接:https://ipfs.io/docs/install/
2.1 下載
下載地址:https://dist.ipfs.io/#go-ipfs
下載:go-ipfs_v0.4.16_linux-amd64.tar.gz
2.2 安裝
$ tar zxvf go-ipfs_v0.4.16_linux-amd64.tar.gz
$ cd go-ipfs
$ ./install.sh
安裝成功后會將go-ipfs文件夾下的ipfs文件移動到/usr/local/bin目錄下
2.3 測試
運行ipfs help
命令端礼,如果出現(xiàn)如下內(nèi)容說明安裝成功啡莉。
$ 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> ...
3 節(jié)點配置
3.1 創(chuàng)建節(jié)點
執(zhí)行命令ipfs init
$ ipfs init
initializing IPFS node at /home/fc/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmYptDAwzpZQunynPi5oUQBCyXYJRCVphaPLuL1BPhpZVh
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
執(zhí)行以上命令后柳琢,或者用戶的根目錄( /home/fc/)下生成一個名為.ipfs文件夾用于存儲節(jié)點數(shù)據(jù)图毕。
3.2 修改存儲空間
.ipfs節(jié)點的默認存儲空氣為10個G经窖,如果需要修改可以在~/.ipfs/config文件中修改。
將"StorageMax": "10GB"
修改為其他值即可票编。
3.3 查看節(jié)點ID
使用命令ipfs id
$ ipfs id
{
"ID": "QmYptDAwzpZQunynPi5oUQBCyXYJRCVphaPLuL1BPhpZVh",
"PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDtDhxfTIZwnHR25wobaGoEjYkub/oAH57nwPpVhg/dLhDXn3zpG1Gd773S2N6bWZzqnilSzVyVbPHP6WVxgtLZK/iQ4uWcipn7mzACyx9qkJown13H8DqLHrzdMkRc//MyylsUI8FSWWzmd3O/yMliupjPIQIV+b8sfBOSpoBuWJu4RBh8HcHV91iQpNxua4R0uU4uaUtQxVvLjwhu3lKWEuZBhk6Q42WFPF99QWTVWYMD05mVNs2cDJ2kZOjbFUW4803JeCGTPEtHz9KSZI3EGefynIUqNEU0nxXxS/E13OdM8rDyQqQ4tBFKN5WAFxkjGK13UryNu6O7RJ0nLRFPAgMBAAE=",
"Addresses": null,
"AgentVersion": "go-ipfs/0.4.16/",
"ProtocolVersion": "ipfs/0.1.0"
}
3.4 添加文件到節(jié)點
- 添加命令:ipfs add filename
- 查看命令:ipfs cat 添加文件時返回的哈希值
具體操作:
創(chuàng)建一個文件并在里面寫入"123456":
$ touch ipfsfile.txt
$ echo "123456" > ipfsfile.txt
添加到本地節(jié)點:
$ ipfs add ipfsfile.txt
added QmQU2gS4gZ7TpiTECjDUxdQFd9bBBEWxDxPPfhLfYHVuei ipfsfile.txt
7 B / 7 B [===============================================================================================] 100.00%
添加成功后妄迁,會返回該文件的哈希QmQU2gS4gZ7TpiTECjDUxdQFd9bBBEWxDxPPfhLfYHVuei
,我們可以通過它來查看剛剛添加的文件:
$ ipfs cat QmQU2gS4gZ7TpiTECjDUxdQFd9bBBEWxDxPPfhLfYHVuei
123456
3.5 啟動節(jié)點服務(wù)器
使用命令ipfs daemon
$ ipfs daemon
Initializing daemon...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.16.166.1/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.102/tcp/4001
Swarm listening on /ip4/192.168.162.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmYptDAwzpZQunynPi5oUQBCyXYJRCVphaPLuL1BPhpZVh
Swarm announcing /ip4/117.75.47.134/tcp/60249
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/172.16.166.1/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.102/tcp/4001
Swarm announcing /ip4/192.168.162.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
啟動后在瀏覽器中輸入:https://ipfs.io/ipfs/QmQU2gS4gZ7TpiTECjDUxdQFd9bBBEWxDxPPfhLfYHVuei
即可查看剛剛添加的文件的具體內(nèi)容兑障。
3.6 驗證
具體參考:https://ipfs.io/docs/getting-started/
$ 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