目錄
- 前言
- 系列文章直通車
- 修改configtx.yaml檔案
- 明確檔案資訊
- 修改檔案
- 1、洗掉不必要內容
- 2、真正的修改組態檔
- 結語
前言
上次我們修改了peer-base.yaml檔案,接下來我們還需要修改configx.yaml檔案,這個組態檔是用來創建創世區塊以及通道的組態檔,
系列文章直通車
| 名稱 | 鏈接 |
|---|---|
| 創建自己的區塊鏈網路 一 | 點擊此處 |
| 創建自己的區塊鏈網路 二 | 點擊此處 |
| 創建自己的區塊鏈網路 三 | 點擊此處 |
| 創建自己的區塊鏈網路 四 | 點擊此處 |
| 創建自己的區塊鏈網路 五 | 點擊此處 |
修改configtx.yaml檔案
明確檔案資訊
我們首先需要知道他檔案內容的作用才能去修改它,那么檔案資訊如下:
- Organizations部分指定OrdererOrg與PeerOrg的組織資訊,其核心目的是指定各組織的名稱、唯一ID及MSP的目錄所在路徑,
- Capabilities部分指定通道的權限資訊,
- Application部分指定初始加入通道的組織,
- Orderer部分指定Orderer節點的資訊,
- OrdererType指定共識排序服務的實作方式,目前有兩種選擇(solo及Kafka),
- Addresses指定Orderer節點的服務地址與埠號,
- BatchSize指定與訊息相關的批處理大小,如最大交易數量、最大位元組數及建議位元組數,
- Profiles部分指定了兩個模板:TwoOrgsOrdererGenesis與TwoOrgsChannel,
- TwoOrgsOrdererGenesis模板用來生成Orderer服務的初始區塊檔案,該模板由3部分組成,
- Capabilities:指定通道的權限資訊,
- Orderer:指定Orderer服務的資訊(OrdererOrg)及權限資訊,
- Consortiums:定義聯盟組成成員(Org1、Org2),
- TwoOrgsChannel模板用來生成應用通道交易組態檔,由兩部分組成,
- Consortium:指定聯盟資訊,
- Application:指定組織及權限資訊,
- TwoOrgsOrdererGenesis模板用來生成Orderer服務的初始區塊檔案,該模板由3部分組成,
來源1
那么到這里我們已經明確了此組態檔的作用,還有檔案內容的詳細資訊,那么我們現在就可以取修改還檔案了,
修改檔案
1、洗掉不必要內容
那么我們先來看看官方檔案,
---
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
Writers:
Type: Signature
Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
Admins:
Type: Signature
Rule: "OR('Org1MSP.admin')"
AnchorPeers:
- Host: peer0.org1.example.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
Writers:
Type: Signature
Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
Admins:
Type: Signature
Rule: "OR('Org2MSP.admin')"
AnchorPeers:
- Host: peer0.org2.example.com
Port: 9051
Capabilities:
Channel: &ChannelCapabilities
V1_4_3: true
V1_3: false
V1_1: false
Orderer: &OrdererCapabilities
V1_4_2: true
V1_1: false
Application: &ApplicationCapabilities
V1_4_2: true
V1_3: false
V1_2: false
V1_1: false
Application: &ApplicationDefaults
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ApplicationCapabilities
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.example.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
EtcdRaft:
Consenters:
- Host: orderer.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
- Host: orderer2.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
- Host: orderer3.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
- Host: orderer4.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
- Host: orderer5.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
Channel: &ChannelDefaults
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ChannelCapabilities
Profiles:
TwoOrgsOrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
SampleDevModeKafka:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: kafka
Kafka:
Brokers:
- kafka.example.com:9092
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
SampleMultiNodeEtcdRaft:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: etcdraft
EtcdRaft:
Consenters:
- Host: orderer.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
- Host: orderer2.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
- Host: orderer3.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
- Host: orderer4.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
- Host: orderer5.example.com
Port: 7050
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
Addresses:
- orderer.example.com:7050
- orderer2.example.com:7050
- orderer3.example.com:7050
- orderer4.example.com:7050
- orderer5.example.com:7050
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
是不是很長,我還把注釋給洗掉了,還有這么多,但是我們不需要這么多,
相必大家都看到了TLS加密傳輸我們都不需要,全部刪了,我們只需要如下內容
- Organizations (里面的Policies全部不需要)
- Application/Organizations
- Orderer/OrdererType
- Orderer/Addresses
- Orderer/BatchTimeout
- Orderer/BatchSize
- Profiles/TwoOrgsOrdererGenesis
- Profiles/TwoOrgsChannel
我們只需要這么多內容其它的全部洗掉掉
然后洗掉完后會有爆紅的,我們把他洗掉就行了


這樣就不會爆紅了,那么洗掉完成了我們現在就應該真正的修改它了
2、真正的修改組態檔
那么接下來我們就來真正的修改組態檔,修改完成后是這個樣子的
---
# 1--Ctrl+R 查找example 替換為slzce
# 2--Ctrl+R 查找 org1 替換為 organization1 org2 替換為 organization1 (Organizations內的)
# 3--Ctrl+R 查找peer0 替換為node2 指定的背書節點
# 4-- 我們有三個組織所以需要復制一個 不要忘記修改
# 5-- 修改三個組織的監聽埠為7051
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/slzce.com/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/organization1.slzce.com/msp
AnchorPeers:
- Host: node2.organization1.slzce.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/organization2.slzce.com/msp
AnchorPeers:
- Host: node2.organization2.slzce.com
Port: 7051
- &Org3
Name: Org3MSP
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/organization3.slzce.com/msp
AnchorPeers:
- Host: node2.organization3.slzce.com
Port: 7051
Application: &ApplicationDefaults
Organizations:
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.slzce.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Profiles:
TwoOrgsOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
# 注意這里要加上Org3
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
# 注意這里要加上Org3
那么到這里我們這個檔案就修改完成了,那么下次我們就可以修改docker-compose-base.yaml檔案了,
結語
到這一步距離網路搭建還有一段路程,我們只需要再修改一個yaml檔案就可以撰寫命令來跑通網路了,
創作不易,多多支持,謝謝,

以上表格內容來源于《Hyperledger Fabric 菜鳥進階攻略》 ??
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/272544.html
標籤:區塊鏈
上一篇:vue創建+elementUI
下一篇:數字貨幣合約跟單是怎樣操作的?
