Centos7 HyperLedger Fabric 1.4 生产环境部署

Alanni ·
更新时间:2024-09-20
· 709 次阅读

Centos7 HyperLedger Fabric 1.4 生产环境部署

 Kafka生产环境部署案例采用三个排序(orderer)服务、四个kafka、三个zookeeper和四个节点(peer)组成,共准备八台服务器,每台服务器对应的服务如下所示:

kafka案例网络拓扑图如下:

一、基本环境搭建:关闭防火墙(或开放端口)、selinux、安装配置docker(17.06.2-ce or later)、docker-compose(1.14.0 or later)、git、go(version 1.11.x)、域名ip映射(/etc/hosts)

二、fabirc编译安装

1. 创建目录(GOPATH变量在安装go的时候就配置好了)

1

mkdir -p $GOPATH/src/github.com/hyperledger

2. 下载fabric源码

进入上述目录后,下载源码

1

git clone https://github.com/hyperledger/fabric.git

3. 安装相关依赖软件

1

go get github.com/golang/protobuf/protoc-gen-go

ps:go get下载的文件会自动存放到$GOBIN对应的目录中,如果没有设置GOBIN,则会存放到$GOPATH/bin下面

创建目录

1

mkdir -p $GOPATH/src/github.com/hyperledger/fabric/.build/docker/gotools/bin

注意:build前有一个点“.”,遗漏的话会导致在make docker时出现找不到protoc-gen-go的错误 

将下载的文件复制到上一步创建的目录下

1

cp $GOPATH/bin/protoc-gen-go $GOPATH/src/github.com/hyperledger/fabric/.build/docker/gotools/bin

4. 编译fabric模块

首先进入fabric安装目录

然后执行make release,如果出现以下错误,则说明没有安装gcc,需要先安装gcc:yum install gcc

1

2

3

4

5

6

7

[root@master1 fabric]# make release

Building release/linux-amd64/bin/configtxgen for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxgen/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/common/tools/configtxgen

# runtime/cgo

exec: "gcc": executable file not found in $PATH

make: *** [release/linux-amd64/bin/configtxgen] 错误 2

make release的正确过程:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

[root@master1 fabric]# make release

Building release/linux-amd64/bin/configtxgen for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxgen/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/common/tools/configtxgen

Building release/linux-amd64/bin/cryptogen for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/cryptogen -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/cryptogen/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/common/tools/cryptogen

Building release/linux-amd64/bin/idemixgen for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/idemixgen -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/idemixgen/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/common/tools/idemixgen

Building release/linux-amd64/bin/discover for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/discover -tags "" -ldflags "-X github.com/hyperledger/fabric/cmd/discover/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/cmd/discover

Building release/linux-amd64/bin/configtxlator for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxlator -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxlator/metadata.CommitSHA=e91c57c" github.com/hyperledger/fabric/common/tools/configtxlator

Building release/linux-amd64/bin/peer for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/peer -tags "" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.4.1 -X github.com/hyperledger/fabric/common/metadata.CommitSHA=e91c57c -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.4.14 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/peer

Building release/linux-amd64/bin/orderer for linux-amd64

mkdir -p release/linux-amd64/bin

CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/orderer -tags "" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.4.1 -X github.com/hyperledger/fabric/common/metadata.CommitSHA=e91c57c -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.4.14 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/orderer

mkdir -p release/linux-amd64/bin

make release之后再执行make docker,出现:

1

2

3

4

Successfully built f45ddffeb1be

Successfully tagged hyperledger/fabric-tools:latest

docker tag hyperledger/fabric-tools hyperledger/fabric-tools:amd64-1.4.0-snapshot-

docker tag hyperledger/fabric-tools hyperledger/fabric-tools:amd64-latest

代表编译成功,make docker需要下载父镜像、构建新镜像,所以这步需要等待些许时间,另外在make docker时会一直报错,然后每次报错重新执行make docker命令就好,直到出现上面的编译成功标识。

上述make release和make docker操作完成后,会自动将编译好的二进制文件存放在以下路径中:

1

$GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin

具体内容如下:

 

5. fabric模块的安装

编译完之后,这些模块就可以被运行了,但目前只能在编译文件所在的文件夹中运行这些模块,非常不方便。为了在系统的任何路径下都能运行,需要通过下面的命令将这些模块的可执行文件复制到系统目录中:

1

cp $GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin/* /usr/local/bin/

6. fabric模块安装结果检查
peer模块 

orderer模块

cryptogen模块

configtxgen模块

configtxlator模块

如果全都显示正确,则说明fabric安装成功了!

三、HyperLedger Fabric 1.4 生产环境配置(没有启用tls)

1、服务器(10.20.31.174)部署配置

1) 创建kafkapeer目录

1

2

3

cd $GOPATH/src/github.com/hyperledger/fabric

mkdir kafkapeer

cd kafkapeer

2) 准备生成证书和区块配置文件

配置crypto-config.yaml和configtx.yaml文件

crypto-config.yaml

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#

# ---------------------------------------------------------------------------

# "OrdererOrgs" - Definition of organizations managing orderer nodes

# ---------------------------------------------------------------------------

OrdererOrgs:

  # ---------------------------------------------------------------------------

  # Orderer

  # ---------------------------------------------------------------------------

  - Name: Orderer

    Domain: example.com

    CA:

        Country: US

        Province: California

        Locality: San Francisco

    # ---------------------------------------------------------------------------

    # "Specs" - See PeerOrgs below for complete description

    # ---------------------------------------------------------------------------

    Specs:

      - Hostname: orderer0

      - Hostname: orderer1

      - Hostname: orderer2

# ---------------------------------------------------------------------------

# "PeerOrgs" - Definition of organizations managing peer nodes

# ---------------------------------------------------------------------------

PeerOrgs:

  # ---------------------------------------------------------------------------

  # Org1

  # ---------------------------------------------------------------------------

  - Name: Org1

    Domain: org1.example.com

    EnableNodeOUs: true

    CA:

        Country: US

        Province: California

        Locality: San Francisco

    # ---------------------------------------------------------------------------

    # "Specs"

    # ---------------------------------------------------------------------------

    # Uncomment this section to enable the explicit definition of hosts in your

    # configuration.  Most users will want to use Template, below

    #

    # Specs is an array of Spec entries.  Each Spec entry consists of two fields:

    #   - Hostname:   (Required) The desired hostname, sans the domain.

    #   - CommonName: (Optional) Specifies the template or explicit override for

    #                 the CN.  By default, this is the template:

    #

    #                              "{{.Hostname}}.{{.Domain}}"

    #

    #                 which obtains its values from the Spec.Hostname and

    #                 Org.Domain, respectively.

    # ---------------------------------------------------------------------------

    # Specs:

    #   - Hostname: foo # implicitly "foo.org1.example.com"

    #     CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above

    #   - Hostname: bar

    #   - Hostname: baz

    # ---------------------------------------------------------------------------

    # "Template"

    # ---------------------------------------------------------------------------

    # Allows for the definition of 1 or more hosts that are created sequentially

    # from a template. By default, this looks like "peer%d" from 0 to Count-1.

    # You may override the number of nodes (Count), the starting index (Start)

    # or the template used to construct the name (Hostname).

    #

    # Note: Template and Specs are not mutually exclusive.  You may define both

    # sections and the aggregate nodes will be created for you.  Take care with

    # name collisions

    # ---------------------------------------------------------------------------

    Template:

      Count: 2

      # Start: 5

      # Hostname: {{.Prefix}}{{.Index}} # default

    # ---------------------------------------------------------------------------

    # "Users"

    # ---------------------------------------------------------------------------

    # Count: The number of user accounts _in addition_ to Admin

    # ---------------------------------------------------------------------------

    Users:

      Count: 1

  # ---------------------------------------------------------------------------

  # Org2: See "Org1" for full specification

  # ---------------------------------------------------------------------------

  - Name: Org2

    Domain: org2.example.com

    EnableNodeOUs: true

    CA:

        Country: US

        Province: California

        Locality: San Francisco

    Template:

      Count: 2

    Users:

      Count: 1

configtx.yaml

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#

---

################################################################################

#

#   Section: Organizations

#

#   - This section defines the different organizational identities which will

#   be referenced later in the configuration.

#

################################################################################

Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used

    # in production but may be used as a template for other definitions

    - &OrdererOrg

        # DefaultOrg defines the organization which is used in the sampleconfig

        # of the fabric.git development environment

        Name: OrdererOrg

        # ID to load the MSP definition as

        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration

        MSPDir: crypto-config/ordererOrganizations/example.com/msp

        # Policies defines the set of policies at this level of the config tree

        # For organization policies, their canonical path is usually

        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>

        Policies:

            Readers:

                Type: Signature

                Rule: "OR('OrdererMSP.member')"

            Writers:

                Type: Signature

                Rule: "OR('OrdererMSP.member')"

            Admins:

                Type: Signature

                Rule: "OR('OrdererMSP.admin')"

    - &Org1

        # DefaultOrg defines the organization which is used in the sampleconfig

        # of the fabric.git development environment

        Name: Org1MSP

        # ID to load the MSP definition as

        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

        # Policies defines the set of policies at this level of the config tree

        # For organization policies, their canonical path is usually

        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>

        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:

            # AnchorPeers defines the location of peers which can be used

            # for cross org gossip communication.  Note, this value is only

            # encoded in the genesis block in the Application section context

            - Host: peer0.org1.example.com

              Port: 7051

    - &Org2

        # DefaultOrg defines the organization which is used in the sampleconfig

        # of the fabric.git development environment

        Name: Org2MSP

        # ID to load the MSP definition as

        ID: Org2MSP

        MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

        # Policies defines the set of policies at this level of the config tree

        # For organization policies, their canonical path is usually

        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>

        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:

            # AnchorPeers defines the location of peers which can be used

            # for cross org gossip communication.  Note, this value is only

            # encoded in the genesis block in the Application section context

            - Host: peer0.org2.example.com

              Port: 7051

################################################################################

#

#   SECTION: Capabilities

#

#   - This section defines the capabilities of fabric network. This is a new

#   concept as of v1.1.0 and should not be utilized in mixed networks with

#   v1.0.x peers and orderers.  Capabilities define features which must be

#   present in a fabric binary for that binary to safely participate in the

#   fabric network.  For instance, if a new MSP type is added, newer binaries

#   might recognize and validate the signatures from this type, while older

#   binaries without this support would be unable to validate those

#   transactions.  This could lead to different versions of the fabric binaries

#   having different world states.  Instead, defining a capability for a channel

#   informs those binaries without this capability that they must cease

#   processing transactions until they have been upgraded.  For v1.0.x if any

#   capabilities are defined (including a map with all capabilities turned off)

#   then the v1.0.x peer will deliberately crash.

#

################################################################################

Capabilities:

    # Channel capabilities apply to both the orderers and the peers and must be

    # supported by both.  Set the value of the capability to true to require it.

    Global: &ChannelCapabilities

        # V1.1 for Global is a catchall flag for behavior which has been

        # determined to be desired for all orderers and peers running v1.0.x,

        # but the modification of which would cause incompatibilities.  Users

        # should leave this flag set to true.

        V1_1: true

    # Orderer capabilities apply only to the orderers, and may be safely

    # manipulated without concern for upgrading peers.  Set the value of the

    # capability to true to require it.

    Orderer: &OrdererCapabilities

        # V1.1 for Order is a catchall flag for behavior which has been

        # determined to be desired for all orderers running v1.0.x, but the

        # modification of which  would cause incompatibilities.  Users should

        # leave this flag set to true.

        V1_1: true

    # Application capabilities apply only to the peer network, and may be safely

    # manipulated without concern for upgrading orderers.  Set the value of the

    # capability to true to require it.

    Application: &ApplicationCapabilities

        # V1.1 for Application is a catchall flag for behavior which has been

        # determined to be desired for all peers running v1.0.x, but the

        # modification of which would cause incompatibilities.  Users should

        # leave this flag set to true.

        V1_2: true

################################################################################

#

#   SECTION: Application

#

#   - This section defines the values to encode into a config transaction or

#   genesis block for application related parameters

#

################################################################################

Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on

    # the application side of the network

    Organizations:

    # Policies defines the set of policies at this level of the config tree

    # For Application policies, their canonical path is

    #   /Channel/Application/<PolicyName>

    Policies:

        Readers:

            Type: ImplicitMeta

            Rule: "ANY Readers"

        Writers:

            Type: ImplicitMeta

            Rule: "ANY Writers"

        Admins:

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

    # Capabilities describes the application level capabilities, see the

    # dedicated Capabilities section elsewhere in this file for a full

    # description

    Capabilities:

        <<: *ApplicationCapabilities

################################################################################

#

#   SECTION: Orderer

#

#   - This section defines the values to encode into a config transaction or

#   genesis block for orderer related parameters

#

################################################################################

Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start

    # Available types are "solo" and "kafka"

    OrdererType: kafka

    Addresses:

        - orderer0.example.com:7050

        - orderer1.example.com:7050

        - orderer2.example.com:7050

    # Batch Timeout: The amount of time to wait before creating a batch

    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block

    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch

        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for

        # the serialized messages in a batch.

        AbsoluteMaxBytes: 98 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for

        # the serialized messages in a batch. A message larger than the preferred

        # max bytes will result in a batch larger than preferred max bytes.

        PreferredMaxBytes: 512 KB

    Kafka:

        # Brokers: A list of Kafka brokers to which the orderer connects. Edit

        # this list to identify the brokers of the ordering service.

        # NOTE: Use IP:port notation.

        Brokers:

            - kafka0:9092

            - kafka1:9092

            - kafka2:9092

            - kafka3:9092

    # Organizations is the list of orgs which are defined as participants on

    # the orderer side of the network

    Organizations:

    # Policies defines the set of policies at this level of the config tree

    # For Orderer policies, their canonical path is

    #   /Channel/Orderer/<PolicyName>

    Policies:

        Readers:

            Type: ImplicitMeta

            Rule: "ANY Readers"

        Writers:

            Type: ImplicitMeta

            Rule: "ANY Writers"

        Admins:

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

        # BlockValidation specifies what signatures must be included in the block

        # from the orderer for the peer to validate it.

        BlockValidation:

            Type: ImplicitMeta

            Rule: "ANY Writers"

    # Capabilities describes the orderer level capabilities, see the

    # dedicated Capabilities section elsewhere in this file for a full

    # description

    Capabilities:

        <<: *OrdererCapabilities

################################################################################

#

#   CHANNEL

#

#   This section defines the values to encode into a config transaction or

#   genesis block for channel related parameters.

#

################################################################################

Channel: &ChannelDefaults

    # Policies defines the set of policies at this level of the config tree

    # For Channel policies, their canonical path is

    #   /Channel/<PolicyName>

    Policies:

        # Who may invoke the 'Deliver' API

        Readers:

            Type: ImplicitMeta

            Rule: "ANY Readers"

        # Who may invoke the 'Broadcast' API

        Writers:

            Type: ImplicitMeta

            Rule: "ANY Writers"

        # By default, who may modify elements at this config level

        Admins:

            Type: ImplicitMeta

            Rule: "MAJORITY Admins"

    # Capabilities describes the channel level capabilities, see the

    # dedicated Capabilities section elsewhere in this file for a full

    # description

    Capabilities:

        <<: *ChannelCapabilities

################################################################################

#

#   Profile

#

#   - Different configuration profiles may be encoded here to be specified

#   as parameters to the configtxgen tool

#

################################################################################

Profiles:

    TwoOrgsOrdererGenesis:

        <<: *ChannelDefaults

        Orderer:

            <<: *OrdererDefaults

            Organizations:

                - *OrdererOrg

        Consortiums:

            SampleConsortium:

                Organizations:

                    - *Org1

                    - *Org2

    TwoOrgsChannel:

        Consortium: SampleConsortium

        Application:

            <<: *ApplicationDefaults

            Organizations:

                - *Org1

                - *Org2

3) 生成公私钥和证书

cryptogen generate --config=./crypto-config.yaml

生成的文件都保存到crypto-config文件夹,我们可以进入该文件夹查看生成了哪些文件:tree crypto-config

4) 生成创世区块

mkdir channel-artifacts configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

5) 生成通道配置区块

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel

另外关于锚节点的更新,我们也需要使用这个程序来生成文件:

1

2

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP

最终,我们在channel-artifacts文件夹中,应该是能够看到4个文件。

6) 拷贝生成文件到其它7台服务器

1

2

3

4

5

6

7

8

# cd ..

# scp -r kafkapeer root@10.20.31.175:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.176:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.128:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.126:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.127:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.131:/opt/gopath/src/github.com/hyperledger/fabric

# scp -r kafkapeer root@10.20.31.132:/opt/gopath/src/github.com/hyperledger/fabric

7) 准备zookeeper配置文件
配置docker-compose-zookeeper.yaml文件,拷贝到kafkapeer目录下。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#

version: '2'

services:

  zookeeper0:

    container_name: zookeeper0

    hostname: zookeeper0

    image: hyperledger/fabric-zookeeper

    restart: always

    environment:

      - ZOO_MY_ID=1

      - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2888:3888 server.3=zookeeper2:2888:3888

    ports:

      - 2181:2181

      - 2888:2888

      - 3888:3888

    extra_hosts:

      - "zookeeper0:10.20.31.174"

      - "zookeeper1:10.20.31.175"

      - "zookeeper2:10.20.31.176"

      - "kafka0:10.20.31.174"

      - "kafka1:10.20.31.175"

      - "kafka2:10.20.31.176"

      - "kafka3:10.20.31.128"

8)准备kafka配置文件
配置docker-compose-kafka.yaml文件,拷贝到kafkapeer目录下。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#

version: '2'

services:

  kafka0:

    container_name: kafka0

    hostname: kafka0

    image: hyperledger/fabric-kafka

    restart: always

    environment:

      - KAFKA_MESSAGE_MAX_BYTES=103809024 # 99 * 1024 * 1024 B

      - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 # 99 * 1024 * 1024 B

      - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false

    environment:

      - KAFKA_BROKER_ID=1

      - KAFKA_MIN_INSYNC_REPLICAS=2

      - KAFKA_DEFAULT_REPLICATION_FACTOR=3

      - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2181,zookeeper2:2181

    volumes:

      - /var/hyperledger/kafka/kafka-logs:/tmp/kafka-logs

    ports:

      - 9092:9092

    extra_hosts:

      - "zookeeper0:10.20.31.174"

      - "zookeeper1:10.20.31.175"

      - "zookeeper2:10.20.31.176"

      - "kafka0:10.20.31.174"

      - "kafka1:10.20.31.175"

      - "kafka2:10.20.31.176"

      - "kafka3:10.20.31.128"

9) 准备orderer配置文件
配置docker-compose-orderer.yaml文件,拷贝到kafkapeer目录下。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#

version: '2'

services:

  orderer0.example.com:

    container_name: orderer0.example.com

    image: hyperledger/fabric-orderer

    environment:

      - ORDERER_GENERAL_LOGLEVEL=debug

      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0

      - ORDERER_GENERAL_GENESISMETHOD=file

      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block

      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP

      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp

      # enabled TLS

      - ORDERER_GENERAL_TLS_ENABLED=false

      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key

      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt

      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]

      - ORDERER_KAFKA_RETRY_LONGINTERVAL=10s

      - ORDERER_KAFKA_RETRY_LONGTOTAL=100s

      - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s

      - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s

      - ORDERER_KAFKA_VERBOSE=true

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: orderer

    volumes:

      - /var/hyperledger/order_data/:/var/hyperledger/production/

      - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block

      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp:/var/hyperledger/orderer/msp

      - ./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/tls/:/var/hyperledger/orderer/tls

    ports:

      - 7050:7050

    extra_hosts:

     - "kafka0:10.20.31.174"

     - "kafka1:10.20.31.175"

     - "kafka2:10.20.31.176"

     - "kafka3:10.20.31.128"

2、服务器(10.20.31.175)部署配置

1) 准备zookeeper配置文件
配置docker-compose-zookeeper.yaml文件,拷贝到kafkapeer目录下。

+ View Code

2) 准备kafka配置文件
配置docker-compose-kafka.yaml文件,拷贝到kafkapeer目录下。

+ View Code

3) 准备orderer配置文件
配置docker-compose-orderer.yaml文件,拷贝到kafkapeer目录下。

+ View Code

3、服务器(10.20.31.176)部署配置

1) 准备zookeeper配置文件
配置docker-compose-zookeeper.yaml文件,拷贝到kafkapeer目录下。

+ View Code

2) 准备kafka配置文件
配置docker-compose-kafka.yaml文件,拷贝到kafkapeer目录下。

+ View Code

3) 准备orderer配置文件
配置docker-compose-orderer.yaml文件,拷贝到kafkapeer目录下。

+ View Code

4、服务器(10.20.31.128)部署配置

1) 准备kafka配置文件

配置docker-compose-kafka.yaml文件,拷贝到kafkapeer目录下。

+ View Code

5、服务器(10.20.31.126)部署配置

1) 准备peer配置文件
配置docker-compose-peer.yaml文件,拷贝到kafkapeer目录下。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39



环境 hyperledger 生产环境 fabric centos

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章