目錄
-
- 前言
- 系列文章直通車
- 修改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 菜鳥進階攻略》 ↩︎