这里将演示一个fabric orderer kafka的多机部署版本。如果想看简化版本: 无kafka,无tls的部署步骤
测试环境:
- 多机环境:1 个 ubuntu18 + 6台centos 7,其中ubuntu作为client机器.在6台机器上,修改/etc/hosts:
192.168.64.136 peer0.org1.ping40.net
192.168.64.225 peer1.org1.ping40.net
192.168.64.243 peer0.org2.ping40.net
192.168.64.249 peer1.org2.ping40.net
192.168.64.213 orderer0.ping40.net
192.168.64.213 orderer1.ping40.net
192.168.64.213 orderer2.ping40.net
192.168.64.69 kafka0.ping40.net
192.168.64.69 kafka1.ping40.net
192.168.64.69 kafka2.ping40.net
192.168.64.69 kafka3.ping40.net
多机环境下,要保证所有机器的时间一样。在 core.yaml, orderer.yaml配置文件要求时间相处不能超过15分钟:
authentication:
# the acceptable difference between the current server time and the
# client's time as specified in a client request message
timewindow: 15m
理论上也可以使用2~6台机器进行测试
- 单机环境:1 个 ubuntu18,/etc/hosts 修改配置:
127.0.0.1 peer0.org1.ping40.net
127.0.0.1 peer1.org1.ping40.net
127.0.0.1 peer0.org2.ping40.net
127.0.0.1 peer1.org2.ping40.net
127.0.0.1 orderer0.ping40.net
127.0.0.1 orderer1.ping40.net
127.0.0.1 orderer2.ping40.net
192.168.64.206 kafka0.ping40.net
192.168.64.206 kafka1.ping40.net
192.168.64.206 kafka2.ping40.net
192.168.64.206 kafka3.ping40.net
kafka的地址不能使用127.0.0.1地址。
- 本测试生成的二进制程序是fabric 1.4.0版本。
commit b2ea980d57b2ff50240049b2feef69adaa44a2e3
测试例子中启用tls
docker环境准备
peer0.org1,peer0.org2的机器需要docker环境和二个镜像:
hyperledger/fabric-baseos:amd64-0.4.14
hyperledger/fabric-ccenv:latest
[root@c243 tmp]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-baseos amd64-0.4.14 75f5fb1a0e0c 4 weeks ago 124MB
hyperledger/fabric-ccenv amd64-1.3.0 953124d80237 5 weeks ago 1.38GB
hyperledger/fabric-ccenv latest 953124d80237 5 weeks ago 1.38GB
[root@c243 tmp]# docker version
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
步骤1:下载脚本
在client机器上下载 https://github.com/ping40/fabric_install.git, 进入到子目录 advance下面:
fabric@me:~$ git clone https://github.com/ping40/fabric_install.git
正克隆到 'fabric_install'...
remote: Enumerating objects: 69, done.
remote: Counting objects: 100% (69/69), done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 69 (delta 41), reused 54 (delta 26), pack-reused 0
展开对象中: 100% (69/69), 完成.
正在检出文件: 100% (35/35), 完成.
fabric@me:~$ cd fabric_install/advance/
fabric@me:~/fabric_install/advance$ pwd
/home/fabric/fabric_install/advance
fabric@me:~/fabric_install/advance$ ls -lh
总用量 96M
-rwxrwxr-x 1 fabric fabric 15K 11月 28 09:08 byfn.sh
-rwxrwxr-x 1 fabric fabric 19M 11月 28 09:08 configtxgen
-rw-rw-r-- 1 fabric fabric 13K 11月 28 09:08 configtx.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 28 09:08 core.yaml
-rw-rw-r-- 1 fabric fabric 3.9K 11月 28 09:08 crypto-config.yaml
-rwxrwxr-x 1 fabric fabric 13M 11月 28 09:08 cryptogen
-rw-rw-r-- 1 fabric fabric 2.3K 11月 28 09:08 kafka-cluster.yaml
-rwxrwxr-x 1 fabric fabric 28M 11月 28 09:08 orderer
-rw-rw-r-- 1 fabric fabric 14K 11月 28 09:08 orderer0.yaml
-rw-rw-r-- 1 fabric fabric 14K 11月 28 09:08 orderer1.yaml
-rw-rw-r-- 1 fabric fabric 14K 11月 28 09:08 orderer2.yaml
-rwxrwxr-x 1 fabric fabric 36M 11月 28 09:08 peer
-rw-rw-r-- 1 fabric fabric 28K 11月 28 09:08 peer0-org1.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 28 09:08 peer0-org2.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 28 09:08 peer1-org1.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 28 09:08 peer1-org2.core.yaml
-rw-rw-r-- 1 fabric fabric 263 11月 28 09:08 README.md
drwxrwxr-x 3 fabric fabric 4.0K 11月 28 09:08 src
下面的所有操作当前目录是:/home/fabric/fabric_install/advance。
client机器上需要安装golang
fabric@me:~/fabric_install$ go version
go version go1.11 linux/amd64
步骤2:部署kafka集群
这次kafka集群是通过 docker-compose单机部署的,是4个kafka节点和3个zookeeper节点
把kafka-cluster.yaml 复制到 机器 192.168.64.69的机器上,修改文件:
KAFKA_ADVERTISED_HOST_NAME: 192.168.3.7
修改为:
KAFKA_ADVERTISED_HOST_NAME: 192.168.64.69
不要把 KAFKA_ADVERTISED_HOST_NAME 修改为:127.0.0.1
2.1.启动kafka集群
[root@c69 fabric]# docker-compose -f kafka-cluster.yaml up
Creating network "fabric_default" with the default driver
Creating fabric_zoo3_1_43abc8b508da ... done
Creating fabric_zoo2_1_689db197ee90 ... done
Creating fabric_zoo1_1_bb11ea040a92 ... done
Creating fabric_kafka2_1_8f10c5c37c26 ... done
2.2.验证kafka集群成功启动
[root@c69 ~]# docker exec -ti d15 bash --> 进入到kafka4容器, d15 要根据实际变化
bash-4.4#
bash-4.4# bash-4.4# cd /opt/kafka --> kafka安装包在 /opt/kafka目录下
bash-4.4# bin/kafka-topics.sh --create --zookeeper zoo1:2181 --replication-factor 1 --partitions 1 --topic test123
Created topic "test123".
bash-4.4# bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test123
>this a message #1 --> 输入消息
>hello , fabric
>^C
bash-4.4#
bash-4.4#
bash-4.4# bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test123 --from-beginning
this a message #1 --> 看到输入消息了,说明kafka部署成功了
hello , fabric
^C
Processed a total of 2 messages
步骤3:生成msp相关文件,genesis block,channel.tx, anchor.tx
fabric@me:~/fabric_install/advance$ ./byfn.sh generate
CURRENTDIR = /home/fabric/fabric_install/advance
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ ./cryptogen generate --config=./crypto-config.yaml
org1.ping40.net
org2.ping40.net
+ res=0
+ set +x
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
+ ./configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/mygenesis.block
2018-11-28 09:31:00.898 CST [common.tools.configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen for output operations is deprecated. Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.
2018-11-28 09:31:00.898 CST [common.tools.configtxgen] main -> INFO 002 Loading configuration
2018-11-28 09:31:00.922 CST [common.tools.configtxgen] doOutputBlock -> INFO 003 Generating genesis block
2018-11-28 09:31:00.922 CST [common.tools.configtxgen] doOutputBlock -> INFO 004 Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ping40channel
2018-11-28 09:31:00.957 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-28 09:31:00.981 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-11-28 09:31:00.982 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for part-a-supply ##########
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ping40channel -asOrg part-a-supply
2018-11-28 09:31:01.015 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-28 09:31:01.037 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-28 09:31:01.037 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for big-tech-company ##########
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ping40channel -asOrg big-tech-company
2018-11-28 09:31:01.070 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-28 09:31:01.093 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-28 09:31:01.093 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
步骤4:为orderer,peer运行准备程序,配置文件
./byfn.sh dispatch
CURRENTDIR = /home/fabric/fabric_install/advance
##########################################################
##### copy files to run-orderer, run-peer0-org1 #########
##### run-peer1-org1, run-peer0-org2,run-peer1-org2######
##########################################################
run-orderer0/
run-orderer0/msp/
run-orderer0/msp/tlscacerts/
run-orderer0/msp/tlscacerts/tlsca.ping40.net-cert.pem
......
fabric@me:~/fabric_install/advance$
4.1:多机环境下程序分发
fabric@me:~/fabric_install/advance$ cd multimachine/
fabric@me:~/fabric_install/advance/multimachine$ ll
总用量 77508
drwxrwxr-x 2 fabric fabric 4096 11月 28 09:33 ./
drwxrwxr-x 13 fabric fabric 4096 11月 28 09:33 ../
-rw-rw-r-- 1 fabric fabric 9750048 11月 28 09:32 run-orderer0.tar.gz
-rw-rw-r-- 1 fabric fabric 9750106 11月 28 09:32 run-orderer1.tar.gz
-rw-rw-r-- 1 fabric fabric 9749994 11月 28 09:32 run-orderer2.tar.gz
-rw-rw-r-- 1 fabric fabric 12522654 11月 28 09:33 run-peer0-org1.tar.gz
-rw-rw-r-- 1 fabric fabric 12523270 11月 28 09:33 run-peer0-org2.tar.gz
-rw-rw-r-- 1 fabric fabric 12522907 11月 28 09:33 run-peer1-org1.tar.gz
-rw-rw-r-- 1 fabric fabric 12522884 11月 28 09:33 run-peer1-org2.tar.gz
把相应的包复制到相应的机器上。
比如把 run-orderer0.tar.gz复制到orderer0.ping40.net节点上。
步骤5: 启动orderer,peer程序
5.1:多机环境下
- 5.1.1: 启动orderer
[root@c213 ~]# cd run-orderer0
[root@c213 run-orderer0]# ll
总用量 28572
drwxr-xr-x. 7 1001 1001 85 11月 28 09:32 msp
-rw-r--r--. 1 1001 1001 12914 11月 28 09:32 mygenesis.block
-rwxrwxr-x. 1 1001 1001 29222600 11月 28 09:32 orderer
-rw-rw-r--. 1 1001 1001 13854 11月 28 09:32 orderer.yaml
drwxr-xr-x. 2 1001 1001 53 11月 28 09:32 tls
......
2018-11-28 18:58:43.870 CST [orderer.common.server] Start -> INFO 007 Starting orderer:
Version: 1.4.0
Commit SHA: b2ea980d5
Go version: go1.11
OS/Arch: linux/amd64
2018-11-28 18:58:43.870 CST [orderer.common.server] Start -> INFO 008 Beginning to serve requests
2018-11-28 18:58:43.871 CST [orderer.consensus.kafka] setupTopicForChannel -> INFO 009 [channel: testchainid] Setting up the topic for this channel...
2018-11-28 18:58:44.042 CST [orderer.consensus.kafka] setupProducerForChannel -> INFO 00a [channel: testchainid] Setting up the producer for this channel...
2018-11-28 18:58:44.050 CST [orderer.consensus.kafka] startThread -> INFO 00b [channel: testchainid] Producer set up successfully
2018-11-28 18:58:44.050 CST [orderer.consensus.kafka] sendConnectMessage -> INFO 00c [channel: testchainid] About to post the CONNECT message...
2018-11-28 18:58:44.554 CST [orderer.consensus.kafka] startThread -> INFO 00d [channel: testchainid] CONNECT message posted successfully
2018-11-28 18:58:44.554 CST [orderer.consensus.kafka] setupParentConsumerForChannel -> INFO 00e [channel: testchainid] Setting up the parent consumer for this channel...
2018-11-28 18:58:44.559 CST [orderer.consensus.kafka] startThread -> INFO 00f [channel: testchainid] Parent consumer set up successfully
2018-11-28 18:58:44.559 CST [orderer.consensus.kafka] setupChannelConsumerForChannel -> INFO 010 [channel: testchainid] Setting up the channel consumer for this channel (start offset: -2)...
2018-11-28 18:58:44.571 CST [orderer.consensus.kafka] startThread -> INFO 011 [channel: testchainid] Channel consumer set up successfully
2018-11-28 18:58:44.571 CST [orderer.consensus.kafka] startThread -> INFO 012 [channel: testchainid] Start phase completed successfully
orderer1,orderer2也类似
- 5.1.2: 启动4个peer节点
[root@c136 run-peer0-org1]# ll
总用量 36124
-rw-rw-r--. 1 1001 1001 28266 11月 28 09:32 core.yaml
drwxr-xr-x. 7 1001 1001 103 11月 28 09:32 msp
-rwxrwxr-x. 1 1001 1001 36961288 11月 28 09:32 peer
drwxr-xr-x. 2 1001 1001 53 11月 28 09:32 tls
[root@c136 run-peer0-org1]# ./peer node start
2018-11-28 10:13:34.635 CST [nodeCmd] serve -> INFO 001 Starting peer:
Version: 1.4.0
Commit SHA: b2ea980d5
Go version: go1.11
OS/Arch: linux/amd64
Chaincode:
Base Image Version: 0.4.14
Base Docker Namespace: hyperledger
Base Docker Label: org.hyperledger.fabric
Docker Namespace: hyperledger
2018-11-28 10:13:34.636 CST [ledgermgmt] initialize -> INFO 002 Initializing ledger mgmt
.....
5.2:单机环境环境下
fabric@me:~/fabric_install/advance$ ll
总用量 97492
......
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:32 run-orderer0/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:32 run-orderer1/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:32 run-orderer2/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:32 run-peer0-org1/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:33 run-peer0-org2/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:33 run-peer1-org1/
drwxrwxr-x 4 fabric fabric 4096 11月 28 09:33 run-peer1-org2/
请到上面7个目录下,启动对应的服务
步骤6: 创建通道
步骤6.1: 创建通道
fabric@me:~/fabric_install/advance$ ./byfn.sh createChannel
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel create -o orderer0.ping40.net:51000 -c ping40channel -f ./channel-artifacts/channel.tx --tls true --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:37:09.030 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:09.043 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:09.049 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:37:09.224 CST [cli.common] readBlock -> INFO 004 Got status: &{SERVICE_UNAVAILABLE}
2018-11-28 10:37:09.230 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2018-11-28 10:37:09.432 CST [cli.common] readBlock -> INFO 006 Got status: &{SERVICE_UNAVAILABLE}
2018-11-28 10:37:09.437 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2018-11-28 10:37:09.639 CST [cli.common] readBlock -> INFO 008 Got status: &{SERVICE_UNAVAILABLE}
2018-11-28 10:37:09.646 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2018-11-28 10:37:09.848 CST [cli.common] readBlock -> INFO 00a Got status: &{SERVICE_UNAVAILABLE}
2018-11-28 10:37:09.854 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2018-11-28 10:37:10.056 CST [cli.common] readBlock -> INFO 00c Got status: &{SERVICE_UNAVAILABLE}
2018-11-28 10:37:10.064 CST [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
2018-11-28 10:37:10.270 CST [cli.common] readBlock -> INFO 00e Received block: 0
===================== Channel 'ping40channel' created =====================
步骤6.2: 四个peer节点加入通道
fabric@me:~/fabric_install/advance$ ./byfn.sh joinChannel
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:37:57.628 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:57.641 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:57.646 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:37:57.905 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer0-org1.ping40.net success to join channel =====================
00 setGlobals 1, 1
02 setGlobals 1, 1
CORE_PEER_ADDRESS: peer1.org1.ping40.net:51110
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer1.org1.ping40.net:51110
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:37:57.954 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:57.969 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:57.975 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:37:58.233 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer1-org1.ping40.net success to join channel =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:37:58.285 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:58.298 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:58.303 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:37:58.610 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer0-org2.ping40.net success to join channel =====================
00 setGlobals 1, 2
CORE_PEER_ADDRESS: peer1.org2.ping40.net:51210
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer1.org2.ping40.net:51210
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:37:58.660 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:58.674 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:37:58.679 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:37:58.973 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer1-org2.ping40.net success to join channel =====================
步骤6.3: 更新锚节点
fabric@me:~/fabric_install/advance$ ./byfn.sh updateAnchor
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel update -o orderer0.ping40.net:51000 -c ping40channel -f channel-artifacts/Org1MSPanchors.tx --tls true --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:39:07.054 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:39:07.068 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:39:07.073 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:39:07.098 CST [channelCmd] update -> INFO 004 Successfully submitted channel update
===================== peer0-org1.ping40.net success to updateAnchor =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer channel update -o orderer0.ping40.net:51000 -c ping40channel -f channel-artifacts/Org2MSPanchors.tx --tls true --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:39:07.142 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:39:07.155 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:39:07.159 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-28 10:39:07.177 CST [channelCmd] update -> INFO 004 Successfully submitted channel update
===================== peer0-org2.ping40.net success to updateAnchor =====================
步骤7: Chaincode的部署和调用
步骤7.1: 部署Chaincode代码
fabric@me:~/fabric_install/advance$ ./byfn.sh installChaincode
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ GOPATH=/home/fabric/fabric_install/advance
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode install -n chaincodeName -v 3.1 -p chaincode/ --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:43:18.018 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:43:18.031 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:43:18.040 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-28 10:43:18.040 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-28 10:43:18.351 CST [chaincodeCmd] install -> INFO 005 Installed remotely response:
===================== peer0-org1.ping40.net success to installChaincode =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ GOPATH=/home/fabric/fabric_install/advance
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode install -n chaincodeName -v 3.1 -p chaincode/ --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:43:18.393 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:43:18.406 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:43:18.417 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-28 10:43:18.417 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-28 10:43:18.614 CST [chaincodeCmd] install -> INFO 005 Installed remotely response:
===================== peer0-org2.ping40.net success to installChaincode =====================
如果client机器没有 golang环境,会有如下错误
Error: error getting chaincode code chaincodeName: : failed with error: "exec: not started"
步骤7.2: 实例化Chaincode代码
fabric@me:~/fabric_install/advance$ ./byfn.sh instantiateChaincode
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode instantiate -o orderer0.ping40.net:51000 -C ping40channel -n chaincodeName -v 3.1 --tls --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem -c '{"Args":["init","a","100","b","200"]}' -P 'OR ('\''Org1MSP.member'\'', '\''Org2MSP.member'\'')' --logging-level=debug
+ res=0
+ set +x
2018-11-28 10:44:23.914 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:44:23.929 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-28 10:44:23.945 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-28 10:44:23.945 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
===================== peer0-org2.ping40.net success to instantiateChaincode =====================
步骤7.3: 通过Chaincode写入数据
fabric@me:~/fabric_install/advance$ ./byfn.sh invokeChaincode
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode invoke -o orderer0.ping40.net:51000 -C ping40channel --tls --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem -n chaincodeName -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2018-11-28 10:45:07.598 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on on channel 'ping40channel' =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode invoke -o orderer0.ping40.net:51000 -C ping40channel --tls --cafile /home/fabric/fabric_install/advance/crypto-config/ordererOrganizations/ping40.net/orderers/orderer0.ping40.net/msp/tlscacerts/tlsca.ping40.net-cert.pem -n chaincodeName -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2018-11-28 10:45:07.693 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on on channel 'ping40channel' =====================
几乎同时触发二个transaction,其中一个会失败的
步骤7.4: 通过Chaincode查询数据
fabric@me:~/fabric_install/advance$ ./byfn.sh queryChaincode
CURRENTDIR = /home/fabric/fabric_install/advance
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/peers/peer0.org1.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org1.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode query -C ping40channel -n chaincodeName -c '{"Args":["query","a"]}'
+ res=0
+ set +x
90
========= Query successful on peer0.org1 on channel 'ping40channel' =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
environment variables: begin
environment variables: end
+ CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/peers/peer0.org2.ping40.net/tls/ca.crt
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/advance/crypto-config/peerOrganizations/org2.ping40.net/users/[email protected]/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode query -C ping40channel -n chaincodeName -c '{"Args":["query","a"]}'
+ res=0
+ set +x
90
========= Query successful on peer0.org2 on channel 'ping40channel' =====================
fabric@me:~/fabric_install/advance$