Sibaprasad Maiti
Sibaprasad Maiti

Reputation: 557

Add data persistence in hyperledger fabric

I have built a hyperledger fabric network. The below is the configuration right now in my docker-compose.yaml file.

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    image: hyperledger/fabric-peer:latest
    environment:
      - GODEBUG=netdns=go
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_example
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    volumes:
      - /var/run/:/host/var/run/
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer0.org1.example.com:/var/hyperledger/production
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 7051:7051
      - 7053:7053
    depends_on:
      - couchdb0
    networks:
      - example

  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - "5984:5984"
    networks:
      - example

I have missed on adding the configuration for data persistence. I am following this documentation link to add data persistence. So after I add below line in fabric-couchdb it will use the host machine's specified file system for storing data.

volumes:
 - /var/hyperledger/couchdb0:/opt/couchdb/data

But the thing that I am not able to figure out is how do we retrieve the current data that is present in the network now. Where does fabric-couchdb stores data by default? Can we not copy the old data from default folder location to new folder location?

Upvotes: 0

Views: 408

Answers (1)

kekomal
kekomal

Reputation: 2200

If you define the CouchDB volume as you say, your host folder should be in /var/hyperledger/couchdb0.

You can always run docker volume ls and docker volume inspect your_volume_name to check the mount point of your volumes.

If you have not defined volumes for your container and you want to retrieve the folder (I think that's your problem), then try:

docker cp couchdb0:/opt/couchdb/data your-host-destination-folder

Upvotes: 1

Related Questions