1. 环境准备
1.1 安装CentOS7
关于Vmware中安装CentOS7过程及常见问题解决
1.2 安装docker环境
关于Linux中安装Docker说明
1.3 安装go环境
关于Linux中安装go语言说明
2. 安装Fabric
2.1 git clone fabric
下载官方(速度慢)
git clone https://github.com/hyperledger/fabric.git
国内
git clone https://gitee.com/songfuxiang/fabric.git
2.2 下载fabric启动二进制文件
cd .. /fabric/scripts
./bootstrap.sh
下载完成后会有fabric-sample
文件夹
可能会下载失败,多试几次 下载过程中会pull镜像,保证docker是已经启动的systemctl start docker
2.3 启动test-network
2.3.1 network.sh命令
Usage: network.sh [Flags] Modes: up - Bring up Fabric orderer and peer nodes. No channel is created up createChannel - Bring up fabric network with one channel createChannel - Create and join a channel after the network is created deployCC - Deploy a chaincode to a channel (defaults to asset-transfer-basic) down - Bring down the network Flags: Used with network.sh up, network.sh createChannel: -ca
- Use Certificate Authorities to generate network crypto material
-c - Name of channel to create (defaults to “mychannel”)
-s - Peer state database to deploy: goleveldb (default) or couchdb
-r - CLI times out after certain number of attempts (defaults to 5)
-d - CLI delays for a certain number of seconds (defaults to 3)
-verbose - Verbose mode
Used with network.sh deployCC
-c - Name of channel to deploy chaincode to
-ccn - Chaincode name.
-ccl - Programming language of the chaincode to deploy: go, java, javascript, typescript
-ccv - Chaincode version. 1.0 (default), v2, version3.x, etc
-ccs - Chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc
-ccp
- File path to the chaincode.
-ccep - (Optional) Chaincode endorsement policy using signature policy syntax. The default policy requires an endorsement from Org1 and Org2
-cccg - (Optional) File path to private data collections configuration file
-cci - (Optional) Name of chaincode initialization function. When a function is provided, the execution of init will be requested and the function will be invoked.
-h - Print this message
Possible Mode and flag combinations
up -ca -r -d -s -verbose
up createChannel -ca -c -r -d -s -verbose
createChannel -c -r -d -verbose
deployCC -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose
Examples:
network.sh up createChannel -ca -c mychannel -s couchdb
network.sh createChannel -c channelName
network.sh deployCC -ccn basic -ccp …/asset-transfer-basic/chaincode-javascript/ -ccl javascript
network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript
常用命令及参数:
up
启动网络down
关闭网络createChannel
创建通道deployCC
部署链码-ca
启动ca服务c
指定通道名称-s
指定peer节点存储方式
2.3.2 启动网络
./network.sh up
./network.sh up -ca