0
votes

I can run the Hyperledger Fabric 1.0 "first network" sample fine.

Now I am trying to add CouchDB persistence to this sample as described at https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#using-couchdb and https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#a-note-on-data-persistence

I edit the networkUp() function in fabric-samples/first-network/byfn.sh changing the line from:

CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1

to:

CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d 2>&1

I also edit file fabric-samples/first-network/docker-compose-couch.yaml changing block:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    ports:
      - "5984:5984"
    networks:
      - byfn

to:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    ports:
      - "5984:5984"
    networks:
      - byfn
    volumes:
      - /var/hyperledger/couchdb0:/opt/couchdb/data

When I run it with commands:

yes | sudo ./byfn.sh -m generate
yes | sudo ./byfn.sh -m up

Right after it lists 'Channel "mychannel" is created successfully', I get the error:

UTC [grpc] Printf -> DEBU 003 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: Error while dialing dial tcp 172.18.0.8:7051: getsockopt: connection refused"; Reconnecting to {peer0.org1.example.com:7051 <nil>}

Any help greatly appreciated.

Thanks in advance!

2
After the above error line, I lso get: Error getting endorser client channel: PER:404 - Error trying to connect to local peer - Bertrand_Szoghy

2 Answers

0
votes

This issue was not happening on RHEL 7.3, so I updated my CentOS from 7.2 to 7.3 as described at http://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-update-centos-7-07-17-2-to-centos-7-3.html and my issue was resolved.

Change made:

1) Created folder

mkdir /home/vagrant/db0

2) changed in networkUp() of byfn.sh:

#  CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1
CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d 2>&1

3) added last two "volumes:" lines in docker-compose-couchdb.yaml:

 services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    ports:
      - "5984:5984"
    networks:
      - byfn
    volumes:
      - /home/vagrant/db0:/opt/couchdb/data
0
votes

The docker container starts with the user couchdb. So when when you try to share the volume for the data directory, the docker container tries to create this folder and assign ownership to root. So I think the user variable should be left blank in the dockerfile instead of specifying it as couchdb. My environment is RHEL release 7.3 (Maipo). To fix this I started the container with the following commands and specified the user as root

docker run --rm -itd --name couchdb0 --user root \
--publish 5984:5984 \
--volume /var/hyperledger/couchdb0:/opt/couchdb/data \
hyperledger/fabric-couchdb:x86_64-1.0.0