区块链Hyperledger Fabric Samples 运行入门实战

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wxb880114/article/details/79489892
一、基本资料

1、官方网站

2、git地址

二、实战

下载代码
git clone - b master https : // github . com / hyperledger / fabric - samples . git cd fabric - samples git checkout { TAG }

TAG选择 v1.1.0-rc1
将fabric对应版本的 bootstrap-1.0.0-rc1.sh 拷入fabric-samples


执行脚本
执行结果

生成使用root用户执行,普通用户执行会出现错误
./byfn.sh -m generate

错误
Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
/opt/gopath/src/github.com/hyperledger/fabric/fabric-samples/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4deb2a]

goroutine 1 [running]:
panic(0x6b8d00, 0xc4200120b0)
/opt/go/go1.7.5.linux.amd64/src/runtime/panic.go:500 +0x1a1
github.com/hyperledger/fabric/common/tools/cryptogen/msp.GenerateVerifyingMSP(0xc42001b280, 0x34, 0x0, 0x0, 0xc420011b20, 0x16)
/w/workspace/fabric-binaries-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/msp/generator.go:168 +0x20a
main.generatePeerOrg(0x7042a0, 0xd, 0xc420013580, 0x4, 0xc4200135b0, 0x10, 0x7019fb, 0x2, 0xc420011ac0, 0x13, ...)
/w/workspace/fabric-binaries-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/main.go:405 +0x5f2
main.generate()
/w/workspace/fabric-binaries-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/main.go:263 +0x1ce
main.main()
/w/workspace/fabric-binaries-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/main.go:212 +0x262
Failed to generate certificates...

执行失败
[root@iz2zeivrkckulq2dtidztmz first-network]# ./byfn.sh -m up
Starting with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
Creating network "net_byfn" with the default driver
ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-89b59b41ebbf -j RETURN: iptables: No chain/target/match by that name.
(exit status 1))

使用
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
重新启动docker
service docker start


启动报错

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7efecc215259]

runtime stack:
runtime.throw(0xdd863e, 0x2a)
/opt/go/src/runtime/panic.go:566 +0x95
runtime.sigpanic()
/opt/go/src/runtime/sigpanic_unix.go:12 +0x2cc

goroutine 15 [syscall, locked to thread]:
runtime.cgocall(0xb1b240, 0xc420026df8, 0xc400000000)
/opt/go/src/runtime/cgocall.go:131 +0x110 fp=0xc420026db0 sp=0xc420026d70
net._C2func_getaddrinfo(0x22e8c20, 0x0, 0xc420169e30, 0xc420028290, 0x0, 0x0, 0x0)
??:0 +0x68 fp=0xc420026df8 sp=0xc420026db0
net.cgoLookupIPCNAME(0x7ffc2f6b5a83, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/net/cgo_unix.go:146 +0x37c fp=0xc420026f18 sp=0xc420026df8
net.cgoIPLookup(0xc42037c480, 0x7ffc2f6b5a83, 0x13)
/opt/go/src/net/cgo_unix.go:198 +0x4d fp=0xc420026fa8 sp=0xc420026f18
runtime.goexit()
/opt/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc420026fb0 sp=0xc420026fa8
created by net.cgoLookupIP
/opt/go/src/net/cgo_unix.go:208 +0xb4

goroutine 1 [select]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.DialContext(0x7efecc42b000, 0xc42037c240, 0x7ffc2f6b5a83, 0x18, 0xc420384d20, 0x3, 0x4, 0x0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:434 +0x856
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.Dial(0x7ffc2f6b5a83, 0x18, 0xc420384d20, 0x3, 0x4, 0xc420384d20, 0x2, 0x4)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:319 +0x96
github.com/hyperledger/fabric/peer/common.GetBroadcastClient(0x7ffc2f6b5a83, 0x18, 0x301, 0x7ffc2f6b5adf, 0xa1, 0x380, 0xc42000fe00, 0x126, 0x126)
/opt/gopath/src/github.com/hyperledger/fabric/peer/common/ordererclient.go:66 +0x18f
github.com/hyperledger/fabric/peer/channel.InitCmdFactory.func1(0xc4201692f0, 0xc4201698c0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/channel.go:144 +0x67
github.com/hyperledger/fabric/peer/channel.sendCreateChainTransaction(0xc420320aa0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:164 +0xa7
github.com/hyperledger/fabric/peer/channel.executeCreate(0xc420320aa0, 0xc420320aa0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:178 +0x2f
github.com/hyperledger/fabric/peer/channel.create(0xc4202306c0, 0xc42022d4a0, 0x1, 0xa, 0xc420320aa0, 0xdb23b0, 0x5)
/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:213 +0x45
github.com/hyperledger/fabric/peer/channel.createCmd.func1(0xc4202306c0, 0xc42022d4a0, 0x1, 0xa, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:59 +0x52
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0xc4202306c0, 0xc42022d360, 0xa, 0xa, 0xc4202306c0, 0xc42022d360)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:599 +0x234
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1401d40, 0xf, 0xc420010035, 0x7)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:689 +0x367
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(0x1401d40, 0x7d, 0xc420010035)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:648 +0x2b
main.main()
/opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:118 +0x54e

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/opt/go/src/runtime/asm_amd64.s:2086 +0x1

goroutine 22 [syscall]:
os/signal.signal_recv(0xc4200217a8)
/opt/go/src/runtime/sigqueue.go:116 +0x157
os/signal.loop()
/opt/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
/opt/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 24 [select]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*addrConn).transportMonitor(0xc4200f6fc0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:941 +0x66c
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn.func1(0xc4200f6fc0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:656 +0x1de
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:657 +0x756

goroutine 10 [runnable]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.(*http2Client).reader(0xc42036e000)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:1098
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.newHTTP2Client
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:267 +0xd5e

goroutine 11 [runnable]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.(*http2Client).controller(0xc42036e000)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:1186
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.newHTTP2Client
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:297 +0xea5

goroutine 12 [runnable]:
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.newClientStream.func3(0x141ce40, 0xc42036e000, 0xc4201a7040, 0xc4201586e0, 0xc42000ac00)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/stream.go:249
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc.newClientStream
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/stream.go:269 +0xf12

goroutine 13 [select]:
net.lookupIPContext(0x1418f40, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/net/lookup.go:122 +0x7bc
net.internetAddrList(0x1418f40, 0xc42037c3c0, 0xdb177f, 0x3, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0x0, 0xa, ...)
/opt/go/src/net/ipsock.go:241 +0x5e0
net.resolveAddrList(0x1418f40, 0xc42037c3c0, 0xdb1d7f, 0x4, 0xdb177f, 0x3, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, ...)
/opt/go/src/net/dial.go:179 +0x106
net.(*Dialer).DialContext(0xc42004b4f8, 0x1418f40, 0xc42037c3c0, 0xdb177f, 0x3, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0x0, ...)
/opt/go/src/net/dial.go:329 +0x238
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.dialContext(0x1418f40, 0xc42037c3c0, 0xdb177f, 0x3, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0xc42033c4b0, 0xc420378780)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/go17.go:53 +0xaa
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.DialContext.func1(0x7efecc42b000, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x18, 0x1, 0x0, 0x140a680, 0xc42014ed50)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:341 +0x86
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.newProxyDialer.func1(0x7efecc42b000, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x18, 0x13, 0xc420039701, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/proxy.go:136 +0x143
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.dial(0x7efecc42b000, 0xc42037c3c0, 0xc420373380, 0x7ffc2f6b5a83, 0x18, 0x410a5e, 0xc4200150e0, 0xa0, 0x98)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:135 +0x5a
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.newHTTP2Client(0x7efecc42b000, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0xdbd7a1, 0x11, 0x0, 0x0, ...)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/http2_client.go:173 +0xbf
github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport.NewClientTransport(0x7efecc42b000, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0xdbd7a1, 0x11, 0x0, 0x0, ...)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/transport/transport.go:463 +0xae
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*addrConn).resetTransport(0xc420354540, 0xc420169d00, 0xc420354560, 0xc420039e10)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:876 +0x282
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*ClientConn).resetAddrConn(0xc4203701a0, 0x7ffc2f6b5a83, 0x18, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:630 +0x41e
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.DialContext.func3(0xc42037c2a0, 0xc4203701a0, 0x141ab00, 0xc420028278, 0x7ffc2f6b5a83, 0x18)
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:429 +0x273
created by github.com/hyperledger/fabric/vendor/google.golang.org/grpc.DialContext
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/clientconn.go:433 +0x429

goroutine 14 [select]:
net.cgoLookupIP(0x1418f40, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/net/cgo_unix.go:209 +0x2f5
net.lookupIP(0x1418f40, 0xc42037c3c0, 0x7ffc2f6b5a83, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0)
/opt/go/src/net/lookup_unix.go:70 +0xf9
net.glob..func11(0x1418f40, 0xc42037c3c0, 0xe40da0, 0x7ffc2f6b5a83, 0x13, 0xc4200266c8, 0x7204c9, 0xc420026708, 0xc420026718, 0x455cc0)
/opt/go/src/net/hook.go:19 +0x52
net.lookupIPContext.func1(0xc4203701a0, 0x7ffc2f6b5a83, 0x18, 0x0)
/opt/go/src/net/lookup.go:119 +0x5c
internal/singleflight.(*Group).doCall(0x1435e20, 0xc42035ae60, 0x7ffc2f6b5a83, 0x13, 0xc420169da0)
/opt/go/src/internal/singleflight/singleflight.go:93 +0x3c
created by internal/singleflight.(*Group).DoChan
/opt/go/src/internal/singleflight/singleflight.go:86 +0x339
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

export PATH=/opt/gopath/hyperledger/fabric-samples/bin:$PATH

[chain@iz2zeivrkckulq2dtidztmz fabric-samples]$ ./bootstrap.sh
./bootstrap.sh: line 1: opyright: command not found


+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2018-03-06 16:13:51.740 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-06 16:13:51.744 CST [common/configtx/tool/localconfig] Load -> CRIT 002 Error unmarshaling config into struct: 4 error(s) decoding:

* '' has invalid keys: capabilities
* 'Profiles[TwoOrgsChannel].Application' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis]' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis].Orderer' has invalid keys: Capabilities
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2018-03-06 16:13:51.767 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-06 16:13:51.771 CST [common/configtx/tool/localconfig] Load -> CRIT 002 Error unmarshaling config into struct: 4 error(s) decoding:

* '' has invalid keys: capabilities
* 'Profiles[TwoOrgsChannel].Application' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis]' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis].Orderer' has invalid keys: Capabilities
+ set +x

#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2018-03-06 16:13:51.795 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-06 16:13:51.799 CST [common/configtx/tool/localconfig] Load -> CRIT 002 Error unmarshaling config into struct: 4 error(s) decoding:

* '' has invalid keys: capabilities
* 'Profiles[TwoOrgsChannel].Application' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis]' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis].Orderer' has invalid keys: Capabilities
+ set +x

#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2018-03-06 16:13:51.823 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-06 16:13:51.827 CST [common/configtx/tool/localconfig] Load -> CRIT 002 Error unmarshaling config into struct: 4 error(s) decoding:

* '' has invalid keys: capabilities
* 'Profiles[TwoOrgsChannel].Application' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis]' has invalid keys: Capabilities
* 'Profiles[TwoOrgsOrdererGenesis].Orderer' has invalid keys: Capabilities
+ set +x
阿里云服务器,切换到 bootstrap-1.0.0-rc1.sh

清除所有image
docker rmi $(docker images)




欢迎大家一起加入讨论!!!


猜你喜欢

转载自blog.csdn.net/wxb880114/article/details/79489892