在linux(Ubuntu)当中部署ipfs
查看当前linux操作系统的版本号
查看当前的linux操作系统能够帮助我们在官网:https://ipfs.io/当中下载相应的版本
不过官网需要进行翻墙,没有安装包的可以去我的博客拿,或者微信我
1、创建一个文件夹(ipfs)并将压缩包上传到当前文件夹
sudo mkdir ipfs
cd ipfs
sudo rz
tar xvfz go-ipfs_v0.4.13_linux-amd64.tar.gz
其中sudo rz 指令需要你提前下载lrzsz ,下载命令为sudo apt-get install lrzsz
由于我所有的操作都是在我创建的Ubuntu用户下进行操作,所以会加 sudo
最终的结果如下
ubuntu@10-10-129-28:/data/ipfs$ tar xvfz go-ipfs_v0.4.13_linux-amd64.tar.gz
go-ipfs/build-log
go-ipfs/install.sh
go-ipfs/ipfs
go-ipfs/LICENSE
go-ipfs/README.md
ubuntu@10-10-129-28:/data/ipfs$ cd go-ipfs/
2、查看当前目录,解压缩归档文件,然后使用脚本将ipfs二进制文件移动到可执行文件$PATH中的某个位置install.sh:
ubuntu@10-10-129-28:/data/ipfs/go-ipfs$ ls
build-log install.sh ipfs LICENSE README.md
ubuntu@10-10-129-28:/data/ipfs/go-ipfs$ sudo ./install.sh
Moved ipfs to /usr/local/bin
3、安装成功后,进行测试
ubuntu@10-10-129-28:/data/ipfs/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.
如果出现下面的字段:
USAGE:
ipfs - Global p2p merkle-dag filesystem.
...
恭喜!您现在在计算机上安装了有效的IPFS。
4、ipfs搭建节点
ubuntu@10-10-129-28:/data/ipfs/go-ipfs$ ipfs init
initializing IPFS node at /home/ubuntu/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmNdmQt8aBTTwyjGLVZtQNTrU9xePL67tieWAUa1Zmgg2N
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
ubuntu@10-10-129-28:/data/ipfs/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 id 命令查看自己的本机id
ubuntu@10-10-129-28:/data/ipfs/go-ipfs$ ipfs id
{
"ID": "QmNdmQt8aBTTwyjGLVZtQNTrU9xePL67tieWAUa1Zmgg14",
"PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1jgIf1Uu119sHLj2qZphdde8TonZjWkvdPE9AZoP6FD9mRp2pgYZEb+BIUk9cedXyVyRtboLbuFUof5ndo0MgfhwOtgpt5WxeKY3/ViYT9zdn1IQFijYTi6OZmV0rpqy/LHolRkj7nViyN8/nx6h2IdF3qQoNKykpdrheJzKQV0sHxSLtmYbsAs5nHdlpb0v97vReFFFhwZjSvTfyTePqgNPgOan5RwgpWCW0ggKxNWY0ol4/eaRaImW6Kuv3L1TStkXsdwFwFmybkg7VPvIoXci9tVXAdU1kfba9S6n5vX9XhIQBMIwhIffC8Uhy9zitG6UqqhXicnmeqPxdVhEzAgMBAAE=",
"Addresses": null,
"AgentVersion": "go-ipfs/0.4.13/",
"ProtocolVersion": "ipfs/0.1.0"
}
在本机搭建成功之后我们可以通过ID(QmNdmQt8aBTTwyjGLVZtQNTrU9xePL67tieWAUa1Zmgg14)连接到IPFS提供的可视化界面。只要我们知道ID我们就能够通过ID连接到IPFS节点,访问上面的数据、上传数据。IPFS存在机制,如果只是下载资料,而不为IPFS做贡献,那么我们将会被拉入黑名单。
当前的IPFS节点并没有进入IPFS网络。
5、启动IPFS查看可视化页面
ubuntu@10-10-129-28:/data/ipfs/go-ipfs$ ipfs daemon
Initializing daemon...
Swarm listening on /ip4/10.10.129.28/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmNdmQt8aBTTwyjGLVZtQNTrU9xePL67tieWAUa1Zmgg14
Swarm announcing /ip4/10.10.129.28/tcp/4001
Swarm announcing /ip4/127.0.0.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://127.0.0.1:5001/ipfs/QmNdmQt8aBTTwyjGLVZtQNTrU9xePL67tieWAUa1Zmgg14页面查看,查看结果如下
目前IPFS并没有链接到网络,只能够在本地查看,如果我们想让别人也查看我们的IPFS节点那么我们关闭节点之后,添加一些配置。关闭节点采用ctrl+c的方式。
下面附上一幅没有连接到网络的图
6、IPFS配置
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json Addresses.API '"/ip4/0.0.0.0/tcp/5001"'
通过上面的配置我们就能够在任意的电脑上面打开本地配置的IPFS节点,但需要注意的是将127.0.0.1替换成本低的IP地址
7、当前我存在的问题:
无法连接到peers,求大神指教
————————————————
版权声明:本文为CSDN博主「黑暗料理界的扛把子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41160534/article/details/81358613
网友评论