CouchDB configuration for Hyperledger Fabric 1.2 on Multiple Hosts using Docker Swarm and Compose

Mallikarjun Sarvepalli
2 min readJan 8, 2019

Introduction

This is an update to my previous article Hyperledger Fabric 1.2 on Multiple Hosts using Docker Swarm and Compose, which focused on hosting Hyperledger Fabric 1.2 network on multiple hosts with LevelDB as state database. In this article, I will focus on configuring CouchDB as state database to Fabric 1.2. CouchDB offers richer sets of queries on chain codes and is the preferred database in the production environment.

Topology

I will be extending the topology used in Hyperledger fabric 1.2 to include 4 CouchDB docker containers. Each peer will be configured with one CouchDB container.

1. PC-1

  • Orderer (orderer.example.com) -port 7050

2. PC-2

  • CA1 (ca.org1.example.com) -port 7054
  • Org1 Peer0 (peer0.org1.example.com) -port 7051,8051
  • Org1 Peer1 (peer1.org1.example.com) -port 7053,8053
  • Org1Couchdb0(couchdb0.org1.example.com) — Port 5984
  • Org1Couchdb1(couchdb1.org1.example.com) — port 5986

3. PC-3

  • CA2 (ca.org2.example.com) -port 7054
  • Org2 Peer0 (peer0.org2.example.com) -port 7051,8051
  • Org2 Peer1(peer1.org2.example.com) -port 7053,8053
  • Org2Couchdb0(couchdb0.org2.example.com) — Port 5984
  • Org2Couchdb1 (couchdb1.org2.example.com)— port 5986

Make sure above specified ports are not blocked with firewall. Open 2377,7946,4789 ports for docker swarm.

CouchDB configuration for Existing Hyperledger Fabric 1.2 network

You have an existing Hyperledger Fabric 1.2 network running on multiple hosts using docker swarm and compose installed using link.

  • Go to fabric-samples/fabric-multi-network directory
  • Switch to branch release-1.2 of the repository and pull the updated code
  • Generate CouchDB yaml

./bymn generate -s couchdb -e 1 crypto-config.yaml

This generates docker-compose-org1-couchdb.yaml and docker-compose-org2-couchdb.yaml

  • Launch CouchDB containers and update all peer services

./bymn up -f docker-compose-org1-couchdb.yaml

./bymn up -f docker-compose-org2-couchdb.yaml

This completes the configuration.

CouchDB configuration for new Hyperledger Fabric 1.2 network installation

My article uses levelDB as state database while setting up fabric network. To use CouchDB as state database replace step 4 with.

· ./bymn.sh generate crypto-config.yaml

With

· ./bymn.sh generate crypto-config.yaml -s couchdb

Replace step 9

· ./bymn.sh up -f docker-compose-org1.yaml

With

· ./bymn.sh up -f docker-compose-org1-couchdb.yaml

Replace step 9

· ./bymn.sh up -f docker-compose-org2.yaml

With

· ./bymn.sh up -f docker-compose-org2-couchdb.yaml

Validation

Post successful installation. Try the following urls

http://<pc-2ipadress>:5984/_utils (database of org1 peer0)

http://<pc-2ipadress>:5986/_utils (database of org1 peer1)

http://<pc-3ipadress>:5984/_utils (database of org2 peer0)

http://<pc-2ipadress>:5986/_utils (database of org2 peer1)

user name: couchdb

password: couchdb123

This completes the configuration

--

--