zoukankan      html  css  js  c++  java
  • 超级账本环境搭建fabric

    :go
    tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

    vi ~/.profile

    export PATH=$PATH:/usr/local/go/bin
    export GOROOT=/usr/local/go
    export GOPATH=$HOME/go
    export PATH=$PATH:$HOME/go/bin

    . ~/.profile


    cd ~
    mkdir go


    :docker
    wget -qO- https://get.docker.com/ --no-check-certificate | sh

     (http://mirrors.aliyun.com/docker-engine/apt/repo/pool/main/d/docker-engine/)阿里的下载目录 dpkg -i p.deb

    sudo usermod -aG docker fabric

    sudo mkdir -p /etc/docker
    sudo tee /etc/docker/daemon.json <<-'EOF'
    {
    "registry-mirrors": ["https://obou6wyb.mirror.aliyuncs.com"]
    }
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker

    sudo apt-get install python-pip

    curl -L -k https://get.daocloud.io/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
    sudo mv ~/docker-compose /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose

    :fabric
    mkdir -p ~/go/src/github.com/hyperledger
    cd ~/go/src/github.com/hyperledger
    git clone https://github.com/hyperledger/fabric.git

    cd ~/go/src/github.com/hyperledger/fabric
    git checkout v1.0.0

    cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/
    source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0
    docker images

    ./network_setup.sh up


    docker exec -it cli bash
    peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
    peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","20"]}'

    cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli

    ./network_setup.sh down

    query 
    CORE_PEER_LOCALMSPID=Org1MSP 
    CORE_PEER_MSPCONFIGPATH=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 
    CORE_PEER_TLS_ROOTCERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt 
    CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_ENABLED=true 
    CORE_PEER_TLS_KEY_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key 
    CORE_PEER_TLS_CERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt 
    CORE_LOGGING_LEVEL=DEBUG 
    CORE_PEER_ADDRESS=peer0.org1.example.com:7051 
    ./peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
    

      

    invoke
    CORE_PEER_LOCALMSPID=Org1MSP 
    CORE_PEER_MSPCONFIGPATH=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 
    CORE_PEER_TLS_ROOTCERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt 
    CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_ENABLED=true 
    CORE_PEER_TLS_KEY_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key 
    CORE_PEER_TLS_CERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt 
    CORE_LOGGING_LEVEL=DEBUG 
    CORE_PEER_ADDRESS=peer0.org1.example.com:7051 
    ./peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /root/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","20"]}'
    

     

    install 
    CORE_PEER_LOCALMSPID=Org1MSP 
    CORE_PEER_MSPCONFIGPATH=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 
    CORE_PEER_TLS_ROOTCERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt 
    CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_ENABLED=true 
    CORE_PEER_TLS_KEY_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key 
    CORE_PEER_TLS_CERT_FILE=~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt 
    CORE_LOGGING_LEVEL=DEBUG 
    CORE_PEER_ADDRESS=peer0.org1.example.com:7051 
    ./peer chaincode install -n mycc -v 0 -p github.com/hyperledger/fabric/examples/e2e_cli/examples/chaincode/go/chaincode_example02
    

      

    安装
    peer chaincode install -n c002 -v 1.0 -p github.com/chaincode_example02/go
    peer chaincode instantiate -C mychannel -n c002  -v 1.0 -c '{"Args":["init","a","100","b","200"]}'
    peer chaincode query -C mychannel -n c002 -c '{"Args":["query","a"]}'
    peer chaincode invoke -C mychannel -n c002 -c '{"Args":["invoke","a","b","10"]}'

    升级
    peer chaincode install -n c002 -v 2.0 -p github.com/chaincode_example02/gov1
    peer chaincode upgrade -C mychannel -n c002 -p github.com/chaincode_example02/go -v 2.0 -c '{"Args":["init","a","1000","b","2000"]}'
    peer chaincode query -C mychannel -n c002 -c '{"Args":["query","a"]}'

  • 相关阅读:
    JSONP的学习(收集整理)
    10个必备的移动UI设计资源站(转)
    iscroll4框架解析[webapp开发](转)
    IE9中Media queries在iframe无效的解决方法
    mustache模板技术
    企业级的响应式设计(Responsive design at enterprise level)译
    在JSP中使用jQuery的冲突解决(收集整理)
    Java开发 Eclipse使用技巧(转)
    Front End中Javascript兼容问题收集(转)
    vector it->和*it
  • 原文地址:https://www.cnblogs.com/ahuo/p/8960999.html
Copyright © 2011-2022 走看看