最近又要弄fabric的项目,在sit环境部署时遇到了不少问题。记录一下相关要点。
1.networks问题:
单机部署,所有容器需要在dockerfile定义networks为同一个网络。多机部署,不要求在dockerfile定义networks为同一个网络。
2.CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 配置的问题
如果开启了docker的2375远程服务,CORE_VM_ENDPOINT配置成 http://ip地址:2375
3.- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn 配置问题
${COMPOSE_PROJECT_NAME}的值是通过.env文件传递的,如果不需要,可以把多机的各个dockerfile里改成写死的网络名。
4.configtx.yaml和genesis.block和channel.tx的问题
通过configtx.yaml,使用configtxgen工具可以产生genesis.block和channel.tx。genesis.block是给每个orderer初始化启动时用的,channel.tx是创建通道时使用的。
(1)产生genesis.block使用的configtx.yaml里的profile需要定义使用的共识算法。比如:
SampleMultiNodeEtcdRaft:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: etcdraft
EtcdRaft:
Consenters:
- Host: orderer.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
- Host: orderer2.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
- Host: orderer3.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
Addresses:
- orderer.example.com:7050
- orderer2.example.com:7050
- orderer3.example.com:7050
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
(2)产生channel.tx使用的configtx.yaml里的profile不需要定义使用的共识算法,但需要定义这个通道里有多少个组织。注意这里定义的组织需要和产生genesis.block使用的profile里定义的组织一致。比如:
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
Capabilities:
<<: *ApplicationCapabilities
(5)extra_host配置问题
为了使分布式链网络之间能互相访问,需要配置extra_host对应域名和ip映射关系。每个节点不用配置本机的域名和ip,只需要配置外面需要访问的节点的域名和IP。
当然,还有一种直接的方法就是在各个节点上都配置好hosts配置。vi /etc/hosts
(6)防火墙问题
需要在各个节点开启相应的暴露出去的端口。