go-filecoin 多节点部署

go-filecoin 单机多节点部署

  • 1,系统版本
  • 2,一台服务器运行第2个节点
  • 3,设置别名

1,系统版本

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04 LTS
Release:	18.04
Codename:	bionic

2,一台服务器运行第2个节点

  • 格式化磁盘挂载到目录
# fdisk -l | grep /dev/sd
# mkfs -t ext4 /dev/sdc

# mkdir /storage2
# mount /dev/sdc /storage2/
# df -Th | grep /dev/sd
  • 设置环境变量
# echo 'export fil2="/root/.filecoin2"' >> /root/.profile
# source /root/.profile
# echo $fil2
/root/.filecoin2
  • 节点2初始化
# go-filecoin init --devnet-user --genesisfile=https://genesis.user.kittyhawk.wtf/genesis.car --repodir=$fil2 --sectordir=/storage2
initializing filecoin node at /root/.filecoin2
22:58:23.423  INFO     badger: All 0 tables opened in 0s
 logger.go:46
22:58:23.432  INFO     badger: All 0 tables opened in 0s
 logger.go:46
22:58:23.441  INFO     badger: All 0 tables opened in 0s
 logger.go:46
22:58:23.449  INFO     badger: All 0 tables opened in 0s
 logger.go:46
 
  • 节点2初始化成功
# ls -al /root/ | grep filecoin
lrwxrwxrwx  1 root root       36 9月  25 11:31 .filecoin -> /root/.filecoin-20190925-113109-v002
lrwxrwxrwx  1 root root       37 10月 29 22:58 .filecoin2 -> /root/.filecoin2-20191029-225823-v002
drwxr-xr-x  8 root root     4096 10月 24 15:04 .filecoin-20190925-113109-v002
drwxr-xr-x  8 root root     4096 10月 29 22:58 .filecoin2-20191029-225823-v002
  • 查看监听端口
# apt install -y net-tools
# netstat -antp | grep go-filecoin
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      46652/go-filecoin
tcp        0      0 127.0.0.1:3453          0.0.0.0:*               LISTEN      46652/go-filecoin
  • 修改端口
# cat /root/.filecoin2/config.json
"api": {
		"address": "/ip4/127.0.0.1/tcp/3453",
"swarm": {
		"address": "/ip4/0.0.0.0/tcp/6000"
	},
# vim  /root/.filecoin2/config.json
"api": {
		"address": "/ip4/127.0.0.1/tcp/3472",
"swarm": {
		"address": "/ip4/0.0.0.0/tcp/6072"
  • 守护进程
# go-filecoin daemon --repodir=$fil2 >> /var/log/filecoin2.log 2>&1 &
  • 查看节点1和节点2 ID
# go-filecoin id
"ID": "Qman
# go-filecoin id --repodir=$fil2
"ID": "QmT
  • 查看监听端口
# netstat -antp | grep go-filecoin
tcp        0      0 127.0.0.1:3472          0.0.0.0:*               LISTEN      9407/go-filecoin
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      46652/go-filecoin
tcp        0      0 0.0.0.0:6072            0.0.0.0:*               LISTEN      9407/go-filecoin
tcp        0      0 127.0.0.1:3453          0.0.0.0:*               LISTEN      46652/go-filecoin
  • 查看节点1和节点2 块同步高度
# go-filecoin show block $(go-filecoin chain head | head -n 1)
Weight: 40964238.292
Height: 71585


3,设置别名

# go-filecoin --repodir=$repodir id

# vim .bashrc
alias go-filecoin='go-filecoin --repodir=$repodir'
# source .bashrc

# go-filecoin id

参考:

  1. 【Filecoin源码仓库全解析】第六章:如何单机部署多节点集群

你可能感兴趣的:(IPFS)