向彪fisco bcos入门教程,开始搭建fisco bcos底层链(三)

前言:

这里是由于是学习,就只用了一台服务器,2节点1机构1群组底层架构

机构

节点

所属群组

P2P地址

RPC/channel监听地址

机构A

节点0

群组1

172.27.0.12:30300

172.27.0.12:8545/:20200

 

节点1

群组1

172.27.0.12:30301

172.27.0.12:8546/:20201

正文:

首先先附上官方教程 详细地址:https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/installation.html 有兴趣的朋友可以看看。我们这里记录本次搭建的过程。

1.下载generator

先在root下创建fisco文件夹

进入fisco目录,然后执行一下命令

git clone https://github.com/FISCO-BCOS/generator.git

发现git命令无效,这里我们下载一下

出错原因:服务器没有安装GIT,所以导致出错。

解决方法:

Centos下使用:yum install git -y 或者 yum install -y git

Ubuntu/Debian下使用 : apt-get install git -y

然后继续执行命令

git clone https://github.com/FISCO-BCOS/generator.git

成功了,哈哈.

2.使用工具一键生成链

为了修改方便,这里我们使用xftp连接,进入下图箭头所指的目录

因为我们只是2节点1机构1群组底层架构,所以删除agencyB文件夹

编辑下面路径的文件

原文件如下:

[group]

group_id=1

; Owned nodes

[node0]

; host ip for the communication among peers.

; Please use your ssh login ip.

p2p_ip=127.0.0.1

; listen ip for the communication between sdk clients.

; This ip is the same as p2p_ip for physical host.

; But for virtual host e.g. vps servers, it is usually different from p2p_ip.

; You can check accessible addresses of your network card.

; Please see https://tecadmin.net/check-ip-address-ubuntu-18-04-desktop/

; for more instructions.

rpc_ip=127.0.0.1

channel_ip=0.0.0.0

p2p_listen_port=30300

channel_listen_port=20200

jsonrpc_listen_port=8545

[node1]

p2p_ip=127.0.0.1

rpc_ip=127.0.0.1

channel_ip=0.0.0.0

p2p_listen_port=30301

channel_listen_port=20201

jsonrpc_listen_port=8546

修改后:

先查询本机的内网ip为:172.27.0.12

同样:0.0.0.0也改为172.27.0.12

关于FISCO BCOS网络端口讲解可以看看下面这篇文章

https://mp.weixin.qq.com/s?__biz=MzA3MTI5Njg4Mw==&mid=2247485319&idx=1&sn=b1fb98d27a0f34f5824a876ba8fa5fe6&chksm=9f2ef59ba8597c8d09eac31ccf0be07910e53f2d88afc5f58347247ba045c63736cc74133524&scene=21#wechat_redirect

[group]

group_id=1

; Owned nodes

[node0]

; host ip for the communication among peers.

; Please use your ssh login ip.

p2p_ip=172.27.0.12

; listen ip for the communication between sdk clients.

; This ip is the same as p2p_ip for physical host.

; But for virtual host e.g. vps servers, it is usually different from p2p_ip.

; You can check accessible addresses of your network card.

; Please see https://tecadmin.net/check-ip-address-ubuntu-18-04-desktop/

; for more instructions.

rpc_ip=172.27.0.12

channel_ip=172.27.0.12

p2p_listen_port=30300

channel_listen_port=20200

jsonrpc_listen_port=8545

[node1]

p2p_ip=172.27.0.12

rpc_ip=172.27.0.12

channel_ip=172.27.0.12

p2p_listen_port=30301

channel_listen_port=20201

jsonrpc_listen_port=8546

切换到控制台/root/fisco/generato目录下执行以下命令:

./one_click_generator.sh -b tmp_one_click/

这个过程有点漫长,因为要去github上下载相应的文件,我就先去上个WC压压惊(当然如果是之前已经安装了的,可以把相应的文件直接上传来了,这样快多了)。 这里在我之前的想法中,好像看到过文章讲可以加速,cdn。这里还没仔细研究

。。。。。。。。。。。经过漫长的等待。。WTF。。。。。。。。。。

显示下图的信息表示成功了:

我们启动区块链节点测试下是否正常:

发现报错,根据日志信息显示是ip不对,我们查查、发现内网ip居然变了,这是什么神奇操作。腾讯云真的是厉害,内网ip还会变。

那我们删除生成的文件,修改一下内网ip

把选中的文件都删除,以及agencyA文件夹中只保留node_deployment.ini文件,修改node_deployment.ini文件中的ip如下图所示:

进入下图所示目录,执行命令 ./one_click_generator.sh -b tmp_one_click/

显示成功,我们再次启动节点,来验证是否成功。

cd tmp_one_click/agencyA/node/

./start_all.sh

这里copy一下官方的文档如何验证节点正常:

检查进程

检查进程是否启动

ps -ef | grep -v grep | grep fisco-bcos

正常情况会有类似下面的输出; 如果进程数不为2,则进程没有启动(一般是端口被占用导致的)

检查日志输出

如下,查看节点node0链接的节点数

tail -f /root/fisco/generator/tmp_one_click/agencyA/node/node_10.206.0.10_30301/log/log* |grep connected

正常情况会不停地输出链接信息,从输出可以看出node0与另外1个节点有链接。

执行下面指令,检查是否在共识

tail -f /root/fisco/generator/tmp_one_click/agencyA/node/node_10.206.0.10_30301/log/log* | grep +++

正常情况会不停输出++++Generating seal,表示共识正常。

到这里底层链算是搭建成功了!上个WC压压惊。

猜你喜欢

转载自blog.csdn.net/ws327443752/article/details/108134479