附录
① 安装包下载
从下载对应版本的java安装包,并解压到服务器相关目录
② 配置环境变量
- 修改/etc/profile
- 在/etc/profile末尾添加以下信息
JAVA_HOME=/software/jdk-11
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH==.:$JAVA_HOME/lib
export JAVA_HOME CLASSPATH PATH
- 重载/etc/profile
source /etc/profile
③ 查看版本
java -version
1.2. 数据库部署
此处以Centos安装MariaDB为例。MariaDB数据库是 MySQL 的一个分支,主要由开源社区在维护,采用 GPL 授权许可。MariaDB完全兼容 MySQL,包括API和命令行。其他安装方式请参考。
① 安装MariaDB
sudo yum install -y mariadb*
- 启停
- 设置开机启动
sudo systemctl enable mariadb.service
- 初始化
执行以下命令:
sudo mysql_secure_installation
以下根据提示输入:
Enter current password for root (enter for none):<–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
② 授权访问和添加用户
- 使用root用户登录,密码为初始化设置的密码
mysql -uroot -p -h localhost -P 3306
- 授权root用户远程访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;
- 创建test用户并授权本地访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'test'@localhost IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;
安全温馨提示:
- 例子中给出的数据库密码(123456)仅为样例,强烈建议设置成复杂密码
- 例子中root用户的远程授权设置会使数据库在所有网络上都可以访问,请按具体的网络拓扑和权限控制情况,设置网络和权限帐号
③ 测试连接和创建数据库
- 创建数据库
mysql > create database webasetransaction;
(1)从下载对应版本的安装包,并解压到相应目录
mkdir /software
tar -zxvf zookeeper-XXX.tar.gz /software/
(2)配置和启动
ZooKeeper的安装包括单机模式安装,以及集群模式安装。具体步骤请参考官网说明:
2.1 脚本没权限
赋权限:chmod + *.sh
转格式:dos2unix *.sh
“gradle build -x test”失败,不能编译Lombok注解:
...
/data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/trans/TransService.java:175: error: cannot find symbol
^
symbol: variable log
location: class TransService
/data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/trans/TransService.java:183: error: cannot find symbol
log.warn("call fail. contractAddress:{} abi is not exists", contractAddress);
^
symbol: variable log
location: class TransService
Note: /data/trans/webase-transcation/src/main/java/com/webank/webase/transaction/util/ContractAbiUtil.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors
FAILURE: Build failed with an exception.
...
答: 修改 build.gradle文件,将以下代码的注释去掉
//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网站自行下载。
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