美文网首页区块链hyperledger fabric
Ubuntu 18.04 安装Fabric 1.1

Ubuntu 18.04 安装Fabric 1.1

作者: 四丢皮得 | 来源:发表于2018-07-03 19:08 被阅读425次

    0 权限

    获取管理员权限

    $ sudo passwd   #设置root密码
    $ su     #切换到root用户
    

    1 基础工具准备

    • git
    $ apt install git
    
    • curl
    $ apt install curl
    
    • pip
    $ apt install python-pip
    $ pip install --upgrade pip
    
    • vim
    $ apt install vim
    

    2 安装docker和docker compose

    2.0 卸载旧版本

    如果有的话,卸载旧版本

    $ apt remove docker docker-engine docker.io
    

    2.1 安装docker

      1. 设置docker存储库
    $ apt -y install apt-transport-https ca-certificates
    
      1. 添加docker的GPG密钥,并添加仓库
    $ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add
    $ sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
    
      1. 更新apt软件包
    $ apt update
    
      1. 安装
    $ apt install docker-ce
    
      1. docker版本
    $ docker version
    

    2.2 安装docker-compose

      1. 从github下载docker-compose二进制文件
    $ curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    $ chmod +x /usr/local/bin/docker-compose
    
      1. 检查docker-compose版本
    $ docker-compose version
    

    2.3 docker 常用命令

    删除一个容器:docker rm 
    强制删除一个容器:docker rm -f 
    强制删除全部容器:docker rm -f $(docker ps -aq)
    杀死所有正在运行的容器:docker kill $(docker ps -a -q)
    删除所有已经停止的容器:docker rm $(docker ps -a -q)
    删除所有镜像:docker rmi $(docker images -q)
    强制删除所有镜像:docker rmi -f $(docker images -q)
    

    2.4 添加国内镜像下载源

    修改docker hub的镜像,编辑/etc/docker/daemon.json文件,没有就创建一个,需要管理员提权,写入以下内容:

    {
      "registry-mirrors": ["https://registry.docker-cn.com"]
    }
    

    重启docker服务生效: sudo service docker restart,这样docker就可以从国内镜像站进行pull操作,大大提高了pull image的速度。

    3 安装go

    3.1 下载安装包

    可前往https://golang.org/dl/下载最新版安装包,当前版本为go1.10.3.linux-amd64.tar.gz

    3.2 解压

    $ tar -C /usr/local -zxf go1.10.3.linux-amd64.tar.gz
    

    3.3 配置环境变量

      1. 打开/etc/profile
    $ vim /etc/profile
    
      1. 写入环境变量
    # Go environment
    export PATH=$PATH:/usr/local/go/bin
    export GOPATH=/opt/gopath
    

    然后ESC,:wq保存退出

      1. 环境变量生效
    $ source /etc/profile
    

    3.4 查看go版本

    $ go version
    

    4 安装Node.js

    4.1 安装node

      1. 安装
    $ apt install nodejs
    
      1. 检查版本
    $ node -v
    

    4.2 安装npm

      1. 安装
    $ apt install npm
    
      1. 升级至新版
    $ npm install -g npm@latest
    
      1. 重新开启终端后检测版本
    $ npm -v
    

    4.3 版本

    root@lzj-ThinkCentre-M910t-D562:/# npm -v
    6.1.0
    root@lzj-ThinkCentre-M910t-D562:/# node -v
    v8.10.0
    

    5 下载fabric代码和fabric-samples代码

    5.1 构建文件夹目录

    $ mkdir -p /opt/gopath/src/github.com/hyperledger/
    

    5.2 下载代码

    5.2.1 fabric
      1. 下载fabric代码
    $ cd /opt/gopath/src/github.com/hyperledger/
    $ git clone https://github.com/hyperledger/fabric.git
    
      1. 进入fabric
    $ cd fabric
    
      1. 切换代码分之
    $ git checkout release-1.1
    
    5.2.2 fabric-samples
      1. 下载fabric-samples代码
    $ cd /opt/gopath/src/github.com/hyperledger/
    $ git clone https://github.com/hyperledger/fabric-samples.git
    
      1. 进入fabric-samples
    $ cd fabric-samples
    
      1. 切换代码分支
    $ git checkout release-1.1
    

    5.3 下载docker镜像

    $ cd /opt/gopath/src/github.com/hyperledger/fabric/scripts
    $ ./bootstrap.sh
    

    5.4 查看已安装的docker images

    $ docker images
    

    结果

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# docker images
    REPOSITORY                                                                                               TAG                 IMAGE ID            CREATED             SIZE
    dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba   latest              a012dc755758        About an hour ago   172MB
    hyperledger/fabric-ca                                                                                    latest              72617b4fa9b4        3 months ago        299MB
    hyperledger/fabric-ca                                                                                    x86_64-1.1.0        72617b4fa9b4        3 months ago        299MB
    hyperledger/fabric-tools                                                                                 latest              b7bfddf508bc        3 months ago        1.46GB
    hyperledger/fabric-tools                                                                                 x86_64-1.1.0        b7bfddf508bc        3 months ago        1.46GB
    hyperledger/fabric-orderer                                                                               latest              ce0c810df36a        3 months ago        180MB
    hyperledger/fabric-orderer                                                                               x86_64-1.1.0        ce0c810df36a        3 months ago        180MB
    hyperledger/fabric-peer                                                                                  latest              b023f9be0771        3 months ago        187MB
    hyperledger/fabric-peer                                                                                  x86_64-1.1.0        b023f9be0771        3 months ago        187MB
    hyperledger/fabric-javaenv                                                                               latest              82098abb1a17        3 months ago        1.52GB
    hyperledger/fabric-javaenv                                                                               x86_64-1.1.0        82098abb1a17        3 months ago        1.52GB
    hyperledger/fabric-ccenv                                                                                 latest              c8b4909d8d46        3 months ago        1.39GB
    hyperledger/fabric-ccenv                                                                                 x86_64-1.1.0        c8b4909d8d46        3 months ago        1.39GB
    hyperledger/fabric-zookeeper                                                                             latest              92cbb952b6f8        4 months ago        1.39GB
    hyperledger/fabric-zookeeper                                                                             x86_64-0.4.6        92cbb952b6f8        4 months ago        1.39GB
    hyperledger/fabric-kafka                                                                                 latest              554c591b86a8        4 months ago        1.4GB
    hyperledger/fabric-kafka                                                                                 x86_64-0.4.6        554c591b86a8        4 months ago        1.4GB
    hyperledger/fabric-couchdb                                                                               latest              7e73c828fc5b        4 months ago        1.56GB
    hyperledger/fabric-couchdb                                                                               x86_64-0.4.6        7e73c828fc5b        4 months ago        1.56GB
    hyperledger/fabric-baseos                                                                                x86_64-0.4.6        220e5cf3fb7f        4 months ago        151MB
    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# 
    

    5.5 拉取二进制执行程序

      1. 手动下载文件
    $ cd /opt/gopath/src/github.com/hyperledger/fabric-samples
    $ wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.1.0/hyperledger-fabric-linux-amd64-1.1.0.tar.gz
    $ tar -zxvf hyperledger-fabric-linux-amd64-1.1.0.tar.gz
    
      1. 将二进制文件写入环境变量
    $ cd bin
    $ pwd
    $ vim /etc/profile
    

    写入如下内容

    export PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH
    
      1. 使环境变量生效
    $ source /etc/profile
    

    6 测试fabric-simples

    6.1 启动

    $ cd /opt/gopath/src/github.com/hyperledger/fabric-simaples/fabcar
    $ ./startFabric.sh
    

    启动成功出现

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# ./startFabric.sh 
    
    # don't rewrite paths for Windows Git Bash users
    export MSYS_NO_PATHCONV=1
    
    docker-compose -f docker-compose.yml down
    Removing network net_basic
    WARNING: Network net_basic not found.
    
    docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
    Creating network "net_basic" with the default driver
    Creating ca.example.com      ... done
    Creating orderer.example.com ... done
    Creating couchdb             ... done
    Creating peer0.org1.example.com ... done
    
    # wait for Hyperledger Fabric to start
    # incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
    export FABRIC_START_TIMEOUT=10
    #echo ${FABRIC_START_TIMEOUT}
    sleep ${FABRIC_START_TIMEOUT}
    
    # Create the channel
    docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
    2018-07-03 14:34:30.256 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-07-03 14:34:30.284 UTC [channelCmd] InitCmdFactory -> INFO 002 Endorser and orderer connections initialized
    2018-07-03 14:34:30.495 UTC [main] main -> INFO 003 Exiting.....
    # Join peer0.org1.example.com to the channel.
    docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
    2018-07-03 14:34:30.648 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-07-03 14:34:31.198 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    2018-07-03 14:34:31.198 UTC [main] main -> INFO 003 Exiting.....
    Creating cli ... done
    2018-07-03 14:34:35.168 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
    2018-07-03 14:34:35.168 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
    2018-07-03 14:34:35.168 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
    2018-07-03 14:34:35.168 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
    2018-07-03 14:34:35.168 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
    2018-07-03 14:34:35.866 UTC [golang-platform] getCodeFromFS -> DEBU 006 getCodeFromFS github.com/fabcar/go
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 007 Discarding GOROOT package bytes
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 008 Discarding GOROOT package encoding/json
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package fmt
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 00a Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 00b Discarding provided package github.com/hyperledger/fabric/protos/peer
    2018-07-03 14:34:36.499 UTC [golang-platform] func1 -> DEBU 00c Discarding GOROOT package strconv
    2018-07-03 14:34:36.499 UTC [golang-platform] GetDeploymentPayload -> DEBU 00d done
    2018-07-03 14:34:36.499 UTC [container] WriteFileToPackage -> DEBU 00e Writing file to tarball: src/github.com/fabcar/go/fabcar.go
    2018-07-03 14:34:36.520 UTC [msp/identity] Sign -> DEBU 00f Sign: plaintext: 0A9C070A5C08031A0C08FC92EED90510...F1F3DF000000FFFF06BA999800200000 
    2018-07-03 14:34:36.520 UTC [msp/identity] Sign -> DEBU 010 Sign: digest: FBCB257B6BD6523860A624A84B6F9041A6F7186C4F1F82DC5D95E95D868D3E2F 
    2018-07-03 14:34:36.775 UTC [chaincodeCmd] install -> DEBU 011 Installed remotely response:<status:200 payload:"OK" > 
    2018-07-03 14:34:36.775 UTC [main] main -> INFO 012 Exiting.....
    2018-07-03 14:34:36.925 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
    2018-07-03 14:34:36.925 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
    2018-07-03 14:34:36.925 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
    2018-07-03 14:34:36.925 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
    2018-07-03 14:34:36.926 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
    2018-07-03 14:34:36.926 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AA7070A6708031A0C08FC92EED90510...324D53500A04657363630A0476736363 
    2018-07-03 14:34:36.926 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: B796AF19973CF558DB681686D28ED88E46D0725829C1A140812F2A81D1EACA5F 
    2018-07-03 14:35:00.448 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AA7070A6708031A0C08FC92EED90510...5B7F92427E8339FC92919844438BA5CD 
    2018-07-03 14:35:00.448 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: E1F6F1FB45DE5BD2DDCEBC183557AAAB95E478AB053166E7F72DC0A47FA35DDB 
    2018-07-03 14:35:00.449 UTC [main] main -> INFO 00a Exiting.....
    2018-07-03 14:35:10.607 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
    2018-07-03 14:35:10.607 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
    2018-07-03 14:35:10.608 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
    2018-07-03 14:35:10.608 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
    2018-07-03 14:35:10.608 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
    2018-07-03 14:35:10.608 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AA9070A6908031A0C089E93EED90510...1A0E0A0A696E69744C65646765720A00 
    2018-07-03 14:35:10.608 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 895CCD994678D31504C9AC6DDD0C66CE799BC85CDAF9E121DDAB36999565B838 
    2018-07-03 14:35:10.614 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AA9070A6908031A0C089E93EED90510...12F62521B7B102EB56F1DED55F72234D 
    2018-07-03 14:35:10.614 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: CECA4B1757CC96C01A3D9590E3A3935667B9CD5F404628129A71E117EEBF9484 
    2018-07-03 14:35:10.615 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00a ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \222\251\242\212\340K\"\026\240\027NC\373\030Q\244\363T\0333-\333\265\244O\274cU\006\307\301\345\022\267\006\n\240\006\022\205\006\n\006fabcar\022\372\005\032J\n\004CAR0\032B{\"make\":\"Toyota\",\"model\":\"Prius\",\"colour\":\"blue\",\"owner\":\"Tomoko\"}\032G\n\004CAR1\032?{\"make\":\"Ford\",\"model\":\"Mustang\",\"colour\":\"red\",\"owner\":\"Brad\"}\032N\n\004CAR2\032F{\"make\":\"Hyundai\",\"model\":\"Tucson\",\"colour\":\"green\",\"owner\":\"Jin Soo\"}\032N\n\004CAR3\032F{\"make\":\"Volkswagen\",\"model\":\"Passat\",\"colour\":\"yellow\",\"owner\":\"Max\"}\032G\n\004CAR4\032?{\"make\":\"Tesla\",\"model\":\"S\",\"colour\":\"black\",\"owner\":\"Adriana\"}\032K\n\004CAR5\032C{\"make\":\"Peugeot\",\"model\":\"205\",\"colour\":\"purple\",\"owner\":\"Michel\"}\032H\n\004CAR6\032@{\"make\":\"Chery\",\"model\":\"S22L\",\"colour\":\"white\",\"owner\":\"Aarav\"}\032H\n\004CAR7\032@{\"make\":\"Fiat\",\"model\":\"Punto\",\"colour\":\"violet\",\"owner\":\"Pari\"}\032J\n\004CAR8\032B{\"make\":\"Tata\",\"model\":\"Nano\",\"colour\":\"indigo\",\"owner\":\"Valeria\"}\032M\n\004CAR9\032E{\"make\":\"Holden\",\"model\":\"Barina\",\"colour\":\"brown\",\"owner\":\"Shotaro\"}\022\026\n\004lscc\022\016\n\014\n\006fabcar\022\002\010\001\032\003\010\310\001\"\r\022\006fabcar\032\0031.0" endorsement:<endorser:"\n\007Org1MSP\022\226\006-----BEGIN CERTIFICATE-----\nMIICGjCCAcCgAwIBAgIRAPlwF/rUZUP9mqN4wSml4iswCgYIKoZIzj0EAwIwczEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMTcwODMxMDkxNDMyWhcNMjcwODI5MDkxNDMy\nWjBbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN\nU2FuIEZyYW5jaXNjbzEfMB0GA1UEAxMWcGVlcjAub3JnMS5leGFtcGxlLmNvbTBZ\nMBMGByqGSM49AgEGCCqGSM49AwEHA0IABHihxW6ks3B2+5XdbAVq3CBgxRRRZ22x\nzzpqnD86nKkz7fBElBuhlXl2K6rTxyY2OBOB0ts8keqZ93xueRGymrajTTBLMA4G\nA1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIEI5qg3Ndtru\nuLoM2nAYUdFFBNMarRst3dusalc2Xkl8MAoGCCqGSM49BAMCA0gAMEUCIQD4j0Rn\ne1rrd0FSCzsR6u+IuuPK5dI/kR/bh7+VLf0TNgIgCfUtkJvfvzVEwZLFoFyjoHtr\ntvwzNUS1U0hEqIaDeo4=\n-----END CERTIFICATE-----\n" signature:"0E\002!\000\223j\321\246\203g1\231S\001\306h\032\224\230\025P\276p\335\331\350O\333\256\357\273Z\374$\001\262\002 8@\315\205\233k\207`\252o\236\3472\277\320v\022\366%!\267\261\002\353V\361\336\325_r#M" > 
    2018-07-03 14:35:10.615 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200 
    2018-07-03 14:35:10.615 UTC [main] main -> INFO 00c Exiting.....
    
    Total setup execution time : 62 secs ...
    
    
    Start by installing required packages run 'npm install'
    Then run 'node enrollAdmin.js', then 'node registerUser'
    
    The 'node invoke.js' will fail until it has been updated with valid arguments
    The 'node query.js' may be run at anytime once the user has been registered
    

    启动好后,使用docker ps -a可以看到一下容器进程

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples# docker ps -a
    CONTAINER ID        IMAGE                                                                                                    COMMAND                  CREATED             STATUS              PORTS                                            NAMES
    4d616026fae3        dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba   "chaincode -peer.add…"   9 minutes ago       Up 9 minutes                                                         dev-peer0.org1.example.com-fabcar-1.0
    e3f39adfdaf4        hyperledger/fabric-tools                                                                                 "/bin/bash"              10 minutes ago      Up 10 minutes                                                        cli
    685389dd42c9        hyperledger/fabric-peer                                                                                  "peer node start"        10 minutes ago      Up 10 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
    43a3bbb70a34        hyperledger/fabric-couchdb                                                                               "tini -- /docker-ent…"   10 minutes ago      Up 10 minutes       4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb
    57f9b1916084        hyperledger/fabric-ca                                                                                    "sh -c 'fabric-ca-se…"   10 minutes ago      Up 10 minutes       0.0.0.0:7054->7054/tcp                           ca.example.com
    1248943ad4be        hyperledger/fabric-orderer                                                                               "orderer"                10 minutes ago      Up 10 minutes       0.0.0.0:7050->7050/tcp                           orderer.example.com
    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples# 
    

    6.2 安装node第三方模块

    $ npm install
    

    6.3 测试

      1. 添加管理员
    $ node enrollAdmin.js
    

    结果

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# node enrollAdmin.js 
     Store path:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
    Successfully enrolled admin user "admin"
    Assigned the admin user to the fabric client ::{"name":"admin","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment":{"signingIdentity":"08518a72536f6f69c170ea7e5845e2b8330471aaaf187a14036b8e3ec7c064bd","identity":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICAjCCAaigAwIBAgIUTG/ZsQwBzTSCjRblSjQpZFQK7OcwCgYIKoZIzj0EAwIw\nczELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh\nbiBGcmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMT\nE2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgwNzAzMTUwNDAwWhcNMTkwNzAzMTUw\nOTAwWjAhMQ8wDQYDVQQLEwZjbGllbnQxDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZI\nzj0CAQYIKoZIzj0DAQcDQgAEpDzuGN/CmpaVKOmYifOjjX5eBkvcVrVph/rEACYn\nRJ9D5Y7MRQmEIDtardowpBy2yzWPL3csnb3YsYsomYIpfKNsMGowDgYDVR0PAQH/\nBAQDAgeAMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFG7uFkuIZwBVEWwnjg0seGAc\neapiMCsGA1UdIwQkMCKAIEI5qg3NdtruuLoM2nAYUdFFBNMarRst3dusalc2Xkl8\nMAoGCCqGSM49BAMCA0gAMEUCIQCChcLn3kP+1IA3hhpshz0D973QHvItAznaLrG6\nOIKqAAIgMLV/F65s1Fe+DWsPFa1660WMdrmpQpqZIukNLpv6R8U=\n-----END CERTIFICATE-----\n"}}}
    
      1. 注册用户
    $ node registerUser.js
    

    结果

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# node registerUser.js 
     Store path:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
    Successfully loaded admin from persistence
    Successfully registered user1 - secret:YuarHrEEygUw
    Successfully enrolled member user "user1" 
    User1 was successfully registered and enrolled and is ready to intreact with the fabric network
    
      1. 查询docker
    $ node query.js docker
    

    结果

    root@lzj-ThinkCentre-M910t-D562:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar# node query.js docker
    Store path:/opt/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
    Successfully loaded user1 from persistence
    Query has completed, checking results
    Response is  [{"Key":"CAR0", "Record":{"colour":"blue","make":"Toyota","model":"Prius","owner":"Tomoko"}},{"Key":"CAR1", "Record":{"colour":"red","make":"Ford","model":"Mustang","owner":"Brad"}},{"Key":"CAR2", "Record":{"colour":"green","make":"Hyundai","model":"Tucson","owner":"Jin Soo"}},{"Key":"CAR3", "Record":{"colour":"yellow","make":"Volkswagen","model":"Passat","owner":"Max"}},{"Key":"CAR4", "Record":{"colour":"black","make":"Tesla","model":"S","owner":"Adriana"}},{"Key":"CAR5", "Record":{"colour":"purple","make":"Peugeot","model":"205","owner":"Michel"}},{"Key":"CAR6", "Record":{"colour":"white","make":"Chery","model":"S22L","owner":"Aarav"}},{"Key":"CAR7", "Record":{"colour":"violet","make":"Fiat","model":"Punto","owner":"Pari"}},{"Key":"CAR8", "Record":{"colour":"indigo","make":"Tata","model":"Nano","owner":"Valeria"}},{"Key":"CAR9", "Record":{"colour":"brown","make":"Holden","model":"Barina","owner":"Shotaro"}}]
    

    到此搭建完毕!

    相关文章

      网友评论

        本文标题:Ubuntu 18.04 安装Fabric 1.1

        本文链接:https://www.haomeiwen.com/subject/cdsjuftx.html