: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"]}'