FISCO BCOS Air搭建
# FISCO BCOS Air版本
# 版本说明
Air版本FISCO BCOS主要包括创世块配置文件config.genesis和j节点配置文件config.ini
config.ini
:节点配置文件,主要配置RPC、P2P、SSL证书、账本数据路径、落盘加密等信息;config.genesis
:创世块配置文件,须保证群组内所有节点的创世块配置一致, 创世块配置文件在链初始化后不可更改
, 链初始化后,即使更改了创世块配置,新的配置不会生效,系统仍然使用初始化链时的genesis配置。
# 1.Ubuntu20.04环境搭建
# 1.1 安装依赖
root@fisco:~/fisco# sudo apt install -y curl openssl wget
# 1.2 获取安装脚本
root@fisco:~/fisco# curl -#LO https://osp-1257653870.cos.ap-guangzhou.myqcloud.com/FISCO-BCOS/FISCO-BCOS/releases/v3.0.0/build_chain.sh && chmod u+x build_chain.sh
# 1.3 生成四节点FISCO链
确保机器的30300~30303,20200~20203,8545~8548端口没有被占用。
root@fisco:~/fisco# bash build_chain.sh -l 127.0.0.1:4 -p 30300,20200
其中-p选项指定起始端口,分别是p2p监听端口、rpc监听端口
命令成功后会输出All completed:
[INFO] Generate ca cert successfully!
Processing IP:127.0.0.1 Total:4
[INFO] Generate ./nodes/127.0.0.1/sdk cert successful!
[INFO] Generate ./nodes/127.0.0.1/node0/conf cert successful!
[INFO] Generate ./nodes/127.0.0.1/node1/conf cert successful!
[INFO] Generate ./nodes/127.0.0.1/node2/conf cert successful!
[INFO] Generate ./nodes/127.0.0.1/node3/conf cert successful!
[INFO] Generate uuid success: 14502479-cf42-4713-b4ab-14e7d0cef92f
[INFO] Generate uuid success: 22ff7b62-2f0a-46c7-819b-0766e159081e
[INFO] Generate uuid success: 5ac7ad44-4fe7-46a6-9a84-ab844d25f64b
[INFO] Generate uuid success: 10ab8efd-411c-42f2-a96c-0b7591f329bd
==============================================================
[INFO] GroupID : group0
[INFO] ChainID : chain0
[INFO] fisco-bcos path : bin/fisco-bcos
[INFO] Auth mode : false
[INFO] Start port : 30300 20200
[INFO] Server IP : 127.0.0.1:4
[INFO] SM model : false
[INFO] Output dir : ./nodes
[INFO] All completed. Files in ./nodes
# 1.4 启动所有的节点
启动所有节点
root@fisco:~/fisco# bash nodes/127.0.0.1/start_all.sh
try to start node0
try to start node1
try to start node2
try to start node3
node3 start successfully pid=14403
node1 start successfully pid=14405
node2 start successfully pid=14399
node0 start successfully pid=14400
# 2.配置和使用控制台
控制台提供了向FISCO BCOS节点部署合约、发起合约调用、查询链状态等功能。
# 2.1 安装控制台依赖
控制台运行依赖java环境(推荐使用java 14),安装命令如下:
# ubuntu系统安装java
root@fisco:~/fisco# sudo apt install -y default-jdk
// 可以不配置Java的home环境
root@fisco:~/fisco# cat /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:$PATH
root@fisco:~/fisco# java -version
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
# 2.2 下载控制台
root@fisco:~/fisco# cd ~/fisco && curl -#LO https://gitee.com/FISCO-BCOS/console/raw/master/tools/download_console.sh
root@fisco:~/fisco# chmod +x download_console.sh && bash download_console.sh
# 2.3 配置控制台
root@fisco:~/fisco# cp -n console/conf/config-example.toml console/conf/config.toml
root@fisco:~/fisco# cp -r nodes/127.0.0.1/sdk/* console/conf
# 2.4 启动并使用控制台
root@fisco:~/fisco/console# ./start.sh
=============================================================================================
Welcome to FISCO BCOS console(3.0.0)!
Type 'help' or 'h' for help. Type 'quit' or 'q' to quit console.
________ ______ ______ ______ ______ _______ ______ ______ ______
| | \/ \ / \ / \ | \ / \ / \ / \
| $$$$$$$$\$$$$$| $$$$$$| $$$$$$| $$$$$$\ | $$$$$$$| $$$$$$| $$$$$$| $$$$$$\
| $$__ | $$ | $$___\$| $$ \$| $$ | $$ | $$__/ $| $$ \$| $$ | $| $$___\$$
| $$ \ | $$ \$$ \| $$ | $$ | $$ | $$ $| $$ | $$ | $$\$$ \
| $$$$$ | $$ _\$$$$$$| $$ __| $$ | $$ | $$$$$$$| $$ __| $$ | $$_\$$$$$$\
| $$ _| $$_| \__| $| $$__/ | $$__/ $$ | $$__/ $| $$__/ | $$__/ $| \__| $$
| $$ | $$ \\$$ $$\$$ $$\$$ $$ | $$ $$\$$ $$\$$ $$\$$ $$
\$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$$ \$$$$$$ \$$$$$$ \$$$$$$
=============================================================================================
[group0]: /apps>
# 3.常用的控制台命令
# 3.1 编写和调用合约
(1) 部署合约
[group:0]> deploy HelloWord
(2) 查看区块
[group:0]> getBlockNumber
(3) 调用合约
[group:0]> call HelloWorld 0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1 get
# 3.2 控制台常用命令
(1) 查看控制台命令列表
[group:0]> help
(2) 查看具体的命令说明
[group:0]> getBlockNumber -h
(3) 常用命令分类
(1)节点操作:addObserver、addSealer、getPeers、getNodldList
(2)合约操作:call callByCNS、deploy、deployByCNS
(3)区块操作:getBlockByHash.、getBlockByNumber
(4)群组操作:switch、getGroupPeers、getroupList
(5)交易操作:getTransactionByHash、getPendingTransaction、getPendingTxize、getTotalTansactionCount
(6)权限操作:grantPermissionManager、revokePermissionManager
(7)其他操作:getPbftView、getConsensusStatus、getSyncStatus
上次更新: 2023/11/28, 22:03:59