FISCO搭建说明Ubuntu环境Ubuntu 虚拟机 名称 用途 VirtualBox 6.1.32虚拟机平台Ubuntu 20.04 (amd64,Server)系统镜像文件 Ubuntu 内存给的 2 G,硬盘容量给的 40 G 软件存放 将文件统一存放在 ~/software 目录
软件存放Ubuntu 内存给的 2 G,硬盘容量给的 40 G
安装虚拟机将文件统一存放在
~/software
目录下lsls
更换国内源略过
备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
重写 sources.list
sudo rm /etc/apt/source.list
sodo vim /etc/apt/source.list
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
FISCO 环境
官方文档
Github传送门
此次搭建 FISCO 版本为 2.7.2 ,对应的相关软件版本如下。
sudo apt install -y openssl curl
sudo ufw allow ssh
Ubuntu 安装 Java安装 openssl curl 依赖
# ubuntu系统安装java,将 jdk-9.0.4_linux-x64_bin.tar.gz 放入 /usr/lib/jvm
sudo tar -zvxf jdk-9.0.4_linux-x64_bin.tar.gz # 解压
sudo mv jdk-9.0.4 jdk-9
更改 /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk-9
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
让文件生效
source /etc/profile
搭建 FISCO BCOS 创建目录,下载 build_chain.sh 脚本其他安装包传送门
## 创建操作目录
cd ~ && mkdir -p fisco && cd fisco
## 下载脚本
curl -#LO https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.7.2/build_chain.sh && chmod u+x build_chain.sh
执行脚本设置节点和端口
请使用netstat -an | grep tcp
检查机器的30300~30303,20200~20203,8545~8548
端口是否被占用。
bash build_chain.sh -l 127.0.0.1:4 -p 30300,20200,8545
启动 FISCO BCOS 链
bash nodes/127.0.0.1/start_all.sh
注意: java 版本设置不对可能无法启动
成功后会出现如下效果。
try to start node0
try to start node1
try to start node2
try to start node3
node1 start successfully
node2 start successfully
node0 start successfully
node3 start successfully
检查进程
检查进程是否启动
ps -ef | grep -v grep | grep fisco-bcos
线程数为 4,不为 4 可能端口被占用。&& chmod u+x build_chain.sh
fisco 5453 1 1 17:11 pts/0 00:00:02 /home/ubuntu/software/fisco/nodes/127.0.0.1/node0/../fisco-bcos -c config.ini
fisco 5459 1 1 17:11 pts/0 00:00:02 /home/ubuntu/software/fisco/nodes/127.0.0.1/node1/../fisco-bcos -c config.ini
fisco 5464 1 1 17:11 pts/0 00:00:02 /home/ubuntu/software/fisco/nodes/127.0.0.1/node2/../fisco-bcos -c config.ini
fisco 5476 1 1 17:11 pts/0 00:00:02 /home/ubuntu/software/fisco/nodes/127.0.0.1/node3/../fisco-bcos -c config.ini
检查日志输出
查看节点 node0 链接的节点数
tail -f nodes/127.0.0.1/node0/log/log* | grep connected
bash nodes/127.0.0.1/start_all.sh正常效果,如下。
info|2019-01-21 17:30:58.316769| [P2P][Service] heartBeat,connected count=3
info|2019-01-21 17:31:08.316922| [P2P][Service] heartBeat,connected count=3
info|2019-01-21 17:31:18.317105| [P2P][Service] heartBeat,connected count=3
执行下面指令,检查是否在共识
tail -f nodes/127.0.0.1/node0/log/log* | grep +++
正常情况会不停输出
++++Generating seal
,表示共识正常。
info|2020-12-22 17:24:43.729402|[g:1][CONSENSUS][SEALER]++++++++++++++++ Generating seal on,blkNum=1,tx=0,nodeIdx=1,hash=2e133146...
配置及使用控制台
获取控制台并回到
~/software/fisco
目录
cd ~/software/fisco && curl -LO https://github.com/FISCO-BCOS/console/releases/download/v2.7.2/download_console.sh && bash download_console.sh
拷贝控制台配置文件
若节点未采用默认端口,请将文件中的20200替换成节点对应的channel端口。
# 最新版本控制台使用如下命令拷贝配置文件
cp -n console/conf/config-example.toml console/conf/config.toml
配置控制台证书
cp -r nodes/127.0.0.1/sdk/* console/conf/
启动并使用控制台
启动
cd ~/software/fisco/console && bash start.sh
获取客户端版本
# 获取客户端版本
[group:1]> getNodeVersion
ClientVersion{
version='2.6.0',
supportedVersion='2.6.0',
chainId='1',
buildTime='20200819 15:47:59',
buildType='Darwin/appleclang/RelWithDebInfo',
gitBranch='HEAD',
gitCommitHash='e4a5ef2ef64d1943fccc4ebc61467a91779fb1c0'
}
获取节点信息
[group:1]> getPeers
[
PeerInfo{
nodeID='c1bd77e188cd0783256ee06838020f24a697f9af785438403d3620967a4a3612e3abc4bbe986d1e9dddf62d4236bff0b7d19a935a3cd44889f681409d5bf8692',
ipAndPort='127.0.0.1:30302',
agency='agency',
topic=[
],
node='node2'
},
PeerInfo{
nodeID='7f27f5d67f104eacf689790f09313e4343e7887a1a7b79c31cd151be33c7c8dd57c895a66086c3c8e0b54d2fa493407e0d9646b2bd9fc29a94fd3663a5332e6a',
ipAndPort='127.0.0.1:57266',
agency='agency',
topic=[
_block_notify_1
],
node='node1'
},
PeerInfo{
nodeID='862f26d9681ed4c12681bf81a50d0b8c66dd5b6ee7b0b42a4af12bb37b1ad2442f7dcfe8dac4e737ce9fa46aa94d904e8c474659eabf575d6715995553245be5',
ipAndPort='127.0.0.1:30303',
agency='agency',
topic=[
],
node='node3'
}
]
总结完毕,希望能帮助您