快速安装

快速安装是为了方便用户搭建开发和测试环境,在单台机器上快速部署WeEvent服务。提供Docker镜像、Bash脚本两种安装方式。

如果是第一次安装WeEvent,参见这里的系统要求 。以下安装过程以Centos 7.2为例。

Docker镜像安装

$ docker pull weevent/weevent:1.3.0; docker run -d -p 8080:8080 weevent/weevent:1.3.0 /root/run.sh

WeEvent的镜像里包括了FISCO-BCOS网络,WeEvent服务的各个子模块以及各种依赖。

Bash安装

需要的一些基础工具yum install wget tree tar netstat

  • 获取安装包

    github下载安装包weevent-1.3.0.tar.gz,并且解压到/tmp/

    $ cd /tmp/
    $ wget https://github.com/WeBankFinTech/WeEvent/releases/download/v1.3.0/weevent-1.3.0.tar.gz
    $ tar -zxf weevent-1.3.0.tar.gz
    

    如果github下载速度慢,可以尝试国内下载链接。 解压后目录结构如下:

    $ cd weevent-1.3.0/ 
    $ tree -L 2
    .
    ├── bin
    │   ├── start-all.sh
    │   └── stop-all.sh
    ├── config.properties
    ├── install-all.sh
    ├── modules
    │   ├── broker
    │   ├── gateway
    │   ├── governance
    │   ├── lib
    │   ├── processor
    │   └── zookeeper
    
  • 修改配置

    默认配置文件./config.properties如下:

    #java jdk environment
    JAVA_HOME=/usr/local/jdk1.8.0_191
    
    # Required module
    # support 2.x
    fisco-bcos.version=2.0
    # FISCO-BCOS node channel, eg: 127.0.0.1:20200;127.0.0.2:20200
    fisco-bcos.channel=127.0.0.1:20200
    # The path of FISCO-BCOS 2.x that contain certificate file ca.crt/sdk.crt/sdk.key
    fisco-bcos.node_path=~/fisco/nodes/127.0.0.1/sdk
    
    # Required module
    gateway.port=8080
    zookeeper.default=true
    zookeeper.connect-string=127.0.0.1:2181
    
    # Required module
    broker.port=7000
    
    # Optional module
    governance.enable=false
    governance.port=7009
    #support both h2 and mysql, default h2
    database.type=h2
    #mysql.ip=127.0.0.1
    #mysql.port=3306
    #mysql.user=xxx
    #mysql.password=yyy
    
    # Optional module
    processor.enable=true
    processor.port=7008
    

    配置说明 :

    • JDK变量JAVA_HOME

      因为区块链使用的加密算法很多OpenJDK版本没有提供。所以这里特别让用户设置符合要求的JDK

    • 区块链FISCO-BCOS

      • fisco-bcos.version

        支持2.0及其以上版本。

      • fisco-bcos.channel

        区块链节点的channel访问入口。配置多个节点时用;分割,如127.0.0.1:20200;127.0.0.2:20200

      • fisco-bcos.node_path

        区块链节点的访问证书、私钥存放目录,FISCO-BCOS 2.x一般目录为~/fisco/nodes/127.0.0.1/sdk

        FISCO-BCOS 2.x的证书文件为ca.crtsdk.crtsdk.key。如果WeEvent服务和区块链节点不在同一台机器上,需要把证书文件拷贝到WeEvent所在机器的当前目录,修改fisco-bcos.node_path=./

    • Gateway

      • 监听端口gateway.port

      • zookeeper配置

        zookeeper.default=true,值为true表示使用zookeeper.connect-string里配置的端口,在本机安装zookeeper服务使用。

        zookeeper.default=false,值为false表示使用zookeeper.connect-string的配置去连接用户已有的zookeeper服务。

    • Broker监听端口broker.port

    • Governance模块配置

      • governance.enable是否安装Governance模块,默认为false不安装
      • 监听端口governance.port
      • 默认使用内置的H2数据库,也支持Mysql配置mysql.*
    • Processor模块配置

      • proceessor.enable是否安装Proceessor模块,默认为false不安装
      • 监听端口processor.port
  • 一键安装

    以安装到目录/usr/local/weevent/为例。

    $ ./install-all.sh -p /usr/local/weevent/
    

    正常安装后,输出有如下关键字:

    7000 port is okay
    8080 port is okay
    2181 port is okay
    param ok
    install module zookeeper
    install module gateway 
    install gateway success 
    install module broker 
    install broker success 
    

    目标安装路径/usr/local/weevent/的结构如下:

    $ cd /usr/local/weevent/
    $ tree -L 1
    .
    |-- broker
    |-- lib
    |-- gateway
    |-- start-all.sh
    |-- stop-all.sh
    |-- zookeeper
    
  • 启停服务

    • 启动服务

      在服务安装目录下/usr/local/weevent,通过start-all.sh命令启动所有服务 ,正常启动如下:

      $ ./start-all.sh
      start weevent-broker success (PID=3642)
      add the crontab job success
      start weevent-gateway success (PID=3643)
      add the crontab job success
      ZooKeeper JMX enabled by default
      Using config: /usr/local/weevent/zookeeper/apache-zookeeper-3.6.0-bin/bin/../conf/zoo.cfg
      Starting zookeeper ... STARTED
      
    • 停止所有服务的命令./stop-all.sh

  • 卸载服务

    所有服务停止后,直接删除目录即可。

快速安装作为一种简易安装方式,默认使用内置的H2数据库。并且所有子服务都是单实例的,生产环境中建议多实例部署。各子模块详细部署参见Broker模块部署Governance模块部署