本文节选自电子书《Netkiller Blockchain 手札》
Netkiller Blockchain 手札
Mr. Neo Chan, 陈景峯(BG7NYT)
中国广东省深圳市龙华新区民治街道溪山美地 518131 +86 13113668890 <netkiller@msn.com>
文档始创于2018-02-10
版权 © 2018 Netkiller(Neo Chan). All rights reserved.
版权声明
转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。
内容摘要
这一部关于区块链开发及运维的电子书。
为什么会写区块链电子书?因为2018年是区块链年,区块链是一个风口,前几个风口我都错过了。例如web2.0, 云, 大数据等等,都从身旁擦肩而过。所以我要抓住这次。
这本电子书是否会出版(纸质图书)? 不会,因为互联网技术更迭太快,纸质书籍的内容无法实时更新,一本书动辄百元,很快就成为垃圾,你会发现目前市面的上区块链书籍至少是一年前写的,内容已经过时,很多例子无法正确运行。所以我不会出版,电子书的内容会追逐技术发展,及时跟进软件版本的升级,做到内容最新,至少是主流。
这本电子书与其他区块链书籍有什么不同?市面上大部分区块链书籍都是用2/3去讲区块链原理,只要不到 1/3 的干货,干货不够理论来凑,通篇将理论或是大谈特谈区块链行业,这些内容更多是头脑风暴,展望区块链,均无法落地实施。本书与那些书籍完全不同,不讲理论和原理,面向应用落地,注重例子,均是干货。
写作原则,无法落地的项目作者绝对不会写。凡是写入电子的内容均具备可操作,可落地。
电子书更新频率?每天都会有新内容加入,更新频率最迟不会超过一周,更新内容请关注 https://github.com/netkiller/netkiller.github.io/commits/master
本文采用碎片化写作,原文会不定期更新,请尽量阅读原文 http://www.netkiller.cn/blockchain/index.html
您的打赏是我的写作动力:http://www.netkiller.cn/blockchain/donations.html
接受 ETH 打赏:0x3e827461Cc53ed7c75A29187CfF39629FCAE3661
第 33 章 BaaS (Blockchain as a Service) 平台
目录
33.1. Huawei BCS
华为的 Hyperledger Fabric BaaS 尚处在测试阶段,申请地址是 https://www.huaweicloud.com/product/bcs.html 服务可以免费申请,但是需要
33.1.1. 创建 BCS 服务
打开网址
点击按钮 “立即体验”
点击“购买区块链服务”按钮
共识策略选择 Kafka(CFT), 输入链代码初始管理密码。
这里可以创建通道,也可以略过,后面可以创建。
经过一段时间初始化云主机,最终完成 BCS 创建。
33.1.2. 管理通道
创建通道,输入通道名称和描述,点击确定按钮。
创建好的通道,会显示“暂无节点加入”,点击右边 “加入节点” 连接
选择加入组织的数量
节点添加完毕
33.1.3. 安装链码
首先将 chaincode 源码压缩成 zip 文件
neo@MacBook-Pro ~/chaincode % zip token.zip token.go adding: token.go (deflated 82%) neo@MacBook-Pro ~/chaincode % ls token.*token.go token.zip
点击右边 “链代码管理” 按钮
进入链码管理界面
Organization 选择组织, Peer 选择节点,点击 “Install Chaincode” 按钮。
输入连码名称、版本、并上传 链码对应的 zip 文件。
链码安装成功
实例化链码
输入调用的函数,和传递的参数,点击 OK 按钮
执行成功
33.1.4. 下载 SDK 配置
选择 “下载 SDK 配置”
链代码名称是之前安装链码时输入的名称
链代码版本是当前的链码版本
证书存放根路径填写: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto
点击下载按钮后得到一个 bcs-itetze-sdk-config.zip 文件,解压开 bcs-itetze-sdk-config.yaml
name: "global-trade-network"x-type: "hlfv1"x-loggingLevel: infodescription: "The network to be in if you want to stay in the global trade business"version: 1.0.0client: organization: 266d0f487933503a48f0ab728b85d5b469cb2b79 logging: level: info peer: timeout: connection: 10s queryResponse: 45s executeTxResponse: 120s eventService: timeout: connection: 10s registrationResponse: 50s orderer: timeout: connection: 10s response: 45s cryptoconfig: path: /opt/gopath/src/github.com/hyperledger/fabric credentialStore: path: "/tmp/hfc-kvs" cryptoStore: path: /tmp/msp wallet: wallet-name BCCSP: security: enabled: true default: provider: "SW" hashAlgorithm: "SHA2" softVerify: true ephemeral: false level: 256channels: netkiller: orderers: - orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-0.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local - orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-1.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local - orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-2.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local - orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-3.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local - orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-4.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local peers: peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local: endorsingPeer: true chaincodeQuery: true ledgerQuery: true eventSource: true chaincodes: - netkiller:1.0.0 organizations: 266d0f487933503a48f0ab728b85d5b469cb2b79: mspid: 266d0f487933503a48f0ab728b85d5b469cb2b79MSP cryptoPath: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/266d0f487933503a48f0ab728b85d5b469cb2b79.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local/msp tlsCryptoKeyPath: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/266d0f487933503a48f0ab728b85d5b469cb2b79.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local/tls/server.key tlsCryptoCertPath: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/266d0f487933503a48f0ab728b85d5b469cb2b79.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local/tls/server.crt peers: - peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local certificateAuthorities: - ca-org1 adminPrivateKey: pem: "-----BEGIN PRIVATE KEY-----" signedCert: path: "/tmp/somepath/signed-cert.pem" ordererorg: mspID: "7d8abfe15c3f1389f0468d90e27a382d0bd90b3fMSP" cryptoPath: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp#orderer eip: 49.4.85.126orderers: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-0.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local: url: grpcs://orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-0.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local:30805 grpcOptions: ssl-target-name-override: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-0.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local grpc-max-send-message-length: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp/tlscacerts/tlsca.7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-cert.pem orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-1.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local: url: grpcs://orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-1.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local:30806 grpcOptions: ssl-target-name-override: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-1.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local grpc-max-send-message-length: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp/tlscacerts/tlsca.7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-cert.pem orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-2.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local: url: grpcs://orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-2.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local:30807 grpcOptions: ssl-target-name-override: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-2.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local grpc-max-send-message-length: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp/tlscacerts/tlsca.7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-cert.pem orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-3.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local: url: grpcs://orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-3.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local:30808 grpcOptions: ssl-target-name-override: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-3.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local grpc-max-send-message-length: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp/tlscacerts/tlsca.7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-cert.pem orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-4.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local: url: grpcs://orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-4.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local:30809 grpcOptions: ssl-target-name-override: orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-4.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local grpc-max-send-message-length: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.orderer-7d8abfe15c3f1389f0468d90e27a382d0bd90b3f.default.svc.cluster.local/msp/tlscacerts/tlsca.7d8abfe15c3f1389f0468d90e27a382d0bd90b3f-cert.pem #peer eip: 49.4.85.126peers: peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local: url: grpcs://peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local:30605 eventUrl: grpcs://peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local:30705 grpcOptions: ssl-target-name-override: peer-266d0f487933503a48f0ab728b85d5b469cb2b79-0.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local grpc.http2.keepalive_time: 15 tlsCACerts: path: /opt/gopath/src/github.com/hyperledger/api-server/conf/crypto/266d0f487933503a48f0ab728b85d5b469cb2b79.peer-266d0f487933503a48f0ab728b85d5b469cb2b79.default.svc.cluster.local/msp/tlscacerts/tlsca.266d0f487933503a48f0ab728b85d5b469cb2b79-cert.pem certificateAuthorities: ca-org1: url: https://ca_peerOrg1:7054 httpOptions: verify: true tlsCACerts: path: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/api-server/tls/fabricca/certs/ca_root.pem client: keyfile: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/api-server/tls/fabricca/certs/client/client_fabric_client-key.pem certfile: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/api-server/tls/fabricca/certs/client/client_fabric_client.pem registrar: enrollId: admin enrollSecret: adminpw caName: ca-org1
QQ:13721218 请注明“读者” |
QQ群:128659835 请注明“读者” |