test-network测试网络搭建fabric浏览器

该文指导如何在fabric-sample同级目录下创建crypto-config和edu-explorer文件夹,用于存放证书信息和Docker配置。然后详细说明了编写docker-compose.yaml文件以及config.json文件的过程,这些文件用于设置数据库、网络连接和Fabric网络配置。最后,文章提到了启动docker-compose并访问FabricExplorer的步骤。
摘要由CSDN通过智能技术生成

在fabric-sample文件夹同级目录下创建crypto-config文件夹

将test-network中的peer 和order文件的证书信息拷贝一份到该目录下,

cp -r  fabric-samples/test-network/organizations/peerOrganizations/ fabric-samples/test-network/organizations/ordererOrganizations/ ./crypto-config/

看清路径的对应,和自己的是否一样

在fabric-sample文件夹同级目录下创建edu-explorer文件夹

mkdir edu-explorer

像这样
目录1

进入该目录

cd edu-explorer

编写docker-compose.yaml文件

docker-compose.yaml

version: '2.0'
 
 
volumes:
    pgdata:
    walletstore:

networks:
  mynetwork.com:
    external:
      name: net_test
services:
 
    explorerdb.mynetwork.com:
        image: hyperledger/explorer-db:latest
        container_name: explorerdb.mynetwork.com
        hostname: explorerdb.mynetwork.com
        ports:
            - 5432:5432
        environment:
            - DATABASE_DATABASE=fabricexplorer
            - DATABASE_USERNAME=hppoc
            - DATABASE_PASSWORD=password
        healthcheck:
            test: "pg_isready -h localhost -p 5432 -q -U postgres"
            interval: 30s
            timeout: 10s
            retries: 5
        volumes:
            - pgdata:/var/lib/postgresql/data
 
 
    explorer.mynetwork.com:
        image: hyperledger/explorer:latest
        container_name: explorer.mynetwork.com
        hostname: explorer.mynetwork.com
        ports:
            - 9090:8080
        extra_hosts:
            - "explorerdb.mynetwork.com:xxx.xxx.xxx.xxx"
            - "orderer.example.com:xxx.xxx.xxx.xxx"
            - "peer0.org1.example.com:xxx.xxx.xxx.xxx"
            - "peer0.org2.example.com:xxx.xxx.xxx.xxx"
        environment:
            - DATABASE_HOST=explorerdb.mynetwork.com
            - DATABASE_DATABASE=fabricexplorer
            - DATABASE_USERNAME=hppoc
            - DATABASE_PASSWD=password
            - LOG_LEVEL_APP=debug
            - LOG_LEVEL_DB=info
            - LOG_LEVEL_CONSOLE=debug
            - LOG_CONSOLE_STDOUT=true
            - DISCOVERY_AS_LOCALHOST=false
        volumes:
            - ./config.json:/opt/explorer/app/platform/fabric/config.json
            - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
            - ../crypto-config:/tmp/crypto
            - walletstore:/opt/explorer/wallet
        depends_on:
            explorerdb.mynetwork.com:
                condition: service_healthy

把里面的xxx.xxx.xxx.xxx替换成为你的ip地址

编写config.json

config.json

{
        "network-configs": {
                "prod-network": {
                        "name": "fabric_test",
                        "profile": "./connection-profile/org1ProdNetworkConnection.json"
                }
        },
        "license": "Apache-2.0"
}

创建connection-profile目录

创建org1ProdNetworkConnection.json文件
org1ProdNetworkConnection.json

{
	"name": "test-network",
	"version": "1.0.0",
	"client": {
		"tlsEnable": true,
		"adminCredential": {
			"id": "exploreradmin",
			"password": "exploreradminpw"
		},
		"enableAuthentication": true,
		"organization": "Org1MSP",
		"connection": {
			"timeout": {
				"peer": {
					"endorser": "300"
				},
				"orderer": "300"
			}
		}
	},
	"channels": {
		"mychannel": {
			"peers": {
				"peer0.org1.example.com": {}
			}
		}
	},
	"organizations": {
		"Org1MSP": {
			"mspid": "Org1MSP",
			"adminPrivateKey": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
			},
			"peers": ["peer0.org1.example.com"],
			"signedCert": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
			}
		}
	},
	"peers": {
		"peer0.org1.example.com": {
			"tlsCACerts": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
			},
			"url": "grpcs://xxx.xxx.xxx.xxx:7051"
		}
	}
}

这里的xxx.xxx.xxx.xxx ip也改成你的ip地址,也可以是该节点

保障整体的目录结构如下

edu-explorer/
├── config.json
├── connection-profile
│   └── org1ProdNetworkConnection.json
├── docker-compose.yaml

启动docker-compose文件

docker-compose up -d 

浏览器输入
http://192.168.2.134:9090/#/
换成你自己的ip地址即可
运行截图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱写代码的大狼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值