Set up of Hyperledger fabric on 2 different PCs
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Hyperledger Fabric is a permissioned blockchain platform aimed at enterprises, facilitating robust development frameworks for building blockchain applications. This guide will detail the process of setting up Hyperledger Fabric on two different PCs, focusing on a small network structure that's ideal for development or prototyping purposes.
Prerequisites
Before starting the setup, ensure that both PCs meet the following requirements:
- Operating System: Ubuntu Linux 16.04 or higher (recommended for ease of installation)
- Docker and Docker Compose: Crucial for running the Hyperledger Fabric containers.
- Node.js and npm: Required if using the Fabric SDK for chaincode deployment.
- Git: To clone the necessary repositories.
- cURL: For downloading necessary files.
Step 1: Environment Setup
- Install Docker and Docker Compose: Follow the official installation guides to install Docker and Docker Compose.
- Install Node.js and npm: You can install Node.js and npm via nvm (Node Version Manager) as it allows you to easily switch between node versions.
- Install Git and cURL:
Step 2: Download Fabric Samples, Binaries, and Docker Images Execute the following command to clone the Hyperledger Fabric samples repository and download binaries.
This script downloads all necessary Docker images and binaries for setting up a Fabric network.
Network Setup and Configuration
Step 3: Creating the Network on PC1 (Primary Node)
- Navigate into the Fabric samples directory:
- Start the Network:
This script starts the network, creates a channel named mychannel and deploys a basic chaincode.
Step 4: Setting Up the Secondary Node (PC2)
- Navigate to the Fabric samples directory on PC2.
- Join PC2 to the Existing Network: Execute the network joining script specifying necessary details like the channel name.
Verifying the Setup
Step 5: Chaincode Invocation and Query
- On PC1, invoke the chaincode:
- On PC2, query the chaincode:
If PC2 is able to query the data successfully, it verifies that both nodes are interacting with the same blockchain ledger instance across the network.
Troubleshooting Common Issues
- Firewall and Network Configuration: Ensure all required ports are open and accessible between the two PCs. Fabric commonly uses ports such as 7050 (Orderer), 7051, and 7052 (Peers).
- Docker and Docker Compose Issues: Check Docker daemon logs and ensure all containers are up and running properly.
Summary Table
| Component | Description | Notes |
| Docker | Container platform utilized by Fabric nodes. | Ensure correct installation version |
| Node.js and npm | Used for running JavaScript-based chaincode and SDK. | Use compatible version with Fabric |
| Network Setup | Involves starting a network, creating a channel, and joining it. | Proper scripts execution is crucial |
| Chaincode | Smart contracts running on the network. | Ensure proper deployment and testing |
Conclusion
Setting up Hyperledger Fabric on multiple PCs involves careful synchronization and understanding of blockchain network fundamentals. With the primary node hosting the network and secondary nodes joining it, you can effectively simulate a distributed enterprise environment. This setup is instrumental for development, testing, and scaling of blockchain applications in a controlled environment.

