Fabric1.0.0
########第n次测试#########
sudo apt-get update
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install python3-pip
pip3 install --upgrade pip
sudo apt-get install npm
#此处注意:python-pip安装会报找不到,所以改为python3-pip
#安装go
wget https://storage.googleapis.com/golang/go1.14.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
cd ~
mkdir go
vim ~/.profile
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
source ~/.profile
#安装docker
##卸载旧版docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
#安装依赖
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#安装
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
###
sudo apt-get install docker-ce
### sudo apt install docker.io,此命令安装不全可以进行测试
sudo gpasswd -a xl docker #正在将用户“halfape”加入到“docker”组中
newgrp docker #更新用户组
配置镜像加速器https://cr.console.aliyun.com/mirrors
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://5ussdk09.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
###
sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
#安装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
##简单测试
####我们仍然停留在e2e_cli文件夹
./network_setup.sh up
###
#1.1编译生成Fabric公私钥、证书的程序,程序在目录:fabric/release/linux-amd64/bin
#1.2基于configtx.yaml生成创世区块和通道相关信息,并保存在channel-artifacts文件夹。
#1.3基于crypto-config.yaml生成公私钥和证书信息,并保存在crypto-config文件夹中。
#1.4基于docker-compose-cli.yaml启动1Orderer+4Peer+1CLI的Fabric容器。
#1.5在CLI启动的时候,会运行scripts/script.sh文件,这个脚本文件包含了创建Channel,加入Channel,安装Example02,运行Example02等功能。
###
#在官方例子中,channel名字是mychannel,链码的名字是mycc。我们首先进入CLI,我们重新打开一个命令行窗口,输入:
docker exec -it cli bash
###
#查询a账户的余额
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
#我们试一试把a账户的余额再转80元给b账户
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","80"]}'
#查询一下a账户的余额,没问题的话,应该是只剩下10块大洋了
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
#关闭Fabric网络
cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli
./network_setup.sh down
Fabric1.4.3
########第n次测试#########
sudo apt-get update
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install python3-pip
pip3 install --upgrade pip
sudo apt-get install npm
#此处注意:python-pip安装会报找不到,所以改为python3-pip
#安装go
wget https://storage.googleapis.com/golang/go1.14.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
cd ~
mkdir go
vim ~/.profile
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
source ~/.profile
#安装docker
##卸载旧版docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
#安装依赖
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#安装
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
###
sudo apt-get install docker-ce
### sudo apt install docker.io,此命令安装不全可以进行测试
sudo gpasswd -a xl docker #正在将用户“halfape”加入到“docker”组中
newgrp docker #更新用户组
配置镜像加速器https://cr.console.aliyun.com/mirrors
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://5ussdk09.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
###
sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
#安装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.4.3
###
vi bootstrap.sh
#nexus.hyperledger.org这个网站不再维护了,需要把脚本中nexus.hyperledger.org位置替换一下
#------------------------------
#改造前:
binariesInstall() {
echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
binaryDownload ${BINARY_FILE} https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/${BINARY_FILE}
if [ $? -eq 22 ]; then
echo
echo "------> ${FABRIC_TAG} platform specific fabric binary is not available to download <----"
echo
fi
echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary"
binaryDownload ${CA_BINARY_FILE} https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${CA_VERSION}/${CA_BINARY_FILE}
if [ $? -eq 22 ]; then
echo
echo "------> ${CA_TAG} fabric-ca-client binary is not available to download (Available from 1.1.0-rc1) <----"
echo
fi
}
#改造后:
binariesInstall() {
echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries" binaryDownload ${BINARY_FILE} https://github.com/hyperledger/fabric/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/${BINARY_FILE}
if [ $? -eq 22 ]; then
echo
echo "------> ${FABRIC_TAG} platform specific fabric binary is not available to download <----"
echo
fi
echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary" binaryDownload ${CA_BINARY_FILE} https://github.com/hyperledger/fabric/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${CA_VERSION}/${CA_BINARY_FILE}
if [ $? -eq 22 ]; then
echo
echo "------> ${CA_TAG} fabric-ca-client binary is not available to download (Available from 1.1.0-rc1) <----"
echo
fi
}
#-------------------------------------
cd /home/xl/go/src/github.com/hyperledger/fabric
make configtxgen
make cryptogen
make configtxlator
#在启动fabric中first-network网络时,需要执行一个自动化脚本:
#./byfn.sh -m generate
#该脚本需要自动生成相关证书信息,fabric官方提供了两款工具:configtxgen、cryptogen。在脚本执行中会从fabric-simple/bin中取查找并调用两者。初次启动时没有这个工具的。
#解决方法:
#进入fabric目录,看见make* 文件,使用make configtxgen、make cryptogen两个指令生成工具(如果之前搭建过fabric-1.0环境,直接进fabric/build将bin文件夹直接移动到fabric-sample目录即可)。
cd /home/xl/go/src/github.com/hyperledger/fabric/scripts/fabric-samples
mkdir bin
cd ~/go/src/github.com/hyperledger/fabric/.build
sudo cp bin/* ../scripts/fabric-samples/bin/
cd ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network
./byfn.sh -m generate -c mychannel
./byfn.sh -m up -c mychannel
###
docker exec -it cli bash
#查询a余额
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
#查询b余额
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","b"]}'
./byfn.sh -m down
##备注###
cd ~/go/src/github.com/hyperledger/fabric
###切换分支
git checkout v1.4.3
git changes
git stash
git checkout v1.4.3
###
Fabric2.2.0
########第n次测试#########
sudo apt-get update
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install python3-pip
pip3 install --upgrade pip
sudo apt-get install npm
#此处注意:python-pip安装会报找不到,所以改为python3-pip
#安装go
wget https://storage.googleapis.com/golang/go1.14.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
cd ~
mkdir go
vim ~/.profile
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
source ~/.profile
#安装docker
##卸载旧版docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
#安装依赖
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#安装
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
###
sudo apt-get install docker-ce
### sudo apt install docker.io,此命令安装不全可以进行测试
sudo gpasswd -a xl docker #正在将用户“halfape”加入到“docker”组中
newgrp docker #更新用户组
配置镜像加速器https://cr.console.aliyun.com/mirrors
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://5ussdk09.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
###
sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
#安装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 v2.2.0
###
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
###
cd scripts/
./bootstrap.sh
cd /home/xl/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar
./startFabric.sh go
####
cd go
go run fabcar.go
#####
###安装nodejs
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
cd javascript/
npm install
####
node enrollAdmin.js
node registerUser.js
node invoke.js
node query.js
版权声明:本文为weixin_41865104原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。