愿景
创建的同构多链中维护的账本 创世区块等
使用 couchdb
1 根据configtx.yaml配置文件在网络部署过程中创建的genesis.block就一个
2 每个单独的通道都会有自己的channel初始块,自己账本的开始,独立维护自己通道内账本的数据。
3 在自己创建的多组织上使用ca,每个组织生成自己的fabric-ca数据库
网络部署4个组织 每个组织下两个节点
peer0.org1 端口号:7051
peer1.org1 端口号:8051
peer0.org2 端口号:9051
peer1.org2 端口号:10051
peer0.org3 端口号:11051
peer1.org3 端口号:12051
peer0.org4 端口号:13051
peer1.org4 端口号:14051
需要修改的 文件
在更改的时候需要注意空格的问题 部署时出现问题大多是空格原因
1 crypto-config.yaml文件中 添加新组织配置信息 生成数字证书和密钥
2 configtx.yaml文件中修改 创世区块配置信息、通道配置信息、组织锚节点信息
3修改docker-compose-cli.yaml文件中镜像的启动配置信息
4修改 /base目录下的docker-compose-base.yaml文件,新增节点配置信息
5 修改scripts/utils.sh文件 方便后续在cli端节点的切换
6修改加密文件下crypto-comfig下 (多个组织下的yaml文件)peerOrganizations/org1.example/ca下的 fabric-ca-server-config.yaml文件,添加组织信息,方便后续注册组织用户
按照手动部署byfn.sh 的流程重新部署
1 生成数字证书和加密文件
../bin/cryptogen generate --config=./crypto-config.yaml
2生成创世区块
../bin/configtxgen -profile FourOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
3生成通道配置文件
../bin/configtxgen -profile FourOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
4更新锚节点配置文件
Org1
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
Org2
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
Org3
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel -asOrg Org3MSP
Org4
../bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org4MSPanchors.tx -channelID mychannel -asOrg Org4MSP
5启动docker-compose-cli.yaml
docker-compose -f docker-compose-cli.yaml up -d
1 不启用couchdb 使用默认的leveldb
2 更改docker-compose-cli.yaml文件 启用couchdb
6进入cli端操作
docker exec -it cli bash
根据通道配置文件创建通道
peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
cp mychannel.block ./channel-artifacts
7下载有8个节点 都需要加入通道
执行env | grep CORE
查看当前节点信息
执行source scripts/utils.sh
运行脚本 调用 setGlobals ? ?
切换节点方便所有节点加入通道
peer channel join -b channel-artifacts/mychannel.block
peer0.org1 端口号:7051
peer1.org1 端口号:8051
peer0.org2 端口号:9051
peer1.org2 端口号:10051
peer0.org3 端口号:11051
peer1.org3 端口号:12051
peer0.org4 端口号:13051
peer1.org4 端口号:14051
8 根据锚节点配置文件更新每个组织中的锚节点
org1
peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
org2
peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
org3
peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org3MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
org4
peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org4MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
9安装测试链码 /chaincode/chaincode_example02/go/
在peer0.org1上安装测试
安装链码
指定自己要安装的链码的路径
peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
初始化链码
peer chaincode instantiate -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'OR ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
验证操作
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
3 生成每个组织的CA
1 cd /opt/gopath
创建 bin文件夹 mkdir bin
2安装必要组件 apt install libtool libltdl-dev
3执行 go get -u github.com/hyperledger/fabric-ca/cmd/...
4 验证 fabric-ca-version
修改yaml文件 中每个组织下生成的私钥
version: '2'
networks:
byfn:
services:
ca.org1.example.com:
image: hyperledger/fabric-ca:latest
environment:
- FABRIC_CA_HOME=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca
- FABRIC_CA_SERVER_CA_NAME=ca.org1.example.com
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca/9a454fdc61bf1f94ec132876510cc8d142445d1ebec1649ad73503dc8e5bed96_sk
- FABRIC_CA_SERVER_PORT=7054
ports:
- "7054:7054"
command: sh -c 'fabric-ca-server start --ca.certfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem --ca.keyfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca/9a454fdc61bf1f94ec132876510cc8d142445d1ebec1649ad73503dc8e5bed96_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/ca/:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca
container_name: ca.org1.example.com
networks:
- byfn
ca.org2.example.com:
image: hyperledger/fabric-ca:latest
environment:
- FABRIC_CA_HOME=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca
- FABRIC_CA_SERVER_CA_NAME=ca.org2.example.com
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca/ef8c969014da01bc8b052fe6d27dc92193633fc193ee978c646f823e2af897fe_sk
- FABRIC_CA_SERVER_PORT=8054
ports:
- "8054:8054"
command: sh -c 'fabric-ca-server start --ca.certfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem --ca.keyfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca/ef8c969014da01bc8b052fe6d27dc92193633fc193ee978c646f823e2af897fe_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org2.example.com/ca/:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca
container_name: ca.org2.example.com
networks:
- byfn
ca.org3.example.com:
image: hyperledger/fabric-ca:latest
environment:
- FABRIC_CA_HOME=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca
- FABRIC_CA_SERVER_CA_NAME=ca.org3.example.com
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca/3866204b90ae9ea8897753a30462abea2642254fe72f04441da2195070fc2351_sk
- FABRIC_CA_SERVER_PORT=9054
ports:
- "9054:9054"
command: sh -c 'fabric-ca-server start --ca.certfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem --ca.keyfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca/3866204b90ae9ea8897753a30462abea2642254fe72f04441da2195070fc2351_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org3.example.com/ca/:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/ca
container_name: ca.org3.example.com
networks:
- byfn
ca.org4.example.com:
image: hyperledger/fabric-ca:latest
environment:
- FABRIC_CA_HOME=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca
- FABRIC_CA_SERVER_CA_NAME=ca.org4.example.com
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca/7f10f579b2d9024c42e83cf08f499e1b67525070e531e0dd4edb7b819c9d7e73_sk
- FABRIC_CA_SERVER_PORT=10054
ports:
- "10054:10054"
command: sh -c 'fabric-ca-server start --ca.certfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem --ca.keyfile /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca/7f10f579b2d9024c42e83cf08f499e1b67525070e531e0dd4edb7b819c9d7e73_sk -b admin:adminpw -d'
volumes:
- ./crypto-config/peerOrganizations/org4.example.com/ca/:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/crypto-config/peerOrganizations/org4.example.com/ca
container_name: ca.org4.example.com
networks:
- byfn
帮忙部署ipfs 区块链 联盟链 fabric网络(多共识 多版本 多数据库 ca ) 网络封装接口 区块链浏览器,相关配置文件联系微信 18852897525