1. 基本信息
虚拟机名称:Pure-Ununtu18.04
Blockchain位置:/root/wecross-demo/fabric
证书文件位置:/root/wecross-demo/fabric/fabric-samples-1.4.4/first-network/crypto-config/*
Explorer位置:/root/wecross-demo/fabric/explorer
Caliper位置:/root/caliper-workspace
1.5 VScode 远程连接
- 虚拟机桌面右键 Open Terminal
- ifconfig,根据网卡ens33的地址,修改vscode的远程congfig文件, 账号/密码:toor / root
- 打开远程文件目录 vscode-file-open folder-/root
- 打开远程终端 VScode-Terminal
2. 启动区块链
切换超级用户 su root 密码:root
cd /root/wecross-demo/fabric
bash start.sh up (此操作会导致秘钥名称发生变化,应注意!!!)
3. 部署链码(若已部署则不需要)
cd /root/wecross-demo/fabric
bash deploy_sacc.sh
4. 启动区块链浏览器
- cd /root/wecross-demo/fabric/explorer
- 删除pgdata , crypto和 walletstore文件夹 rm -r pgdata, rm -r walletstore, rm -r crypto
- 创建空crypto文件夹 mkdir crypto
- cp -r /root/wecross-demo/fabric/fabric-samples-1.4.4/first-network/crypto-config/* crypto
- cd /root/wecross-demo/fabric/explorer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore
- 复制此目录下的文件名称xxx_sk,替换/root/wecross-demo/fabric/explorer/connection-profile/test-network.json的32行中的xxx_sk
- cd /root/wecross-demo/fabric/explorer
- 启动区块链浏览器 bash start.sh
- 虚拟机内访问http://localhost:8082/#/login 账号/密码:用户名:exploreradmin 密码:exploreradminpw
5. Caliper性能测试
- cd /root/caliper-workspace
- cd /root/wecross-demo/fabric/explorer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore
- 复制此目录下的文件名称xxx_sk,替换/root/caliper-workspace/networks/networkConfig.json的18行中的xxx_sk
- 在benchmarks目录下的benchmark.yaml,用于定义测试的发送交易总量、以及发送tps, 根据自己服务器配置进行调整。
txNumber :发送交易总量,一般为20
tps:交易发送速率,一般为10 - 根据实验需求,修改CT_load.js中的18行和20行,set方法为写入数据(修改20行中的key, value),get方法为读取数据(20行中只需要key)
- 运行caliper
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/networkConfig.json --caliper-benchconfig benchmarks/benchmark.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
若报错,则
-
清除npm缓存 npm cache clean --force
-
取消ssl验证: npm config set strict-ssl false
-
更换npm下载源
npm config set registry https://registry.npm.taobao.org
npm install -g cnpm --registry=https://registry.npm.taobao.org -
在caliper-workspace路径下,执行以下命令下载依赖包
npm install --only=prod @hyperledger/caliper-cli@0.4.0 --unsafe-perm=true --allow-root
npx caliper bind --caliper-bind-sut fabric:2.1 --unsafe-perm=true --allow-root
6. 实验结束,关机走人。
poweroff