• FABRIC单机开发者模式启动


    在开始之前需要导出一个自定义变量,方便后续操作:

    export FABRIC=/opt/gopath/src/github.com/hyperledger/fabric/devenv

    1.在真机上执行如下操作,进入虚拟机

    cd $FABRIC
    vagrant up//启动虚拟机
    vagrant ssh//进入虚拟机

    2.在虚拟机中执行如下操作,启动memberserv和peer,并保持该终端的启动,命名为T1

    cd /opt/gopath/src/github.com/hyperledger/fabric/yaml
    docker-compose -f docker-compose-dev.yaml up

    附docker-compose-dev.yaml

    membersrvc:
      image: hyperledger/fabric-membersrvc
      ports:
        - "7054:7054"
      command: membersrvc
    vp0:
      image: hyperledger/fabric-peer
      ports:
        - "7050:7050"
        - "7051:7051"
        - "7053:7053"
      environment:
        - CORE_PEER_ADDRESSAUTODETECT=true
        - CORE_VM_ENDPOINT=unix:///var/run/docker.sock
        - CORE_LOGGING_LEVEL=DEBUG
        - CORE_PEER_ID=vp0
        - CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
        - CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
        - CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
        - CORE_SECURITY_ENABLED=false
        - CORE_SECURITY_ENROLLID=test_vp0
        - CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
      links:
        - membersrvc
      command: sh -c "sleep 5; peer node start --peer-chaincodedev"

    3.新开一个终端,用于启动chaincode程序,保持该终端的开启,命名为T2

    cd $FABRIC
    vagrant ssh//进入虚拟机
    cd /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02//进入要部署的chaincode所在目录
    go build//编译代码,生成chaincode_example02可执行程序
    CORE_CHAINCODE_ID_NAME=mycc01 CORE_PEER_ADDRESS=172.17.0.3:7051 ./chaincode_example02//注册chaincode,并为其注册一个名称CORE_CHAINCODE_ID_NAME

    返回信息如下:

    02:06:56.192 [shim] DEBU : Peer address: 172.17.0.3:7051
    02:06:56.197 [shim] DEBU : os.Args returns: [./chaincode_example02]
    02:06:56.200 [shim] DEBU : Registering.. sending REGISTER
    02:06:56.228 [shim] DEBU : []Received message REGISTERED from shim
    02:06:56.229 [shim] DEBU : []Handling ChaincodeMessage of type: REGISTERED(state:created)
    02:06:56.229 [shim] DEBU : Received REGISTERED, ready for invocations

    4.新开一个终端,用于部署chaincode程序,命名为T3

    cd $FABRIC
    vagrant ssh//进入虚拟机
    CORE_PEER_ADDRESS=172.17.0.3:7051 peer chaincode deploy -n mycc01 -c '{ "Args":["init"]}'//部署chaincode

    在T2终端打印:

    02:07:10.906 [shim] DEBU : [mycc01]Received message INIT from shim
    02:07:10.906 [shim] DEBU : [mycc01]Handling ChaincodeMessage of type: INIT(state:established)
    02:07:10.907 [shim] DEBU : Entered state init
    02:07:10.907 [shim] DEBU : [mycc01]Received INIT, initializing chaincode
    02:07:10.908 [shim] DEBU : [mycc01]Init succeeded. Sending COMPLETED
    02:07:10.909 [shim] DEBU : [mycc01]Move state message COMPLETED
    02:07:10.909 [shim] DEBU : [mycc01]Handling ChaincodeMessage of type: COMPLETED(state:init)
    02:07:10.909 [shim] DEBU : [mycc01]send state message COMPLETED
    在T3终端打印:

    Deploy chaincode: mycc01

    这里返回chaincode id,生产模式下打印的是chaincode对应的hash值

    之后就可以进行相应的invoke或者query操作了

  • 相关阅读:
    网络管理不得不知道的一些常识
    DWZ(一):框架初了解
    第三天 ThinkPHP手把手高速拼接站点(三)
    stl之list双向链表容器应用基础
    如何使用ninja编译系统编译我们的程序?
    由抓取豆瓣信息想到的網絡知識
    学习实践:使用模式,原则实现一个C++数据库訪问类
    加入新的linux系统调用
    【转】repo 的一些用法和理解-不错
    【转】ubuntu 12.04 LTS将关闭最大化最小化移动到右上角
  • 原文地址:https://www.cnblogs.com/fengxm/p/6015120.html
Copyright © 2020-2023  润新知