安装环境
[root@localhost opt]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
防火墙关闭
systemctl stop firewalld && systemctl disable firewalld
编号 | 工具 | 版本号 |
---|---|---|
1 | CURL | 7.29.0 (系统自带) |
2 | Docker | 17.06.2-ce及其以上版本 |
3 | Docker Compose | 1.14.0及其以上版本 |
4 | Go | 1.11.x |
5 | Node.js | 8.9.4及其以上版本,10.15.3及其以上版本 |
6 | NPM | 5.6.0 |
7 | Python | 2.7.x |
8 | Git | 1.8.3.1(系统自带) |
查看版本
[root@iZ8vbb3mz6nouzleylfgi9Z ~]# curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.36 zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
安装docker
yum install -y yum-utils device-mapper-persistent-data lvm2 vim \
&& yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo \
&& yum makecache fast \
&& yum -y install docker-ce \
&& mkdir -p /etc/docker/ \
&& echo -e '{\n "data-root":"/home/docker",\n "registry-mirrors": ["https://1e7waog4.mirror.aliyuncs.com"]\n}' > /etc/docker/daemon.json \
&& systemctl start docker && systemctl enable docker
版本如下
[root@localhost opt]# docker --version
Docker version 19.03.4, build 9013bf583a
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
yum -y install epel-release \
&& yum -y install python-pip \
&& pip install --upgrade pip \
&& pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose
版本如下
[root@localhost opt]# docker-compose --version
docker-compose version 1.24.1, build 1110ad01
yum install -y wget \
&& wget https://dl.google.com/go/go1.11.13.linux-amd64.tar.gz -O /opt/go1.11.13.linux-amd64.tar.gz \
&& cd /opt/;tar -zxvf go1.11.13.linux-amd64.tar.gz \
&& rm -rf /opt/go1.11.13.linux-amd64.tar.gz \
&& mkdir /opt/goWork \
&& echo -e 'export GOROOT=/opt/go \nexport GOBIN=$GOROOT/bin \nexport PATH=$PATH:$GOBIN \nexport GOPATH=/opt/goWork' >> /etc/profile \
&& source /etc/profile
版本如下
[root@localhost opt]# go version
go version go1.11.13 linux/amd64
wget https://npm.taobao.org/mirrors/node/v8.9.4/node-v8.9.4-linux-x64.tar.xz -O /opt/node-v8.9.4-linux-x64.tar.xz \
&& cd /opt/;tar -xvf node-v8.9.4-linux-x64.tar.xz \
&& rm -rf /opt/node-v8.9.4-linux-x64.tar.xz \
&& ln -s /opt/node-v8.9.4-linux-x64/bin/npm /usr/local/bin/npm \
&& ln -s /opt/node-v8.9.4-linux-x64/bin/node /usr/local/bin/node
版本如下
[root@localhost opt]# node -v && npm -v
v8.9.4
5.6.0
系统自带2.7.5
python --version
Python 2.7.5
yum install -y git
[root@localhost opt]# git --version
git version 1.8.3.1
下载fabric-samples到$GOPATH/src/github.com/hyperledger
目录中
mkdir -p $GOPATH/src/github.com/hyperledger \
&& cd $GOPATH/src/github.com/hyperledger \
&& git clone https://github.com/hyperledger/fabric-samples.git \
&& cd fabric-samples \
&& git checkout -b sample v1.4.0
配置环境变量
echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
刷新生效
source /etc/profile
有两种安装方式可供选择:
直接执行scripts
目录下的bootstrap.sh
脚本
[root@localhost scripts]# ./scripts/bootstrap.sh
Installing Hyperledger Fabric binaries
===> Downloading version 1.4.0 platform specific fabric binaries
===> Downloading: https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
21 50.9M 21 11.0M 0 0 145k 0 0:05:58 0:01:17 0:04:41 84684
成功后会自动列出下载的镜像
===> List out hyperledger docker images
hyperledger/fabric-tools 1.4.0 0a44f4261a55 9 months ago 1.56GB
hyperledger/fabric-tools latest 0a44f4261a55 9 months ago 1.56GB
hyperledger/fabric-ccenv 1.4.0 5b31d55f5f3a 9 months ago 1.43GB
hyperledger/fabric-ccenv latest 5b31d55f5f3a 9 months ago 1.43GB
hyperledger/fabric-orderer 1.4.0 54f372205580 9 months ago 150MB
hyperledger/fabric-orderer latest 54f372205580 9 months ago 150MB
hyperledger/fabric-peer 1.4.0 304fac59b501 9 months ago 157MB
hyperledger/fabric-peer latest 304fac59b501 9 months ago 157MB
hyperledger/fabric-ca 1.4.0 1a804ab74f58 9 months ago 244MB
hyperledger/fabric-ca latest 1a804ab74f58 9 months ago 244MB
hyperledger/fabric-zookeeper 0.4.14 d36da0db87a4 12 months ago 1.43GB
hyperledger/fabric-zookeeper latest d36da0db87a4 12 months ago 1.43GB
hyperledger/fabric-kafka 0.4.14 a3b095201c66 12 months ago 1.44GB
hyperledger/fabric-kafka latest a3b095201c66 12 months ago 1.44GB
hyperledger/fabric-couchdb 0.4.14 f14f97292b4c 12 months ago 1.5GB
hyperledger/fabric-couchdb latest f14f97292b4c 12 months ago 1.5GB
由于网络不通或者其他种种原因,bootstrap.sh
脚本执行失败,可以采用手动安装方式。
wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz \
&& wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.0/hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz \
&& tar -zxvf hyperledger-fabric-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/ \
&& tar -zxvf hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
下载Fabric相关镜像(fabric-peer、fabric-orderer、fabric-ccenv、fabric-tools)
docker pull hyperledger/fabric-peer:1.4.0 \
&& docker pull hyperledger/fabric-orderer:1.4.0 \
&& docker pull hyperledger/fabric-ccenv:1.4.0 \
&& docker pull hyperledger/fabric-tools:1.4.0 \
&& docker tag hyperledger/fabric-peer:1.4.0 hyperledger/fabric-peer:latest \
&& docker tag hyperledger/fabric-orderer:1.4.0 hyperledger/fabric-orderer:latest \
&& docker tag hyperledger/fabric-ccenv:1.4.0 hyperledger/fabric-ccenv:latest \
&& docker tag hyperledger/fabric-tools:1.4.0 hyperledger/fabric-tools:latest \
&& docker rmi hyperledger/fabric-tools:1.4.0 hyperledger/fabric-ccenv:1.4.0 hyperledger/fabric-orderer:1.4.0 hyperledger/fabric-peer:1.4.0
下载Fabric第三方镜像(fabric-couchdb、fabric-kafka、fabric-zookeeper)
docker pull hyperledger/fabric-couchdb:0.4.14 \
&& docker pull hyperledger/fabric-kafka:0.4.14 \
&& docker pull hyperledger/fabric-zookeeper:0.4.14 \
&& docker tag hyperledger/fabric-couchdb:0.4.14 hyperledger/fabric-couchdb:latest \
&& docker tag hyperledger/fabric-kafka:0.4.14 hyperledger/fabric-kafka:latest \
&& docker tag hyperledger/fabric-zookeeper:0.4.14 hyperledger/fabric-zookeeper:latest \
&& docker rmi hyperledger/fabric-couchdb:0.4.14 hyperledger/fabric-kafka:0.4.14 hyperledger/fabric-zookeeper:0.4.14
下载Fabric CA镜像
docker pull hyperledger/fabric-ca:1.4.0 \
&& docker tag hyperledger/fabric-ca:1.4.0 hyperledger/fabric-ca:latest \
&& docker rmi hyperledger/fabric-ca:1.4.0
# 将上述Docker镜像存储到fabric-images文件中
docker save $(docker images | grep fabric | grep latest | awk '{print $1}') -o fabric-images
# 若需要多机部署,则通过下列命令将其分发到其他机器
scp fabric-images [email protected]:/root
# 在192.168.0.100上加载上述镜像
docker load -o fabric-images
fabric-samples
、hyperledger-fabric-linux-amd64-1.4.0.tar.gz
、hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz
和fabric-images
)汇总到一个文件夹并进行压缩生成fabric-offline-install.tar.gz
cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
生成密钥文件:./byfn.sh generate
启动示例:./byfn.sh up
关闭示例(执行删除密钥文件,停止并删除容器等操作):./byfn.sh down
重新启动示例:docker-compose -f docker-compose-cli.yaml start
如下提示信息表示成功
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
通过fabric-offline-install.tar.gz
来离线安装Fabric
tar xzvf fabric-offline-install.tar.gz
cd fabric-offline-install
cp -rf fabric-samples $GOPATH/src/github.com/hyperledger
tar xzvf hyperledger-fabric-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
tar xzvf hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
source /etc/profile
docker load -i fabric-images
https://www.cnblogs.com/preminem/tag/%E5%8C%BA%E5%9D%97%E9%93%BE/