ubuntu16.04.7
安装openssh-server:
apt install openssh-server
ubuntu18默认安装python3.6,查看版本:
python --version
更新apt-get:
sudo apt-get update
安装python2.7:
sudo apt-get install python2.7
安装pip:
sudo apt install python-pip
sudo apt install python3-pip
查看pip版本:
pip --version
pip3 --version
更新pip:
sudo pip install --upgrade pip
mkdir go
cd go
sudo apt install lrzsz
tar -xvf go1.15.11.linux-amd64.tar.gz
(-C可以指定解压到的目录)apt install vim
mkdir go/workspace
vim ~/.bashrc
export GOROOT=/home/hallen/go/go
export GOPATH=/home/hallen/go/workspace
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source ~/.bashrc
sudo apt install git
sudo apt-get update
sudo apt-get install docker
sudo apt install docker.io
docker version
sudo groupadd docker
sudo gpasswd -a hallen docker
systemctl restart docker
newgrp docker
docker version
mkdir docker
sudo apt install curl
curl -L 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
mkdir bin pkg src
mkdir src
cd src
git clone https://github.com/hyperledger/fabric.git
cd fabric
git checkout v1.0.0
main分支是没有examples文件夹的docker pull hyperledger/fabric-tools:x86_64-1.0.0
docker pull hyperledger/fabric-orderer:x86_64-1.0.0
docker pull hyperledger/fabric-peer:x86_64-1.0.0
docker pull hyperledger/fabric-couchdb:x86_64-1.0.0
docker pull hyperledger/fabric-kafka:x86_64-1.0.0
docker pull hyperledger/fabric-ca:x86_64-1.0.0
docker pull hyperledger/fabric-ccenv:x86_64-1.0.0
docker pull hyperledger/fabric-baseimage:x86_64-0.4.7
docker pull hyperledger/fabric-javaenv:x86_64-1.0.0
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.0
docker tag hyperledger/fabric-tools:x86_64-1.0.0 hyperledger/fabric-tools
docker tag hyperledger/fabric-orderer:x86_64-1.0.0 hyperledger/fabric-orderer
docker tag hyperledger/fabric-peer:x86_64-1.0.0 hyperledger/fabric-peer
docker tag hyperledger/fabric-couchdb:x86_64-1.0.0 hyperledger/fabric-couchdb
docker tag hyperledger/fabric-kafka:x86_64-1.0.0 hyperledger/fabric-kafka
docker tag hyperledger/fabric-ca:x86_64-1.0.0 hyperledger/fabric-ca
docker tag hyperledger/fabric-ccenv:x86_64-1.0.0 hyperledger/fabric-ccenv
docker tag hyperledger/fabric-baseimage:x86_64-0.4.7 hyperledger/fabric-baseimage
docker tag hyperledger/fabric-javaenv:x86_64-1.0.0 hyperledger/fabric-javaenv
docker tag hyperledger/fabric-zookeeper:x86_64-1.0.0 hyperledger/fabric-zookeeper
docker images
docker container prune
docker rmi –f [IMAGE ID]
mkdir hyperledger
cryptogen showtemplate > conf.yaml
cryptogen generate --config conf.yaml
configtxgen -profile GenGenesis -outputBlock ./genesis.block
configtxgen -profile GenChannel -channelID zlktchannel -outputCreateChannelTx ./channel.tx
chmod 775 channel.tx genesis.block
configtxgen -profile GenChannel -outputAnchorPeersUpdate ./Org1MSPAnchorUpdate.tx -asOrg Org1MSP -channelID zlktChannel
configtxgen -profile GenChannel -outputAnchorPeersUpdate ./Org2MSPAnchorUpdate.tx -asOrg Org2MSP -channelID zlktChannel
mkdir channel-artifacts
mv genesis.block channel-artifacts/
mv channel.tx channel-artifacts/
mkdir chaincode
mkdir base
cd base
docker-compose -f docker-compose-cli.yaml up -d
docker-compose -f docker-compose-cli.yaml ps
docker exec -it cli /bin/bash peer channel create -o orderer.example.com:7050 -c zlktchannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts /tlsca.example.com-cert.pem
peer channel list
peer channel join -b zlktchannel.block
export CORE_PEER_ADDRESS=peer0.org2.example.com:7051
export CORE_PEER_LOCALMSPID=Org2MSP
export CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
export CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key
export CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
peer channel join -b zlktchannel.block
peer chaincode install -n example02 -v 1.0.0 -p github.com/hyperledger/fabric/examples/chaincode/go
peer chaincode instantiate -o orderer.example.com:7050 -C zlktchannel -c '{"Args":["init","a","200","b","300"]}' -n example02 -P "OR('Org1MSP.member','Org2MSP.member')" -v 1.0.0 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode query -C zlktchannel -n example02 -c '{"Args":["query","a"]}'
mkdir mycc
cd mycc
peer chaincode install -n mycc1 -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/mycc
peer chaincode instantiate -o orderer.example.com:7050 -C zlktchannel -c '{"Args":["init","name","hallen","age","18"]}' -n mycc1 -v 1.0 -P "OR('Org1MSP.member','Org2MSP.member')" --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode query -C zlktchannel -n mycc1 -c '{"Args":["query","name"]}'
mkdir mytxcc
cd mytxcc
peer chaincode install -n mytxcc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/mytxcc
peer chaincode instantiate -o orderer.example.com:7050 -C zlktchannel -c '{"Args":["init","hallen","200","zhiliao","300"]}' -n mytxcc -v 1.0 -P "OR ('Org1MSP.member','Org2MSP.member')" --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode query -C zlktchannel -n mytxcc -c '{"Args":["query","hallen"]}'
peer chaincode query -C zlktchannel -n mytxcc -c '{"Args":["query","hallen"]}'
peer chaincode invoke -C zlktchannel -n mytxcc -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem -c '{"Args":["invoke","hallen","zhiliao","20"]}'
docker exec -it cli bash
peer chaincode install -n mytxcc -v 2.0 -p github.com/hyperledger/fabric/examples/chaincode/go/mytxcc
peer chaincode upgrade -o orderer.example.com:7050 -C zlktchannel -c '{"Args":["init","hallen","200","zhiliao","300"]}' -n mytxcc -v 2.0 -P "OR ('Org1MSP.member','Org2MSP.member')" --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem
mkdir myivcc
cd myivcc
peer chaincode install -n myivcc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/myivcc
peer chaincode instantiate -o orderer.example.com:7050 -C zlktchannel -c '{"Args":["init","hallen","200"]}' -n myivcc -v 1.0 -P "OR ('Org1MSP.member','Org2MSP.member')" --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode query -o orderer.example.com:7050 -C zlktchannel -n myivcc -c '{"Args":["invoke","mytxcc","hallen","zlktchannel"]}'
peer chaincode package -n myivcc -p github.com/hyperledger/fabric/examples/chaincode/go/myivcc -v 1.0 myivcc.1.0.out