centos7下源代码方式安装fabric1.0
生成组织关系和身份证书
cat crypto-config.yaml
OrdererOrgs:
- Name: Orderer
Domain: example.com
Specs:
- Hostname: orderer
PeerOrgs:
- Name: Org1
Domain: org1.example.com
Template:
Count: 2
Users:
Count: 1
- Name: Org2
Domain: org2.example.com
Template:
Count: 2
Users:
Count: 1
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli
cryptogen generate --config=./crypto-config.yaml --output ./crypto-config
yum -y install tree
tree -L 4 crypto-config
对于Orderer节点:需将crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/拷贝至Orderer节点的/etc/hyperledger/fabric下
对于Peer节点:需将crypto-config/peerOrganizations/org1.example.com/拷贝至Peer节点的/etc/hyperledger/fabric下
对于客户端节点:需将crypto-config完整目录拷贝至/etc/hyperledger/fabric下
生成Ordering服务启动初始区块
cat configtx.yaml
Profiles:
TwoOrgsOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/example.com/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
AnchorPeers:
- Host: peer0.org1.example.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.example.com/msp
AnchorPeers:
- Host: peer0.org2.example.com
Port: 7051
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.example.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 98 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
Organizations:
Application: &ApplicationDefaults
Organizations:
该配置文件定义了两个模板:TwoOrgsOrdererGenesis和TwoOrgsChannel,其中TwoOrgsOrdererGenesis用来生成Ordering服务的初始区块文件
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./orderer.genesis.block
所生成的orderer.genesis.block需拷贝至Orderer节点/etc/hyperledger/fabric下
生成新建应用通道的配置交易
CHANNEL_NAME=businesschannel
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./businesschannel.tx -channelID ${CHANNEL_NAME}
所生成的配置交易文件会在后续步骤被客户端使用,因此可放在客户端节点上
生成锚节点配置更新文件
锚节点配置更新文件用于对组织的锚节点进行配置
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./Org1MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./Org2MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org2MSP
所生成的锚节点配置更新文件会在后续步骤中被客户端使用,因此可放在客户端节点上
启动Orderer节点
检查启动节点所有配置是否就绪
/etc/hyperledger/fabric下orderer.yaml(可参考sampleconfig/orderer.yaml)
/etc/hyperledger/fabric下msp和tls目录
/etc/hyperledger/fabric下orderer.genesis.block
启动Orderer节点:orderer start
启动Peer节点
检查启动Peer节点所有配置是否就绪
/etc/hyperledger/fabric下core.yaml(可参考sampleconfig/core.yaml)
/etc/hyperledger/fabric下msp和tls目录
启动Peer节点:peer node start
操作网络(暂未验证)
在客户端进行相关操作
创建通道:peer channel create
通道创建成功后,会自动在本地生成该应用通道同名的初始区块文件,只有拥有该文件才可以加入创建的应用通道中
加入通道:peer channel join
所操作的Peer连接到该应用通道的Ordering服务上,开始接收区块信息
更新锚节点配置:锚节点负责代表组织与其他组织中的节点进行Gossip通信
peer channel update
测试链码:
安装链码:peer chaincode install
链码容器实例化:peer chaincode instantiate
用户调用链码发起交易:peer chaincode invoke
查询链码调用后结果:peer chaincode query
监听事件:block-listener
网友评论