附录

    ① 安装包下载

    从下载对应版本的java安装包,并解压到服务器相关目录

    ② 配置环境变量

    • 修改/etc/profile
    • 在/etc/profile末尾添加以下信息
    1. JAVA_HOME=/software/jdk-11
    2. PATH=$PATH:$JAVA_HOME/bin
    3. CLASSPATH==.:$JAVA_HOME/lib
    4. export JAVA_HOME CLASSPATH PATH
    • 重载/etc/profile
    1. source /etc/profile

    ③ 查看版本

    1. java -version

    1.2. 数据库部署

    此处以Centos安装MariaDB为例。MariaDB数据库是 MySQL 的一个分支,主要由开源社区在维护,采用 GPL 授权许可。MariaDB完全兼容 MySQL,包括API和命令行。其他安装方式请参考MySQL官网

    ① 安装MariaDB

    1. sudo yum install -y mariadb*
    • 启停
    • 设置开机启动
    1. sudo systemctl enable mariadb.service
    • 初始化
    1. 执行以下命令:
    2. sudo mysql_secure_installation
    3. 以下根据提示输入:
    4. Enter current password for root (enter for none):<–初次运行直接回车
    5. Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
    6. New password: <– 设置root用户的密码
    7. Re-enter new password: <– 再输入一次你设置的密码
    8. Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车
    9. Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
    10. Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

    ② 授权访问和添加用户

    • 使用root用户登录,密码为初始化设置的密码
    1. mysql -uroot -p -h localhost -P 3306
    • 授权root用户远程访问
    1. mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
    2. mysql > flush PRIVILEGES;
    • 创建test用户并授权本地访问
    1. mysql > GRANT ALL PRIVILEGES ON *.* TO 'test'@localhost IDENTIFIED BY '123456' WITH GRANT OPTION;
    2. mysql > flush PRIVILEGES;

    安全温馨提示:

    • 例子中给出的数据库密码(123456)仅为样例,强烈建议设置成复杂密码
    • 例子中root用户的远程授权设置会使数据库在所有网络上都可以访问,请按具体的网络拓扑和权限控制情况,设置网络和权限帐号

    ③ 测试连接和创建数据库

    • 创建数据库
    1. mysql > create database webasetransaction;

    (1)从下载对应版本的安装包,并解压到相应目录

    1. mkdir /software
    2. tar -zxvf zookeeper-XXX.tar.gz /software/

    (2)配置和启动

    ZooKeeper的安装包括单机模式安装,以及集群模式安装。具体步骤请参考官网说明:

    2.1 脚本没权限

    1. 赋权限:chmod + *.sh
    2. 转格式:dos2unix *.sh

    “gradle build -x test”失败,不能编译Lombok注解:

    1. ...
    2. /data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/trans/TransService.java:175: error: cannot find symbol
    3. ^
    4. symbol: variable log
    5. location: class TransService
    6. /data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/trans/TransService.java:183: error: cannot find symbol
    7. log.warn("call fail. contractAddress:{} abi is not exists", contractAddress);
    8. ^
    9. symbol: variable log
    10. location: class TransService
    11. Note: /data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/util/ContractAbiUtil.java uses unchecked or unsafe operations.
    12. Note: Recompile with -Xlint:unchecked for details.
    13. 100 errors
    14. FAILURE: Build failed with an exception.
    15. ...

    答: 修改 build.gradle文件,将以下代码的注释去掉

    1. //annotationProcessor 'org.projectlombok:lombok:1.18.2'

    2.3 启动报错“nested exception is javax.net.ssl.SSLException”

    答:CentOS的yum仓库的OpenJDK缺少JCE(Java Cryptography Extension),导致Web3SDK无法正常连接区块链节点,因此在使用CentOS操作系统时,推荐从OpenJDK网站自行下载。

    1. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleService': Unsatisfied dependency expressed through field 'transService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transService': Unsatisfied dependency expressed through field 'web3jMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'web3j' defined in class path resource [com/webank/webase/transaction/config/Web3Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.HashMap]: Factory method 'web3j' threw exception; nested exception is java.io.IOException: Processing bcos message timeout