将对等方添加到Fabcar网络-Hyperledger Fabric

时间:2018-06-27 09:27:56

标签: hyperledger-fabric hyperledger ibm-blockchain

我试图将fabcar网络扩展到在同一系统上运行的2个对等节点。我遇到了一些错误。

我对docker compose文件进行了以下更改。

  peer1.org1.example.com:
  container_name: peer1.org1.example.com
  image: hyperledger/fabric-peer
  environment:
    - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
    - CORE_PEER_ID=peer1.org1.example.com
    - CORE_LOGGING_PEER=debug
    - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
    - CORE_PEER_LOCALMSPID=Org1MSP
    - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
    - CORE_PEER_ADDRESS=peer1.org1.example.com:7051
    # # the following setting starts chaincode containers on the same
    # # bridge network as the peers
    # # https://docs.docker.com/compose/networking/
    - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
    - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
    - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
    # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
    # provide the credentials for ledger to connect to CouchDB.  The username and password must
    # match the username and password set for the associated CouchDB.
    - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
    - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
  working_dir: /opt/gopath/src/github.com/hyperledger/fabric
  command: peer node start
  # command: peer node start --peer-chaincodedev=true
  ports:
    - 8051:7051
    - 8053:7053
  volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/msp/peer
      - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
      - ./config:/etc/hyperledger/configtx
  depends_on:
    - orderer.example.com
    - couchdb1
  networks:
    - basic

couchdb1:
container_name: couchdb1
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
  - COUCHDB_USER=
  - COUCHDB_PASSWORD=
ports:
  - 6984:5984
networks:
  - basic

在start.sh文件中,我添加了一行代码以将对等1加入通道。

当执行./startFabric.sh节点时,出现以下错误:

  

来自守护程序的错误响应,容器未运行。

日志如下:

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                     PORTS                                            NAMES

b602e1898831        hyperledger/fabric-peer      "peer node start"        3 minutes ago       Exited (1) 3 minutes ago                                                    peer1.org1.example.com
780acf5be420        hyperledger/fabric-couchdb   "tini -- /docker-ent…"   3 minutes ago       Up 3 minutes               4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp       couchdb1

d93c8d14e07d        hyperledger/fabric-peer      "peer node start"        3 minutes ago       Up 3 minutes               0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com

f8d5a07e0c14        hyperledger/fabric-couchdb   "tini -- /docker-ent…"   3 minutes ago       Up 3 minutes               4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb

0c8be993aaad        hyperledger/fabric-orderer   "orderer"                3 minutes ago       Up 3 minutes               0.0.0.0:7050->7050/tcp                           orderer.example.com

29484423ee69        hyperledger/fabric-ca        "sh -c 'fabric-ca-se…"   3 minutes ago       Exited (1) 3 minutes ago                                                    ca.example.com

Digitals-MacBook-Air-3:fabcar digital3$ docker logs b602e1898831  
2018-06-28 08:12:18.923 UTC [main] main -> ERRO 001 **Cannot run peer because error when setting up MSP of type bccsp from directory /etc/hyperledger/msp/peer/: could not load a valid signer certificate from directory /etc/hyperledger/msp/peer/signcerts: stat /etc/hyperledger/msp/peer/signcerts: no such file or directory**

我所做的更改是:

  1. 在crypto-config中:将模板计数更改为2。
  2. 在docker-compose中,为peer1添加了另一项服务,数据库为couchdb1。无需更改CLI。
  3. 在start.sh文件中,我写了一行代码将对等点1添加到通道。

在fabcar目录中运行./startFabric.sh节点时,出现上述错误。

我正在基本网络而不是第一个网络中进行编辑。

我刚刚检查了我的证书目录:如下图

CRYPTOCONFIG-PeerOrganisations-Peers-peer0,peer1

Peer0拥有所有证书

Peer1仅具有msp文件夹,而没有tls文件夹。 msp文件夹仅包含admincerts和密钥库

更新

我设法为两个对等方生成了证书,并从fabcar目录成功运行了./startFabric.sh节点命令。但是,当我执行enrollAdmin命令时遇到了一个问题。

  

错误:呼叫注册端点失败,并显示错误[错误:连接ECONNREFUSED 10.228.27.101:7054]       在ClientRequest。 (/用户/digital3/fabric-samples/fabcar/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:883:12)       在emitOne上(events.js:116:13)       在ClientRequest.emit(events.js:211:7)       在Socket.socketErrorListener(_http_client.js:387:9)       在emitOne上(events.js:116:13)       在Socket.emit(events.js:211:7)       在emitErrorNT上(internal / streams / destroy.js:64:8)       在_combinedTickCallback(内部/进程/next_tick.js:138:11)       在process._tickCallback(内部/进程/next_tick.js:180:9)   无法注册管理员:错误:无法注册管理员

您能帮我吗

1 个答案:

答案 0 :(得分:0)

如果要添加其他对等节点,则还需要生成相关的加密材料。

在基本网络目录中crypto-config.yaml文件的第63行上,将Count的值设置为'2',例如:

# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive.  You may define both
# sections and the aggregate nodes will be created for you.  Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
  Count: 2
  # Start: 5
  # Hostname: {{.Prefix}}{{.Index}} # default

这将使cryptogen步骤为组织的两个对等节点生成密钥材料:Org1