在git base中使用以下命令进入到测试网络目录
```
cd $GOPATH/src/github.com/hyperledger/fabric-samples/test-network
ll
```
在test-network目录下有network.sh文件,先运行以下命令以从以前的运行中删除所有容器或进程,以防冲突报错
```
./network.sh down
在test-network目录下
```
接着就可以启用它了
`
./network.sh up
`
成功后
完整的日志
`1. $ ./network.sh up
2. Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.0.0
DOCKER_IMAGE_VERSION=2.0.0
/e/go/src/github.com/hyperledger/fabric-samples/bin/cryptogen
##########################################################
Generate certificates using cryptogen tool
##########################################################
##########################################################
############ Create Org1 Identities ######################
##########################################################
cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
res=0
set +x
##########################################################
############ Create Org2 Identities ######################
##########################################################
cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
res=0
set +x
##########################################################
############ Create Orderer Org Identities ###############
##########################################################
cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
res=0
set +x
Generate CCP files for Org1 and Org2
/e/go/src/github.com/hyperledger/fabric-samples/bin/configtxgen
######### Generating Orderer Genesis block ##############
configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-03-25 21:53:50.247 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-25 21:53:50.423 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 Orderer.Addresses unset, setting to [127.0.0.1:7050]
2020-03-25 21:53:50.423 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: etcdraft
2020-03-25 21:53:50.423 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2020-03-25 21:53:50.423 CST [common.tools.configtxgen.localconfig] Load -> INFO 005 Loaded configuration: E:\go\src\github.com\hyperledger\fabric-samples\test-network\configtx\configtx.yaml
2020-03-25 21:53:50.500 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2020-03-25 21:53:50.505 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
res=0
set +x
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating orderer.example.com ... done
Creating peer0.org2.example.com ... done
Creating peer0.org1.example.com ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fefe3e72e413 hyperledger/fabric-peer:latest "peer node start" 44 seconds ago Up 2 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
992bfeabaf33 hyperledger/fabric-orderer:latest "orderer" 44 seconds ago Up 2 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
6718e53a63b6 hyperledger/fabric-peer:latest "peer node start" 44 seconds ago Up 2 seconds 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
`
根据日志,目前我们已经有了两个组织及对应的peer节点,还有一个orderer排序节点
下面我们在此基础上创建一个名叫“xiaowei”的通道
./network.sh createChannel -c xiaowei
createChannel这个脚本除了创建通道外,还自动把上面创建的三个节点都加到通道里了
有了通道,就可以在上面部署链码了,如果按官方手册直接执行安装操作的话,会报错。原因是国内无法访问golang.org这个官网
我们需要把golang.org/x下面的依赖先手工下载回来。首先在在$GOPATH/src中创建golang.org/x/文件夹,然后进入github上把需要的依赖全部通过git下载回来(go get 也行,只是要多了一步文件迁入到x目录的操作)
如上面的两个
`
1. cd $GOPATH/src/golang.org/x 2. git clone https://github.com/golang/text.git 3. git clone https://github.com/golang/net.git
`
本文由小韦云原创,转载请注明出处:https://www.bctos.cn/doc/4/1802,否则追究其法律责任
有疑问加站长微信联系(非本文作者)