【技术科普】部署工具venachainctl操作指南(v1.2)

万纳链(Venachain)是万向区块链基于PlatONE底层开源平台,针对企业级客户和开发者在数字化转型过程中的实际需求,推出的自主可控的高性能联盟链,已通过中国电子标准化研究院的功能与性能双项测试。依托万向区块链丰富的技术与生态资源,万纳链具备出色的关联技术耦合能力,通过与隐私计算、物联网、知识图谱等技术融合,引航分布式认知技术的创新和实践。同时,结合团队出色的机制设计能力,万纳链旨在为实体经济的数字化转型打造可信数字底座,为企业级客户和开发者提供隐私安全、性能优越、一键部署、功能丰富的综合解决方案。

我们将通过一系列技术科普文章,帮助大家了解万纳链的技术特点和操作方法。今天我们一起来了解万纳链部署工具venachainctl的使用方法。

本文作者:万向区块链通用架构技术部 

0. 阅读指南

在使用 venachainctl.sh 工具前,请先阅读完本章 0.阅读指南 中的内容。如果存在文档也无法提供帮助解决的问题,或者文档有地方存在异议,请及时联系我们。

文档使用方法

  • 关于脚本提供功能的使用,直接看 操作示例 部分即可;

  • 如果在操作过程中遇到问题与疑惑,那么可以通过 注意事项 进行排查。

功能分类

  • 在单机上操作时,查看 1.venachainctl.sh 提供的功能;

  • 多机一键部署查看 2.venachainctl.sh remote deploy

  • 容器化一键部署查看 3.venachainctl.sh docker deploy

指令参数介绍

关于指令中每个参数的作用以及默认值,请查看指令 --help 中的英文解释:

  • 如果没有给出 default 就代表该参数没有默认值。

  • 如果参数解释中有 must be specified ,那么代表该参数是必须给定的。

  • 给定选项选择的都会有 "AAA" and "BBB" are supported 的提示,参数值必须从给出的可选选项中进行选择。

注意事项

  • 注意事项 中,每一个目录第一次出现都会给出完整的相对路径或绝对的方式来表示,相对路径是与 venachainctl.sh 相对的路径。

  • 如果该目录在文中再次出现,那么会直接使用引用表示( ${} )的方法。因此在阅读时,如果需要知道引用表示目录的绝对路径,那么可以在前文中找到。

概念说明

单机与多机

  • 单机部署指的是只在同一台主机上进行操作。

  • 多机部署指的是支持对不在同一个局域网中的主机进行操作。

  • venachainctl.sh 工具中,只有 remotedocker 功能支持多机操作,其余功能都属于单机操作功能。

部署机与目标机

  • 在多机操作时,如果主机Z分别向主机A、B、C、D部署四个节点,那么主机Z即为部署机,主机A、B、C、D即为目标机。

  • 部署机也可以同时是目标机。

  • 在部署机上向目标机部署完节点后,可以进入目标机的部署路径,使用脚本提供的单机操作功能。

配置文件

  • 配置文件指的是 deploy_node-${node-id}.conf 文件,单机部署与多机部署都基于该文件进行操作。

  • 单机部署时,配置文件可以通过 venachainctl.sh dcgen 生成;多机部署时,配置文件可以通过 venachainctl.sh remote prepare 生成。

  • 配置文件也可以根据需要,自定义修改 conf/deploy.conf.template 文件,然后放入相应的目录下。

节点部署目录结构

通过venachainctl one/four 以及分步部署方式

${WORKSPACE}
    ├── bin
    ├── conf
    │   ├── bak                                 // 之前部署时产生的文件的备份
    │   ├── contracts
    │   ├── contracts_privacy
    │   ├── deploy.conf.template                // 配置文件模板
    │   ├── docker-compose.yml.template         // docker-compose文件模板
    │   ├── firstnode.info                      // firstnode信息
    │   ├── genesis.json                        // 链的配置信息
    │   ├── genesis.json.istanbul.template      // genesis.json文件模板
    │   ├── keyfile.account                     // keyfile对应的account
    │   ├── keyfile.json                        // 账户生成的keyfile
    │   └── keyfile.phrase                      // keyfile的密码
    ├── data
    │   └── node-0                              // 节点数据存放位置
    │       ├── deploy_node-0.conf              // 节点配置信息
    │       ├── keystore                        // 存放节点的账户
    │       ├── logs                            // 节点的日志
    │       │   ├── venachain_error.log         // 节点报错日志
    │       │   ├── venachain_log               // 节点运行日志
    │       │   └── wasm_log
    │       ├── node-0.ipc
    │       ├── node.address                    // 节点的地址
    │       ├── node.prikey                     // 节点的私钥
    │       ├── node.pubkey                     // 节点的公钥
    │       └── venachain
    └── scripts
        ├── docker
        ├── local
        └── remote

通过venachainctl remote/docker方式

  • 部署机的目录结构如下

    ${DEPLOYMENT_PATH}
    ├── deployment_conf                           // ${DEPLOYMENT_CONF_PATH}
    │   ├── bak                                   // 之前部署的项目的配置文件备份
    │   ├── logs                                
    │   │   └── prepare_log.txt                   // 当前部署机上所有项目配置文件的信息
    │   └── projects                              // 部署项目的必要数据
    │       └── ${PROJECT_NAME}                   // ${PROJECT_CONF_PATH}
    │           ├── deploy_node-0.conf            // 节点配置文件
    │           ├── global                        // 存放genesis.json等全局信息
    │           │   ├── data                      // 存放所有节点的公钥
    │           │   │   └── node-0
    │           │   │       └── node.pubkey
    │           │   ├── firstnode.info            // firstnode的信息
    │           │   ├── genesis.json              // 链的配置
    │           │   ├── keyfile.account           // firstnode的keyfile对于的account
    │           │   ├── keyfile.json              // firstnode账户生成的keyfile
    │           │   └── keyfile.phrase            // firstnode的keyfile的密码
    │           └── logs
    │               └── deploy_log.txt            // 当前项目部署过程产生的日志
    └── linux                                     // 用于执行部署的必要文件
        ├── bin
        ├── conf
        └── scripts
  • 目标机 deploy_path 的目录结构如下

    .                                             // $HOME/(Venachain|Venachain-docker)
    ├── bak                                       // 以前部署过的项目的conf文件备份
    └── ${DEPLOY_PATH}
        ├── bin
        ├── conf
        │   ├── bak                               // 之前部署时产生的文件的备份
        │   ├── contracts
        │   ├── contracts_privacy
        │   ├── deploy.conf.template              // 配置文件模板
        │   ├── docker-compose.yml.template       // docker-compose文件模板
        │   ├── firstnode.info                    // firstnode信息
        │   ├── genesis.json                      // 链的配置信息
        │   ├── genesis.json.istanbul.template    // genesis.json文件模板
        │   ├── keyfile.accou                     // 账户生成的keyfile
        │   └── keyfile.phrase                    // keyfile的密码
        ├── data
        │   └── node-0                            // 节点数据存放位置
        │       ├── deploy_node-0.conf            // 节点配置信息
        │       ├── keystore                      // 存放节点的账户
        │       ├── logs                          // 节点的日志
        │       │   ├── venachain_error.log       // 节点报错日志
        │       │   ├── venachain_log             // 节点运行日志
        │       │   └── wasm_log
        │       ├── node-0.ipc
        │       ├── node.address                  // 节点的地址
        │       ├── node.prikey                   // 节点的私钥
        │       ├── node.pubkey                   // 节点的公钥
        │       └── venachain
        └── scripts
            ├── docker
            ├── local
            └── remote

1.venachainctl.sh

所有与部署相关的功能的入口。

DESCRIPTION
    The deployment script for venachain
USAGE:
    venachainctl.sh <command> [command options] [arguments...]
COMMANDS
    one                      start a node completely (default account password: 0)
    four                     start four node completely (default account password: 0)
    setupgen                 create the genesis.json and compile sys contract
    init                     initialize node. please setup genesis first
    start                    try to start the specified node
    deploysys                deploy the system contract
    addnode                  add normal node to system contract
    updatesys                update node type
    dcgen                    generate deploy conf file
    keygen                   generate key pair
    gengen                   generate genesis.json file
    addadmin                 add super admin role and chain admin role
    delete                   try to delete the specified node
    stop                     try to stop the specified node
    restart                  try to restart the specified node
    clear                    try to stop and clear the node data
    createacc                create account
    unlock                   unlock node account
    console                  start an interactive JavaScript environment
    remote                   remote deploy
    docker                   docker deploy
    status                   show all node status
    get                      display all nodes in the system contract
    version                  show venachain release version

接口说明

  • 指令 one - updatesys 是兼容老脚本的单机部署与分布部署的命令。

  • 指令 dcgen - addadmin 是新添加的分布部署相关的命令,有新增的功能也有从老脚本逻辑中提取出来的功能。

  • 指令 delete - clear 是单机上和清理链相关的命令。

  • 指令 createunlock 是账户操作的命令。

  • 指令 console 是进入控制台的命令。

  • 指令 remote 是远程一键部署的命令。

  • 指令 docker 是容器化一键部署的命令。

  • 指令 status - version 是查看节点信息相关的命令。

one

在单机上部署一个单节点的链。

one OPTIONS
    --encryption, -enc           the encryption algorithm
                                 "ECDSA" and "GM" are supported (default: ECDSA)
    --consensus                  the consensus type
                                 "ibft" and "raft" are supported (default: ibft)
    --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh one
​
## 自定义参数执行
./venachainctl.sh one --encryption GM --consensus raft

注意事项

  • 如果是要部署新的链,那么在使用前先使用 clear 指令清理下。

  • 固定值: nodeid0ip_addr127.0.0.1rpc_port6791p2p_port16791ws_port26791 。如果上述端口被占用,那么无法完成部署。

four

在单机上部署一个四节点的链。

four OPTIONS
    --encryption, -enc           the encryption algorithm
                                 "ECDSA" and "GM" are supported (default: ECDSA)
    --consensus                  the consensus type
                                 "ibft" and "raft" are supported (default: ibft)
    --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh four
​
## 自定义参数执行
./venachainctl.sh four -encryption GM --consensus raft

注意事项

  • 如果是要部署新的链,那么在使用前先使用 clear 指令清理下。

  • 固定值: nodeid0 ~ 3ip_addr127.0.0.1rpc_port6791 ~ 6794p2p_port16791 ~ 16794ws_port26791 ~ 26794 。如果上述端口被占用,那么无法完成部署。

setupgen

第一个节点生成密钥并生成创世信息。

setupgen OPTIONS
    --nodeid, -n                 the first node id (default: 0)
    --encryption, -enc           the encryption algorithm
                                 "ECDSA" and "GM" are supported (default: ECDSA)
    --consensus                  the consensus type
                                 "ibft" and "raft" are supported (default: ibft)
    --interpreter, -i            select virtual machine interpreter
                                 "wasm", "evm" and "all" are supported (default: all)
    --validatorNodes, -v         set the genesis validatorNodes
                                 (default: the first node enode code)
    --ip                         the first node ip (default: 127.0.0.1)
    --p2p_port, -p2p             the first node p2p_port (default: 16791)
    --auto                       will read exit the deploy conf, node key and skip ip check
    --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh setupgen --auto true
​
## 自定义参数执行
./venachainctl.sh setupgen --nodeid 1 --encryption GM --consensus raft --ip 10.10.10.10 --p2p_port 16792 --interpreter all --auto true

注意事项

  • 如果要分步部署国密节点,本步骤需要给定 --encryption GM

  • 如果使用了参数 --p2p_port ,那么它的值会在完成配置文件的生成后,被保存到配置文件中。

  • 如果设置了 validatorNodes ,那么 genesis.json 中的 firstValidatorNode 字段会将它作为值;否则根据 ipp2p 以及节点的公钥生成 enode://${node_pubkey}@${IP_ADDR}:${P2P_PORT} 作为该字段的值。

  • 如果在 ../conf 下已存在 genesis.json ,那么将它备份至 ../conf/bak 下并生成新的。

  • 如果使用了 --auto 参数:

    • 如果在 ../data/node-${node-id} 中存在 deploy_node-${node-id}.conf 配置文件,那么直接读取,否则直接生成新的配置文件。

    • 如果在 ../data/node-${node-id} 下同时存在 node.prikeynode.pubkeynode.address 这三个密钥文件时,会自动读取它们,否则会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥。(老脚本即使在三个密钥文件都存在的情况,也会直接覆盖旧密钥生成新密钥)

    • 在密钥成功生成后保存 ip 的值到配置文件中。

  • 如果没有使用 --auto 参数:

    • 会先询问是否生成配置文件:

      1. 假如选择 y ,且在 ../data/node-${node-id} 中存在 deploy_node-${node-id}.conf 配置文件,那么会询问是否要覆盖。如果选择 y ,会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥。

      2. 所有交互完成后,如果存在配置文件,会读取配置文件,否则终止流程。

        [local/generate-deployconf] Do You What To Create a deploy conf ? Yes or No(y/n):
        y
        [local/generate-deployconf] Deploy conf already exists, overwrite it? Yes or No(y/n):
        y
    • 会询问是否生成密钥:

      1. 如果选择 y ,那么会检测是否已有密钥文件。只要存在一个密钥文件,就会询问是否要备份旧的密钥并生成新的密钥。如果选择 y ,会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥;

      2. 交互完后,如果三个密钥文件都存在,那么继续流程,否则终止流程。(不会检测公私钥是否匹配)。

        [local/generate-key] Do You What To Create a new node key ? Yes or No(y/n):
        y
        [local/generate-key] Node key already exists, overwrite it? Yes or No(y/n):
        y
    • 会检查输入的 ip 参数的合法性(简单检查是否是 0-999.0-999.0-999.0-999 的格式),如果不合法则要求再次输入。通过检测后,保存 ip 的值到配置文件中。

init

初始化节点。除了 firstnode ,其余节点都从本步骤开始进行在单机上的分步部署

init OPTIONS
    --nodeid, -n                 set node id (default: 0)
    --ip                         set node ip (default: 127.0.0.1)
    --rpc_port, -rpc             set node rpc port (default: 6791)
    --p2p_port, -p2p             set node p2p port (default: 16791)
    --ws_port, -ws               set node ws port (default: 26791)
    --auto                       will read exit the deploy conf and node key 
    --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh init --auto true
​
## 自定义参数执行
./venachainctl.sh init --nodeid 1 --ip 10.10.10.10 --rpc_port 6792 --p2p_port 16792 --ws_port 26792  --auto true

注意事项

  • 如果使用了参数 --ip--rpc_port--p2p_port--ws_port ,那么它们的值会被保存到配置文件中。

  • 如果使用了 --auto 参数:

    • 如果在 ../data/node-${node-id} 中存在 deploy_node-${node-id}.conf 配置文件,那么直接读取,否则直接生成新的配置文件。

    • 如果在 ../data/node-${node-id} 下同时存在 node.prikeynode.pubkeynode.address 这三个密钥文件时,会自动读取它们,否则会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥。(老脚本只要发现有node.pubkey就跳过生成,新脚本要保证三个文件都存在才跳过)

    • 在密钥成功生成后保存 ip 的值到配置文件中。

  • 如果没有使用 --auto 参数(firstnode谨慎使用,可能会导致与genesis中信息不一致的情况):

    • 会先询问是否生成配置文件:

      1. 假如选择 y ,且在 ../data/node-${node-id} 中存在 deploy_node-${node-id}.conf 配置文件,那么会询问是否要覆盖。如果选择 y ,会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥。

      2. 所有交互完成后,如果存在配置文件,会读取配置文件,否则终止流程。

        [local/generate-deployconf] Do You What To Create a deploy conf ? Yes or No(y/n):
        y
        [local/generate-deployconf] Deploy conf already exists, overwrite it? Yes or No(y/n):
        y

    • 会询问是否生成密钥:

      1. 如果选择 y ,那么会检测是否已有密钥文件。只要存在一个密钥文件,就会询问是否要备份旧的密钥并生成新的密钥。如果选择 y ,会将已存在的密钥文件备份至 ../data/node-${node-id}/bak 下,并生成新的密钥。

      2. 交互完后,如果三个密钥文件都存在,那么继续流程,否则终止流程。(不会检测公私钥是否匹配)。

        [local/generate-key] Do You What To Create a new node key ? Yes or No(y/n):
        y
        [local/generate-key] Node key already exists, overwrite it? Yes or No(y/n):
        y

start

根据启动参数来启动节点。

start OPTIONS
    --nodeid, -n                 start the specified node, must be specified
    --bootnodes, -b              connect to the specified bootnodes node
                                 (default: the first in the suggestObserverNodes in genesis.json)
    --logsize, -s                Log block size (default: 67108864)
    --logdir, -d                 log dir (default: ../data/node_dir/logs/)
    --extraoptions, -e           extra venachain command options when venachain starts
                                 (default: --debug)
    --txcount, -c                max tx count in a block (default: 1000)
    --tx_global_slots, -tgs      max tx count in txpool (default: 4096)
    --lightmode, -l              select lightnode mode
                                 "lightnode" and "lightserver" are supported
    --dbtype                     select database type
                                 "leveldb" and "pebbledb" are supported (default: leveldb)
    --all, -a                    start all nodes
    --help, -h                   show help

操作示例

## 启动单个节点
./venachainctl.sh start --nodeid 0
​
## 启动所有节点
./venachainctl.sh start --all
​
## 自定义参数执行
./venachainctl.sh start --nodeid 1 --logdir "/opt/venachain/logs" --extraoptions "--debug --verbosity 4" --lightmode lightserver

注意事项

  • 如果节点已经启动,那么不会执行启动命令。

  • 如果使用了参数 --bootnodes 、 --logsize--logdir--extraoptions--txcount--tx_global_slots--lightmode--dbtype ,那么它们的值会被保存到配置文件中。如果前一次启动失败,那么要注意在 ../data/node-${NODE_ID}/deploy_node-${NODE_ID}.conf 已经保存上了前一次传入的参数。

  • 如果节点启动失败,可以查看 ${log_dir}/venachain_log 下的日志或 ${log_dir}/venachain_error.log 来排查问题。

  • --logdir 参数需要加上 "" ,且使用绝对路径。

  • venachain 的其他参数,都可以加在 --extraoptions 中,参数也需要加上 ""

  • 如果要启动轻节点,那么设置参数为 --lightmode lightnode ;如果要启动轻节点服务,那么设置参数为 --lightmode lightserver

deploysys

firstnode完成权限设置,加入链并成为链上的共识节点。

deploysys OPTIONS
    --nodeid, -n                 the specified node id (default: 0)
    --auto                       will use the default node password: 0
                                 to create the account and also to unlock the account

操作示例

./venachainctl.sh deploysys --auto true

注意事项

  • 不使用 --auto 会询问要创建账户使用的密码。

    [local/create-account] Please input account passphrase.
    123
  • 生成账户后会解锁账户。

  • firstnode 在执行完本操作后完成部署。

addnode

将节点添加到链上。

addnode OPTIONS
    --nodeid, -n                 the specified node id, must be specified
    --desc                       the specified node desc
    --ip                         the specified node ip
                                 If the node specified by nodeid is local,
                                 then you do not need to specify this option
    --rpc_port, -rpc             the specified node rpc_port
                                 If the node specified by nodeid is local,
                                 then you do not need to specify this option
    --p2p_port, -p2p             the specified node p2p_port
                                 If the node specified by nodeid is local,
                                 then you do not need to specify this option
    --pubkey                     the specified node pubkey
                                 If the node specified by nodeid is local,
                                 then you do not need to specify this option
    --type                       select specified node type in "2" & "3"
                                 "2" is observer, "3" is lightnode (default: 2)
    --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh addnode --nodeid 0
​
## 自定义参数执行
./venachainctl.sh addnode --nodeid 1 --desc node1 --ip 10.10.10.10 --rpc_port 6792 --p2p_port 16792 --pubkey b9b5b10c9685b340701a72ce78e471314edcba62f3b208305d6f1f6e50700f3cd8a5b811d70f2a925a79f75c28c8b29c14779c9ff0931b089a1b4e3c5659f310 --type 3

注意事项

  • 参数 --desc 的值中不能有空格。

  • 如果要添加为轻节点,设置参数 --type 3

  • 要由 firstnode 来完成将其他节点加入到区块链。

updatesys

更新节点的类型,可以更新为共识节点或观察者节点。

updatesys OPTIONS
    --nodeid, -n                 the specified node id, must be specified
    --content, -c                update content 
                                 "consensus" and "observer" are supported (default: consensus)
    --help, -h                   show help

操作示例

## 默认更新为共识节点
./venachainctl.sh updatesys --nodeid 0 
​
## 更新为观察者节点
./venachainctl.sh updatesys --nodeid 0 --content observer

注意事项

  • 通过 ./venachainctl.sh get 可以查看节点类型, type:1 为共识节点, type:2 为观察者节点, type:3 为轻节点。

  • 要由 firstnode 来完成更新节点类型。

dcgen

自动生成配置文件。

dcgen OPTIONS
    --nodeid, -n                 the node's name, must be specified
    --auto                       will read exist file
    --help, -h                   show help

操作示例

./venachainctl.sh dcgen --nodeid 0 --auto

注意事项

  • 会在 ../data/node-${NODE_ID} 目录下生成 deploy_node-${NODE_ID}.conf

  • 会检查本机端口占用情况,自动选择空闲端口作为 rpcp2pws 使用的端口号。

  • 如果使用 --auto ,那么在已存在配置文件的情况下,会直接读取配置。

  • 如果没有使用 --auto ,那么首先会询问是否新建配置文件。如果选择 y ,那么会检查是否已存在配置文件,假如已存在,那么会询问是否覆盖该配置文件。

    [local/generate-deployconf] Do You What To Create a deploy conf ? Yes or No(y/n):
    y
    [local/generate-deployconf] Deploy conf already exists, overwrite it? Yes or No(y/n):
    y
  • 备份的配置文件会放置到 ../data/node-${NODE_ID}/bak 下。

keygen

用于生成密钥对。

keygen OPTIONS
   --nodeid, -n                 the specified node name, must be specified
   --encryption, -enc           the encryption algorithm, must be specified
                                "ECDSA" and "GM" are supported
   --auto                       will read exit node key
   --help, -h                   show help

操作示例

## 快速执行
./venachainctl.sh keygen --nodeid 0 --auto
​
## 生成国密密钥对
./venachainctl.sh keygen --nodeid 0 --encryption GM

注意事项

  • 必须给定 --encryption 以用来生成相应加密算法的密钥。

  • 会生成 node.pubkeynode.prikeynode.address 并放置在 ../data/node-${NODE_ID} 目录下。

  • 如果选择 --auto ,且三个密钥文件都存在,那么会直接读取;否则备份已有的密钥文件并生成新的密钥文件。

  • 如果不选择 --auto ,那么会询问是否要生成新的密钥。如果选择 y ,会检查是否存在任意一个密钥文件,如果存在则会询问是否要覆盖。

    [local/generate-key] Do You What To Create a new node key ? Yes or No(y/n):
    y
    [local/generate-key] Node key already exists, overwrite it? Yes or No(y/n):
    y
  • 备份的密钥文件会放置到 ../data/node-${NODE_ID}/bak 下。

gengen

生成 genesis.json 文件。

gengen OPTIONS
   --nodeid, -n                 the first node id, must be specified
   --encryption, -enc           the encryption algorithm, must be specified
                                "ECDSA" and "GM" are supported
   --consensus                  the consensus type, must be specified
                                "ibft" and "raft" are supported
   --interpreter, -i            select virtual machine interpreter, must be specified
                                "wasm", "evm" and "all" are supported
   --validatorNodes, -v         set the genesis validatorNodes
                                (default: the first node enode code)
   --ip                         the first node ip
   --p2p_port, -p2p             the first node p2p_port
   --help, -h                   show help
操作示例
## 快速执行
./venachainctl.sh gengen --nodeid 0
​
## 自定义参数执行
./venachainctl.sh gengen --nodeid 0 --encryption GM --consensus raft --interpreter all 

注意事项

  • 如果在 ../conf 下已存在 genesis.json ,那么它会被备份至 ../conf/bak 下并生成新的。

  • 如果设置了 validatorNodes ,那么 genesis.json 中的 firstValidatorNode 字段会将它作为值;否则根据 ipp2p 以及节点的公钥生成 enode://${node_pubkey}@${IP_ADDR}:${P2P_PORT} 作为该字段的值。

addadmin

授予节点系统管理员与链管理员权限。

addadmin OPTIONS
    --nodeid, -n                the specified node name, must be specified
    --help, -h                  show help

操作示例

./venachainctl.sh addadmin --nodeid 0

注意事项

  • 如果节点已经有相应的权限,那么会跳过执行。

  • 会在 ../conf 下生成 firstnode.info 文件。

delete

将节点从链上删除。

delete OPTIONS
    --nodeid, -n                the specified node id, must be specified
    --help, -h                  show help

操作示例

./venachainctl.sh delete --nodeid 3

注意事项

  • 在执行前,要保证 firstnode 处于运行状态。

  • 尽量保证被删除节点处于运行状态,否则会有删除失败的情况发生。

  • 被删除的节点,其 status 会变为 2 ,删除的操作不可逆。节点的 status 可以通过 get 指令查看。

  • 如果 firstnode 被删除,那么链将会无法正常运作。

stop

停止在 ../data 目录下,正在运行的节点。

stop OPTIONS
   --nodeid, -n                 stop the specified node
   --all, -a                    stop all node
   --help, -h                   show help

操作示例

## 指定某个节点
./venachainctl.sh stop --nodeid 0
​
## 全部节点
./venachainctl.sh stop --all

restart

重新启动在 ../data 目录下的节点。先停止节点,然后再启动节点。

restart OPTIONS
   --nodeid, -n                 restart the specified node
   --all, -a                    restart all node
   --help, -h                   show help

操作示例

## 指定某个节点
./venachainctl.sh restart --nodeid 0
​
## 全部节点
./venachainctl.sh restart --all

注意事项

  • 没有使用 --all ,那么如果节点处于不可用(disable状态)时,会直接启动节点。

  • 使用了 --all ,那么只会对正在运行(enable状态)的节点生效,没有启动的节点不会被启动。

clear

停止在 ../data 目录下的节点,并清除数据。

clear OPTIONS
   --nodeid, -n                 clear specified node data
   --all, -a                    clear all nodes data
   --help, -h                   show help

操作示例

## 指定某个节点
./venachainctl.sh clear --nodeid 0
​
## 全部节点
./venachainctl.sh clear --all

注意事项

  • 假如是清除指定节点,那么会删除该节点的 ../data/node-${nodeid} 目录。

  • 假如时清除所有节点,那么会删除整个 ../data 目录,并将 ../conf 目录下的 genesis.jsonfirstnode.infokeyfile.jsonkeyfile.phrasekeyfile.account 备份至 ../conf/bak 目录下,并将这5个文件从 ../conf 中移除。

createacc

创建账户。

createacc OPTIONS
    --nodeid, -n                the specified node name, must be specified
    --create_keyfile, -ck       will create keyfile
    --auto                      will use the default node password: 0
                                to create the account and also to unlock the account
    --help, -h                  show help

操作示例

## 生成账户
./venachainctl.sh createacc --nodeid 0 
​
## 生成账户,并保存keyfile到本地
./venachainctl.sh createacc --nodeid 0 --create_keyfile
​
## 自动生成密码为0的账户,并保存keyfile到本地
./venachainctl.sh createacc --nodeid 0 --create_keyfile --auto

注意事项

  • 操作后会在 ../data/node-${nodeid} 下生成 UTC--* 文件。

  • 使用 --create_keyfile ,会使用 ../data/node-${nodeid}/keystore 下最新生成的 UTC--* 文件来,在 ../conf 下生成三个 keyfile 文件。

  • 使用 --auto 指令,会自动使用 0 作为账户的密码来生成账户。

  • 生成账户后会解锁账户。

unlock

解锁账户。

unlock OPTIONS
   --nodeid, -n                 unlock account on specified node
   --help, -h                   show help

操作示例

./venachainctl.sh unlock --nodeid 0

注意事项

  • 一个节点可能有多个账户,本操作会将最早生成的账户解锁。

console

进入JavaScript控制台。

console OPTIONS
   --opennodeid , -n            open the specified node console
                                set the node id here
   --closenodeid, -c            stop the specified node console
                                set the node id here
   --closeall                   stop all node console
   --help, -h                   show help

操作示例

## 进入控制台,exit退出
./venachainctl.sh console --nodeid 0
​
## 杀死指定控制台进程
./venachainctl.sh console --closenodeid 0
​
## 杀死所有控制台进程
./venachainctl.sh console --closeall

注意事项

  • 当使用exit退出控制台后,控制台进程就会被删除,不需要再手动执行一次 --closenodeid 命令。

status

获取本机上部署的在 ../data下的节点的运行情况以及节点信息

status OPTIONS                  show all node status
   --nodeid, -n                 show the specified node status info
   --all, -a                    show all nodes status info
   --help, -h                   show help

操作示例

## 指定某个节点
./venachainctl.sh status --nodeid 0
​
## 所有节点
./venachainctl.sh status --all

get

获取加入区块链的节点信息。

操作示例

./venachainctl.sh get

注意事项

  • 使用前要确保链上已经有节点完成部署。

2. venachainctl.sh remote

remote OPTIONS
   deploy               deploy nodes
   prepare              generate directory structure and deployment conf file
   transfer             transfer necessary file to target node
   init                 initialize the target node
   start                start the target node
   clear                clear the target node
   --help, -h           show help

接口说明

  • 命令需在部署机使用。

  • 必须提前在部署机与各目标机之间做好免密登录

remote deploy

一键多机部署。

remote deploy OPTIONS:
    --project, -p               the project name, must be specified
    --encryption, -enc          the encryption algorithm
                                "ECDSA" and "GM" are supported (default: ECDSA)
    --consensus                 the consensus type
                                "ibft" and "raft" are supported (default: ibft)
    --mode, -m                  the specified deploy mode
                                "conf", "one", "four" are supported (default: conf)
                                "conf": deploy node by exist node deploy conf file
                                "one": deploy a one-node chain locally
                                "four": deploy a four-nodes chain locally
    --node, -n                  the node name, only used in conf mode
                                use "," to seperate the name of node
    --address, -addr            the specified node address, only used in conf mode
                                deploy conf file will be generated automatically
    --all, -a                   deploy all nodes
    --help, -h                  show help

操作示例

## 单机部署单节点
./venachainctl.sh remote deploy --mode one --project test
​
## 单机部署四节点
./venachainctl.sh remote deploy --mode four --project test
​
## 根据配置一键多机部署
## --mode conf 可省略
## 根据地址,新建配置文件部署
./venachainctl.sh remote deploy --mode conf --project test --address [email protected],[email protected]
​
## 根据节点名称,读取已有配置文件部署
# 单个节点
./venachainctl.sh remote deploy --mode conf --project test --node 0
# 多个节点
./venachainctl.sh remote deploy --mode conf --project test --node 1,2
# 所有节点
./venachainctl.sh remote deploy --mode conf --project test --all

注意事项

  • 支持通过 --encryption--consensus 参数来部署支持国密、raft的节点。注意,它们只有在 conf 模式下,且部署的节点是 firstnode 时才会生效。

  • 参数 --addr 的值以 ${USER_NAME}@${IP_ADDR} 的形式表示

  • onefour 模式下,如果已存在 ../../../deployment_conf/${PROJECT_NAME} ( ${PROJECT_CONF_PATH} ) 目录,那么会询问是否要覆盖已有项目。如果选择 y ,那么会停止已有项目的节点并进行备份和清除数据,然后依次部署节点;否则停止执行。

    [remote/deploy] /home/wujingwen/workspace/go/src/venachain/release/deployment_conf/projects/test has already been existed, do you want to overwrite it?
    n
  • conf 模式中,有两种部署方式。如果同时使用了 --address--node--all 参数时,默认选择使用 --address 方式。

    • 使用 --address 方式时,如果部署机已存在 ${PROJECT_CONF_PATH} ,那么会询问是否覆盖。如果选择 y ,那么会停止已有项目的节点并进行备份和清除数据,然后依次新建配置文件并部署节点。否则,会询问是否要在已有项目目录下新建配置文件进行部署。如果选择 y ,那么节点会以新节点加入已有链的形式进行部署,否则停止执行。

      [remote/prepare] /home/wujingwen/workspace/go/src/venachain/release/deployment_conf/projects/test already exists, do you want to cover it? Yes or No(y/n): 
      n
      [remote/prepare] Do you mean you want to create new conf file in exist path? Yes or No(y/n): 
      y
    • 使用 --node--all 方式时,会读取 ${PROJECT_CONF_PATH} 下的配置文件,并根据 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 日志内容进行部署。同时使用了 --node--all 参数,会默认使用 --all 进行部署。

  • 关于备份与清除的文件处理的具体内容可参考 remote prepare --cover

  • 如果节点已经被启动,那么再次根据已有配置部署,节点会被重启。

remote prepare

生成部署机上的目录结构并生成项目的配置文件。

remote prepare OPTIONS:
​
    --project, -p               the specified project name, must be specified
    --address, -addr            nodes' addresses, must be specified
    --docker                    deploy by docker method
    --cover                     backup the project directory if exists
    --help, -h                  show help

操作示例

## 生成单个配置文件
./venachainctl.sh remote prepare --project test --address [email protected]
​
## 生成多个配置文件
./venachainctl.sh remote prepare --project test --address [email protected],[email protected],[email protected]

注意事项

  • 会新建2个目录。其中, ../../../deployment_conf ( ${DEPLOYMENT_CONF_PATH} ) 作为部署机主要的工作目录; ../../../deployment_conf/${PROJECT_NAME} ( ${PROJECT_CONF_PATH} ) 作为项目目录。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 参数 --addr 的值以 ${USER_NAME}@${IP_ADDR} 的形式表示。

  • 使用参数 --docker ,会生成适合容器化部署的配置文件。

  • 生成配置文件时,对于参数 deploy_path ,非容器化部署会使用 $HOME/Venachain/${PROJECT_NAME} ; 容器化部署会使用 $HOME/Venachain-docker/${PROJECT_NAME} 作为部署路径。

  • 生成的配置文件会放在 ${PROJECT_CONF_PATH} 目录下。如果要自定义配置文件,手动生成的配置文件同样也需要放入该目录下。

  • 自动生成的配置文件相关信息会立即被写入 ${DEPLOYMENT_CONF_PATH}/logs/prepare_log.txt ;手动添加的配置文件,在下次执行 prepare 命令时也会被写入 ${DEPLOYMENT_CONF_PATH}/logs/prepare_log.txt 。该日志文件记录了部署机目录下所有项目下配置文件的概要信息。

  • 使用参数 --cover ,会在已存在相同项目名的目录的情况下,直接进行备份覆盖操作。

  • 不使用参数 --cover ,在已存在相同项目名的目录的情况下,会首先问是否要覆盖已有项目。如果选择 y ,那么会备份已有项目并生成新的项目,覆盖会根据当前项目的配置文件完成节点的停止、备份以及清理;否则询问是否要在已有项目下新增配置文件。关于目标机上的备份与清除的文件处理可参考 remote clear --mode clean --all 。清理完成后,部署机上 ${PROJECT_CONF_PATH} 会被打上时间戳并移至 ${DEPLOYMENT_CONF_PATH}/bak 下。

    [remote/prepare] /home/wujingwen/workspace/go/src/venachain/release/deployment_conf/projects/test already exists, do you want to cover it? Yes or No(y/n): 
    n
    [remote/prepare] Do you mean you want to create new conf file in exist path? Yes or No(y/n): 
    y
  • 生成配置文件会自动探测并避开目标机已占用的端口,以及 prepare_log.txt 中记录的已占用的端口。

remote transfer

向目标机传输部署需要的文件。

remote transfer OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --all, -a                   transfer files to all nodes
    --help, -h                  show help

操作示例

## 单节点执行
./venachainctl.sh remote transfer --project test --node 0
​
## 多节点执行
./venachainctl.sh remote transfer --project test --node 1,2
​
## 所有节点执行
./venachainctl.sh remote transfer --project test --all

注意事项

  • 在执行前,必须确保 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.confdeploy_pathuser_nameip_addrp2p_port 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • 会新建两个目录。其中,目录 ${PROJECT_CONF_PATH}/global 用于存放全局信息,如 genesis.jsonfirstnode.info 等;目录 ${PROJECT_CONF_PATH}/logs 用于存放项目部署过程中产生的日志信息。

  • 会将 ../conf../scripts../bin 以及 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.conf 传输到目标机。

  • 各项文件传输完成的日志会被记录到 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 中。如果传输过程中因出现错误而中断,再次执行相同的指令可以跳过已完成传输的文件。

  • 同一台目标机上的同一个项目,目录 ../conf../scripts../bin 只会被传送一次。其中任意一个已经在 deploy_log.txt 里记录过完成传输,就不会再进行传输。因此,如果手动将目标机上的以上任意目录活目录中的文件删除,那么应当手动将关联的输出日志手动删除。

remote init

完成启动节点前的所有初始化操作。

remote init OPTIONS:
    --project, -p               the specified project name, must be specified
    --encryption, -enc          the encryption algorithm, must be specified for new project
                                "ECDSA" and "GM" are supported
    --consensus                 the consensus type, must be specified for new project
                                "ibft" and "raft" are supported
    --interpreter, -i           Select virtual machine interpreter, must be specified for new project
                                "wasm", "evm" and "all" are supported
    --validatorNodes, -v        set the genesis validatorNodes, must be specified for new project
                                (default: the first node enode code)
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --all, -a                   init all nodes
    --help, -h                  show help

操作示例

## 单节点执行
./venachainctl.sh remote init --project test --encryption GM --consensus raft --node 0
​
## 多节点执行
./venachainctl.sh remote init --project test --node 1,2
​
## 所有节点执行
./venachainctl.sh remote init --project test --all

注意事项

  • 在执行前,必须确保 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.confdeploy_pathuser_nameip_addrrpc_portp2p_port 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • 如果是新项目,还没有生成 genesis.json ,那么必须设置 --encryption--consensus--interpreter 这几个参数。

  • 目标机上生成的 node.pubkey 会被传输至部署机的 ${PROJECT_CONF_PATH}/global/data/node-${NODE_ID}/ 目录下。

  • 只要部署机不存在 ${PROJECT_CONF_PATH}/global/genesis.json ,就会默认当前节点为 firstnode

  • 如果是 firstnode ,目标机上生成的 genesis.json 会被传输至部署机的 ${PROJECT_CONF_PATH}/global 目录下。

  • 如果不是 firstnode ,那么会先将部署机上的 ${PROJECT_CONF_PATH}/global/genesis.json 传输至目标机的 ${DEPLOY_PATH}/conf 下。

  • 初始化阶段各项执行完成的日志会被记录到 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 中。如果执行命令的过程中因出现错误而中断,再次执行相同指令可以跳过已完成执行的命令。所有命令执行成功后,根据日志只会执行一次,如果手动对密钥或genesis文件进行了删除,那么也应当删除对应的日志内容。

  • 第一次部署该节点,即没有相关执行完成的日志(比如密钥生成、genesis生成)时,但目标节点的三个密钥文件都存在(可能某些需求场景需要用指定密钥手动放入),那么会直接读取;否则会备份已有的密钥文件并生成新的密钥文件。而如果已存在 genesis.json ,那么会被直接备份原文件并生成新文件。

remote start

完成节点的启动、加入链与成为共识节点。

remote start OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --all, -a                   start all nodes
    --help, -h                  show help

操作示例

## 单节点执行
./venachainctl.sh remote start --project test --node 0
​
## 多节点执行
./venachainctl.sh remote start --project test --node 1,2
​
## 所有节点执行
./venachainctl.sh remote start --project test --all

注意事项

  • 在执行前,必须确保 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.confdeploy_pathuser_nameip_addrrpc_port 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • 只要部署机不存在 ${PROJECT_CONF_PATH}/global/genesis.json ,就会默认当前节点为 firstnode

  • 部署 firstnode 时,生成的 keyfile 文件与 firstnode.info 会从目标机传输到部署机的 ${PROJECT_CONF_PATH}/global 下。

  • 部署非 firstnode 时, firstnode.info 会被传输至宿主机的 ${DEPLOY_PATH}/conf 下;当前部署节点的 node.pubkey 与配置文件会被传输至 firstnode 所在目标机的 ${DEPLOY_PATH}/data/node-${NODE_ID} 下。其中, ${NODE_ID} 是当前被部署的节点名,而不是 firstnode 的节点名。

  • 本阶段各项执行完成的日志会被记录到 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 中。如果在执行命令的过程中因出现错误而中断,再次执行相同的指令可以跳过已完成执行的命令(节点启动除外)。

  • 如果节点已经启动,那么再次执行执行本命令,节点会被重启。

remote clear

远程清洁。

remote clear OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --mode, -m                  the specified execute mode
                                "deep", "delete", "stop", "restart", "clean" are supported (default: deep)
                                "deep": will do "delete" and "clean" actions
                                "delete": will delete the node from chain
                                "stop": will stop the node
                                "restart": will restart the node
                                "clean": will stop the node and remove the files, configuration files will be backed up
    --all, -a                   clear all nodes
    --help, -h                  show help

操作示例

## 链上删除节点
./venachainctl.sh remote clear --project test --mode delete --node 1
​
## 停止节点
./venachainctl.sh remote clear --project test --mode stop --node 1
​
## 重启节点
./venachainctl.sh remote clear --project test --mode restart --node 1
​
## 停止节点,并删除节点文件
./venachainctl.sh remote clear --project test --mode clean --node 1
​
## 链上删除节点,停止节点,并删除节点文件
# --mode deep 可省略
./venachainctl.sh remote clear --project test --mode deep --node 1
​
## 多种执行方式
# 单节点执行
./venachainctl.sh remote clear --project test --node 0
​
# 多节点执行
./venachainctl.sh remote clear --project test --node 1,2
​
# 所有节点执行
./venachainctl.sh remote clear --project test --all

注意事项

  • 在执行前,必须确保 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.confdeploy_pathuser_nameip_addrp2p_port 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • delete 操作:

    • 不允许对 firstnode 进行该操作。如果有需求需要从链上删除 firstnode ,可到目标机使用 vclvenachainctl.sh delete 进行删除。使用 --all 会跳过对 firstnode 的删除。

    • 要求 ${PROJECT_CONF_PATH}/global/firstnode.info 存在,且 user_nameip_addrrpc_port 字段不能为空。

    • firstnode 必须在正常运行。

  • stop 操作会杀死节点的进程,如果是容器化部署,那么会停止容器 。

  • clean 操作:

    • 首先执行 stop 操作,然后对节点部署所在目录中的文件进行清理。

    • 如果是容器化部署,会将对应的容器删除。

    • 只有配置文件会被备份至 "${DEPLOY_PATH}/../bak/${PROJECT_NAME}" 目录下,其余在 ${NODE_DIR} 下的文件都会被删除。

    • 节点在部署过程中向 deploy_log.txt 里写入的日志内容会被删除。

    • 如果节点所在目标机的部署路径下,所有文件都已被删除,或路径下存在的所有 ${NODE_DIR} 中都没有 node.prikey 文件,那么该目标机部署路径下的 scriptsdatabin 目录会被删除; conf 目录会被备份至 "${DEPLOY_PATH}/../bak/${PROJECT_NAME}" 目录下。

    • 如果某个节点的部署过程还没有执行到密钥生成步骤,仅完成了配置文件的传输,就停止了部署。而同目录下其他节点都完成了 cleandeep 操作,那么该节点也会被一起清理掉。并且,它被清理的配置文件不会被备份。

    • 在项目中的所有节点被清除后:

      • "${DEPLOY_PATH}/../bak/${PROJECT_NAME}" 会被打上时间戳。

      • 部署机上的 ${PROJECT_CONF_PATH} 下的 globallogs 会被删除,如果需要备份可以提前手动进行操作。

      • ${PROJECT_CONF_PATH} 目录以及目录下的配置文件不会删除是为了方便下次以使用 remote deploy --node 命令进行同样配置的部署;如果想要覆盖重新部署,那么可以使用 remote deploy --addr ;如果想要彻底删除,可以直接手动进行操作。

  • deep 操作会依次执行 deleteclean

3. venachainctl.sh docker

docker OPTIONS
   deploy               deploy docker nodes
   setupdc              generate docker-compose yml file by deployment conf file
   transfer             transfer necessary file to target node
   start                start the target docker node
   --help, -h           show help

接口说明

  • 本命令也属于多机部署命令,需在部署机使用。

  • 必须提前在部署机与各目标机之间做好免密登录。

  • 部署机与目标机都要配置好docker和docker-compose环境

docker deploy

一键容器化部署。

docker deploy OPTIONS:
    --project, -p               the specified project name, must be specified.
    --encryption, -enc          the encryption algorithm
                                "ECDSA" and "GM" are supported (default: ECDSA)
    --consensus                 the consensus type
                                "ibft" and "raft" are supported (default: ibft)
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --address, -addr            the specified node address          
    --all, -a                   deploy all nodes
    --help, -h                  show help

操作示例

## 根据地址,新建配置文件部署
./venachainctl.sh docker deploy --project test --address [email protected],[email protected]
​
## 根据节点名称,读取已有配置文件部署
# 单个节点
./venachainctl.sh docker deploy --project test --node 0
# 多个节点
./venachainctl.sh docker deploy --project test --node 1,2
# 所有节点
./venachainctl.sh docker deploy --project test --all

注意事项

  • 支持通过 --encryption--consensus 参数来部署支持国密、raft的节点。注意,它们只有当部署的节点是 firstnode 时才会生效。

  • 如果同时使用了 --address--node--all 参数时,默认选择使用 --address 方式。

    • 使用 --address 方式时,如果部署机已存在 ${PROJECT_CONF_PATH} ,那么会询问是否覆盖。如果选择 y ,那么会停止已有项目的节点并进行备份和清除数据,然后依次生成新的配置文件并部署节点。否则,会询问是否要在已有项目目录下新建配置文件进行部署。如果选择 y ,那么节点会以新节点加入已有链的形式进行部署,否则停止执行。

      [remote/prepare] /home/wujingwen/workspace/go/src/venachain/release/deployment_conf/projects/test already exists, do you want to cover it? Yes or No(y/n): 
      n
      [remote/prepare] Do you mean you want to create new conf file in exist path? Yes or No(y/n): 
      y
    • 使用 --node--all 方式时,会读取 ${PROJECT_CONF_PATH} 下的配置文件,并根据 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 日志内容进行部署。同时使用了 --node--all 参数,会默认使用 --all

  • 关于文件的备份与清除处理的具体内容可参考 remote prepare --cover

  • 如果节点已经被启动,那么再次根据已有配置部署,节点会被重启。

docker setupdc

一键生成docker-compose文件。

docker setupdc OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node id, must be specified
    --encryption, -enc          the encryption algorithm, must be specified for new project
                                "ECDSA" and "GM" are supported
    --consensus                 the consensus type, must be specified for new project
                                "ibft" and "raft" are supported
    --help, -h                  show help

操作示例

./venachainctl.sh remote docker --project test --node 0 --encryption GM --consensus raft

注意事项

  • 如果是新项目且还没有生成 genesis.json ,那么必须设置 --encryption--consensus 参数。

docker transfer

向目标机传输部署需要的文件。

docker transfer OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --all, -a                   transfer files to all nodes
    --help, -h                  show help

操作示例

## 单节点执行
./venachainctl.sh docker transfer --project test --node 0
​
## 多节点执行
./venachainctl.sh docker transfer --project test --node 1,2
​
## 所有节点执行
./venachainctl.sh docker transfer --project test --all

注意事项

  • 在执行前,必须确保 ${PROJECT_CONF_PATH}/deploy_node-${NODE_ID}.confdeploy_pathuser_nameip_addr 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • 会新建两个目录。其中,目录 ${PROJECT_CONF_PATH}/global 用于存放全局信息,如 genesis.jsonfirstnode.info 等;目录 ${PROJECT_CONF_PATH}/logs 用于存放项目部署过程中产生的日志信息。

  • 节点的配置文件和docker-compose文件会从部署机被传输至目标机的 ${DEPLOY_PATH}/data/node-${NODE_ID} 目录下。

  • 如果目标机没有当前版本的镜像,那么部署机会先将镜像导出成tar包发送至目标机,然后在目标机上读取tar包导入镜像。该过程中在部署机和目标机上产生的tar包在完成传输工作后会被清除。

  • 各项文件传输完成的日志会被记录到 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 中。如果传输过程中因出现错误而中断,再次执行相同的指令,会自动可以跳过已完成传输的文件的传输工作。

docker start

根据配置文件和docker-compose文件完成节点的容器化部署。

docker start OPTIONS:
    --project, -p               the specified project name, must be specified
    --node, -n                  the specified node name
                                use "," to seperate the name of node
    --all, -a                   start all nodes
    --help, -h                  show help

操作示例

## 单节点执行
./venachainctl.sh docker start --project test --node 0
​
## 多节点执行
./venachainctl.sh docker start --project test --node 1,2
​
## 所有节点执行
./venachainctl.sh docker start --project test --all

注意事项

  • 节点配置文件中的 deploy_pathuser_nameip_addrrpc_port 不能为空。

  • 如果部署机与目标机无法连通,或者无法免密登录目标机,那么会终止执行。本机不会做该检测。

  • 同时使用了 --node--all 参数,会默认使用 --all

  • 节点的启动与停止实际上是容器的启动与停止。节点完成容器的启动后,会在 ${DEPLOY_PATH}/node-${NODE_ID} 目录下生成 nodeid 文件,该文件用于标识容器启动前的所有工作都已完成,请勿手动删除该文件。

  • 只要部署机不存在 ${PROJECT_CONF_PATH}/global/genesis.json ,就会默认当前节点为 firstnode

  • 所有节点在完成容器启动后,会把 node.pubkey 传输到部署机的 ${PROJECT_CONF_PATH}/global/data/node-${NODE_ID} 目录下。

  • 当部署 firstnode 时,生成的 genesis.jsonkeyfilefirstnode.info 会从目标机传输到部署机的 ${PROJECT_CONF_PATH}/global 目录下。

  • 当部署非 firstnode 时, genesis.jsonfirstnode.info 会从部署机被传输至目标机的 ${DEPLOY_PATH}/conf 目录下。当前部署节点的 node.pubkey 和节点配置文件会被传输至 firstnode 所在目标机的 ${DEPLOY_PATH}/data/node-${NODE} 下。其中, ${NODE_ID} 是当前被部署节点的名称,而不是 firstnode 的节点名称。注意, firstnode.info 中的 deploy_pathuser_nameip_addr 不能为空。

  • 本阶段各项执行完成的日志会被记录到 ${PROJECT_CONF_PATH}/logs/deploy_log.txt 中。如果执行命令的过程中因出现错误而中断,再次执行指令可以跳过已完成执行的命令(节点启动除外)。

  • 如果节点已经启动,那么再次执行执行本命令,节点会被重启。

docker build

一键生成docker镜像。

docker build OPTIONS:
    --compile_env               build environment image for compiling venachain
    --venachain                 build venachain docker image
    --help, -h                  show help

操作示例

## 生成编译环境镜像
./venachainctl.sh docker build  --comile_env
​
## 生成venachain镜像
./venachainctl.sh docker build --venachain

注意事项

  • 必须在完整的venachain项目目录下使用本功能。

  • 使用 --compile_env 时,会提示输入生成镜像的版本号。

  • 使用 --venachain 时,会根据 ../bin/venachain --version 作为镜像的版本号。

  • 如果镜像名已存在,那么会终止执行。

猜你喜欢

转载自blog.csdn.net/Venachain/article/details/122977622
今日推荐