Module 4: Network Setup and Deployment
4.1 Prerequisites and Environment Setup
Before setting up a Hyperledger Fabric network, it's essential to prepare the environment with the necessary prerequisites. This section covers the requirements and setup process for a Fabric development and production environment.
Hardware and Operating System Requirements
Development Environment
For a development environment, the following minimum specifications are recommended:
- CPU: 2 cores / 4 threads
- RAM: 8 GB
- Disk: 50 GB SSD
- Operating System: Ubuntu 20.04/22.04, macOS 10.15+, or Windows 10/11 with WSL2
Production Environment
For a production environment, consider these specifications:
- CPU: 4+ cores / 8+ threads
- RAM: 16+ GB
- Disk: 100+ GB SSD with high IOPS
- Network: 1 Gbps+ with low latency
- Operating System: Ubuntu 20.04/22.04 LTS or Red Hat Enterprise Linux 8+
Cloud Provider Considerations
When deploying in cloud environments:
- Use compute-optimized instances for orderers and peers
- Consider storage-optimized instances for peers with large state databases
- Use managed Kubernetes services for container orchestration
- Implement load balancers for high availability
- Utilize private networks for secure communication
Software Prerequisites
The following software components are required for Hyperledger Fabric:
Core Dependencies
- Docker: Container runtime for Fabric components
- Version 20.10.x or higher
-
Docker Compose V2
-
Go: Programming language for Fabric and chaincode
- Version 1.18.x or higher
-
Required for chaincode development in Go
-
Node.js: For JavaScript/TypeScript chaincode and applications
- Version 16.x or higher
-
npm 8.x or higher
-
Java: For Java chaincode development
- OpenJDK 11 or higher
-
Maven 3.6.x or higher
-
Python: For client applications and scripts
- Version 3.8 or higher
- pip package manager
Additional Tools
- Git: Version control system
-
Version 2.30.x or higher
-
cURL: Command-line tool for data transfer
-
Version 7.68.0 or higher
-
jq: Command-line JSON processor
-
Version 1.6 or higher
-
GNU make: Build automation tool
- Version 4.2.x or higher
Installing Prerequisites on Ubuntu
Here's a step-by-step guide to install prerequisites on Ubuntu 22.04:
# Update package lists
sudo apt update
sudo apt upgrade -y
# Install basic utilities
sudo apt install -y git curl wget jq make
# Install Docker
sudo apt install -y apt-transport-https ca-certificates gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Add user to docker group
sudo usermod -aG docker $USER
newgrp docker
# Install Go
wget https://go.dev/dl/go1.18.10.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz
rm go1.18.10.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.profile
source ~/.profile
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
sudo npm install -g npm@8
# Install Java
sudo apt install -y openjdk-11-jdk maven
# Install Python
sudo apt install -y python3 python3-pip
Installing Hyperledger Fabric Binaries and Docker Images
To install Hyperledger Fabric binaries and Docker images, use the provided script:
# Create a directory for Fabric
mkdir -p ~/fabric
cd ~/fabric
# Download and run the installation script
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.0 1.5.5
# Add Fabric binaries to PATH
echo 'export PATH=$PATH:$HOME/fabric/bin' >> ~/.profile
source ~/.profile
This script downloads:
- Fabric CLI binaries (peer, orderer, configtxgen, etc.)
- Fabric Docker images
- Fabric-CA Docker images
- Fabric samples repository
Setting Up Development Tools
For chaincode and application development, additional tools are helpful:
Visual Studio Code Setup
- Install Visual Studio Code
- Install extensions:
- Go extension
- Node.js extension
- Docker extension
- YAML extension
- IBM Blockchain Platform extension
Go Development Environment
# Install Go tools
go install golang.org/x/tools/gopls@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
Node.js Development Environment
# Install global packages
npm install -g typescript ts-node nodemon
Network Configuration Files
Before setting up a network, you'll need to prepare configuration files:
configtx.yaml
This file defines the network configuration, including: - Organizations - Capabilities - Policies - Channel profiles - Orderer configuration
crypto-config.yaml
This file defines the cryptographic material to be generated: - Organizations - Number of peers per organization - Number of users per organization - CA configuration
docker-compose.yaml
This file defines the Docker containers for: - Orderer nodes - Peer nodes - CA servers - CLI tools
Environment Variables
Set up environment variables for Fabric commands:
# Create a script to set environment variables
cat > ~/fabric/set-env.sh << EOF
#!/bin/bash
# Fabric configuration path
export FABRIC_CFG_PATH=\$HOME/fabric/config
# Peer environment variables
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=\$HOME/fabric/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=\$HOME/fabric/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051
# Orderer environment variables
export ORDERER_CA=\$HOME/fabric/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
EOF
chmod +x ~/fabric/set-env.sh
Troubleshooting Common Setup Issues
Docker Issues
-
Permission denied
bash sudo chmod 666 /var/run/docker.sock -
Docker service not running
bash sudo systemctl start docker -
Insufficient disk space
bash docker system prune -a
Network Issues
- Port conflicts
```bash
# Check for port usage
sudo netstat -tulpn | grep
# Kill process using the port
sudo kill -9
- Firewall blocking connections
bash # Allow Docker traffic sudo ufw allow from 172.16.0.0/12 to any sudo ufw allow from 192.168.0.0/16 to any
Fabric Binary Issues
- Binary not found ```bash # Check PATH echo $PATH
# Verify binary exists ls -la ~/fabric/bin ```
- Wrong version ```bash # Check version peer version
# Reinstall correct version
curl -sSL https://bit.ly/2ysbOFE | bash -s --
By properly setting up your environment with these prerequisites, you'll have a solid foundation for developing and deploying Hyperledger Fabric networks. The next sections will guide you through the process of creating and configuring a Fabric network.