mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum updata
yum install -y yum-utils \device-mapper-persistent-data \lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test
yum install docker-ce
这一句会有点久,但当安装完成时,即意味着docker安装完成。可通过docker version查看。
注意,如果docker version不行
输入命令行:
service docker restart
可能出现问题:
[root@woai33 jack]# service docker restart
Redirecting to /bin/systemctl restart docker.service
Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl start docker.service" again.
输入systemctl status docker.service查看结果:
按这里https://blog.csdn.net/zhangbeizhen18/article/details/85239758试了一遍并不行,但最后发现解决办法:去编辑 /etc/docker/daemon.json,这里的文件错误会导致此类错误,一般将内容修改为:
{
"registry-mirrors":["https://registry.docker-cn.com"]
}
参考教程:https://docs.docker.com/compose/install/
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
如果输入:docker-compose version 不行,继续输入:用于将文件移入/usr/bin/中
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
解压本地已下载好的go压缩包到/usr/local/software/中
tar -C /usr/local/software -xzf go-xxx.tar.gz
编辑配置文件并更新路径
vim /etc/profie
在最后添加以下两句:
export PATH=$PAHT:/usr/local/software/go/bin
export GOPATH=/opt/gopath
再esc i :wq 退出后输入:
source /etc/profile
更新配置 ,最后输入 go version 有显示即可
ftp:用户名:主机名;密码:登录密码
打开控制面板—>软件—>功能—>Internet
项目路径:https://github.com/hyperledger/fabric
安装git:
yum install git
新建文件夹:
mkdir -p /opt/gopath/src/github.com/hyperledger
进入此文件夹:
cd /opt/gopath/src/github.com/hyperledger
再通过git clone https://github.com/hyperledger/fabric 即可将fabric下载到目前所在目录下,之后通过进入并执行
scripts/bootstrap.sh
即可下载镜像
若需要相关镜像,可在docker官网上搜索下载:
例:https://hub.docker.com/r/hyperledger/fabric-kafka/tags 即可得到下载链接:
docker pull hyperledger/fabric-kafka:latest
并可通过docker images 查看
官方教程:https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html
中文版:https://blog.csdn.net/hugowang/article/details/83113964
注意,第一步,先执行bootstrap.sh,否则,会报错:cryptogen tool not found.exiting
当出现问题时,如果执行后无效,可以试着直接将该文件下载下载进行解压,而不是按教程来https://blog.csdn.net/mellymengyan/article/details/77671185
通过下载需要的包:
https://github.com/hyperledger/fabric/releases/download/v1.4.4/hyperledger-fabric-linux-amd64-1.4.4.tar.gz
并将下载的hyperledger-fabric-linux-amd64-1.4.4.tar.gz下载后解压到
/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/
中。当fabric-samples中有了bin文件夹和first-network时,即可进入first-network开始执行
./byfn.sh generate
开始创建网络。
正常配置如图:
开始创建:
最后:通过命令行:
./byfn.sh up
即可完成网络的构建
[root@woai33 first-network]# ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.4
DOCKER_IMAGE_VERSION=1.4.4
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer1.org2.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer0.org1.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ad955dfeebff hyperledger/fabric-tools:latest "/bin/bash" 1 second ago Up Less than a second cli
0e47af5cf4a4 hyperledger/fabric-peer:latest "peer node start" 2 seconds ago Up Less than a second 0.0.0.0:8051->8051/tcp peer1.org1.example.com
b29d51bb92b5 hyperledger/fabric-peer:latest "peer node start" 2 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp peer0.org1.example.com
69435f4ee8ef hyperledger/fabric-orderer:latest "orderer" 2 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com
cf1307ba9694 hyperledger/fabric-peer:latest "peer node start" 2 seconds ago Up Less than a second 0.0.0.0:10051->10051/tcp peer1.org2.example.com
d8c0ad67d683 hyperledger/fabric-peer:latest "peer node start" 2 seconds ago Up Less than a second 0.0.0.0:9051->9051/tcp peer0.org2.example.com
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
Build your first network (BYFN) end-to-end test
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --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
Channel name : mychannel
Creating channel...
+ res=0
+ set +x
2019-12-02 13:31:52.551 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:31:52.565 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-12-02 13:31:52.621 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:31:52.639 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-12-02 13:31:55.694 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:31:55.712 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-12-02 13:31:58.763 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:31:58.781 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-12-02 13:32:01.844 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:32:01.862 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' =====================
Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --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
+ res=0
+ set +x
2019-12-02 13:32:04.911 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:32:04.919 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --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
+ res=0
+ set +x
2019-12-02 13:32:07.969 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-12-02 13:32:07.977 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-12-02 13:32:11.035 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-12-02 13:32:11.036 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-12-02 13:32:11.598 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== Chaincode is installed on peer0.org1 =====================
Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-12-02 13:32:11.646 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-12-02 13:32:11.647 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-12-02 13:32:11.860 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== Chaincode is installed on peer0.org2 =====================
Instantiating chaincode on peer0.org2...
+ peer chaincode instantiate -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 -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
+ res=0
+ set +x
2019-12-02 13:32:11.915 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-12-02 13:32:11.915 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
===================== Chaincode is instantiated on peer0.org2 on channel 'mychannel' =====================
Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x
100
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
Sending invoke transaction on peer0.org1 peer0.org2...
+ 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 --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2019-12-02 13:33:04.351 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================
Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-12-02 13:33:04.401 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-12-02 13:33:04.401 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-12-02 13:33:04.600 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== Chaincode is installed on peer1.org2 =====================
Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer1.org2 ...3 secs
+ res=0
+ set +x
90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
[root@woai33 first-network]#