2.0.0搭建自己的fabric网络

前提是byfn可以运行
之前配置了好多次了,这次记录一下
1.第一步 使用cryptogen为fabric网络产生组织结构和证书
相关的文件是crypt-config.yaml

../bin/cryptogen generate --config=./crypto-config.yaml

终端显示

org1.example.com
org2.example.com

2.我们接下来要告诉configtxgen工具去找这个configtx.yaml文件,让他在当前的工作目录寻找:

export FABRIC_CFG_PATH=$PWD

调用configtxgen来产生创世区块

../bin/configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2020-10-22 18:21:38.472 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-10-22 18:21:38.494 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-10-22 18:21:38.494 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216 
2020-10-22 18:21:38.495 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/li/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-10-22 18:21:38.496 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-10-22 18:21:38.496 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block

3.创建通道交易配置文件

export CHANNEL_NAME=mychannel  && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
2020-10-22 18:24:20.420 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-10-22 18:24:20.443 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/li/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-10-22 18:24:20.443 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-10-22 18:24:20.445 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx

锚节点

../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

4.启动网络

docker-compose -f docker-compose-cli.yaml up -d

5.加入通道
进入容器

docker exec -it cli bash

配置环境变量

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

创建通道

export CHANNEL_NAME=mychannel
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

报错:

Error: got unexpected status: SERVICE_UNAVAILABLE -- no Raft leader

老常规了,以前在做1.4.3这步raft也报错,因为raft需要有2n+1个节点,先把网络down了,我们设置5个orderer节点看看

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值