阿里云Fabric1order1peer部署步骤
1.Fabric官方提供了专门编译cryptogen的入口,只需要运行以下命令即可:cd ~/go/src/github.com/hyperledger/fabricmake cryptogen 运行后系统返回结果:build/bin/cryptogen CGO_CFLAGS=" " GOBIN=/home/studyzy/go/src/github.com/hyperledger/fabric/build/bin go install -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/cryptogen/metadata.Version=1.1.0" github.com/hyperledger/fabric/common/tools/cryptogen Binary available as build/bin/cryptogen 也就是说在build/bin文件夹下可以看到编译出来的cryptogen程序。然后复制bin 文件。 2.在github.com/hyperledger/创建新的文件夹,粘贴bin文件到该目录下并在这个文件夹下创建三个文件夹chaincode(存放智能合约),config(配置文件)crypto-config(order和peer证书配置文件)。 3.复制下面四个文件,根据需求修改里面的信息configtx.yamlcrypto-config.yaml,docker-compose-order.yaml,docker-compose-peer.yaml 4.然后进行下面的操作 4.1生成证书./bin/cryptogen generate --config=./crypto-config.yaml 4.2生成创世区块./bin/configtxgen -profile TwoOrgOrdererGenesis -outputBlock ./config/genesis.block 4.3查看创世块./bin/configtxgen -inspectBlock ./config/genesis.block 4.4生成通道凭证./bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./config/mychannel.tx -channelID mychannel 4.5启动order节点和peer节点 docker-compose -f docker-compose-order.yaml up -d docker-compose -f docker-compose-peer.yaml up -d 4.6查看启动的镜像命令如下docker ps -a 5.进入cli容器命令docker exec -it cli bash 6.创建一个channelpeer channel create -o orderer.example.com:7050 -c mychannel -t 50 -f ./channel-artifacts/mychannel.tx 7.创建完channel后,需要通过mychannel.block文件来加入该channel,以便后续可以安装实例化并测试智能合约。具体命令如下peer channel join -b mychannel.block 8.安装智能合约peer chaincode install -n mychannel -p github.com/hyperledger/fabric/chaincode/go/chaincode_example02 -v 1.0 9.实例化智能合约peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mychannel -c '{"Args":["init","A","100","B","150"]}' -P "OR ('Org1MSP.member','Org2MSP.member')" -v 1.0 10.查询合约命令peer chaincode query -C mychannel -n mychannel -c '{"Args":["query","A"]}' 11.根据合约内容,让A给B转5快钱,执行如下命令peer chaincode invoke -C mychannel -n mychannel -c '{"Args":["invoke", "A", "B", "20"]}'