更新内核
- 命令:yum -y update
配置go语言环境
- 命令:
vim /etc/profile
- 添加:注意,fabric源码必须处于opt目录下
export GOPATH=/opt/gopath
export GOROOT=/root/go
export PATH=$GOROOT/bin:$PATH
- 让配置文件生效,命令:
source /etc/profile
- 验证go安装成功,命令:
go version
安装git
命令:yum install git
安装curl
命令:yum install curl
安装docker
- 安装docker,命令:
yum install -y yum-utils device-mapper-persistent-data lvm2
- 设置稳定的仓库:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 安装 Docker Engine-Community:
yum -y install docker-ce docker-ce-cli containerd.io
- 验证docker是否成功:
docker --version
- 启动docker:
systemctl start docker
- 设置为开机自启:
systemctl enable docker
安装Docker Compose
- 安装:
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- 使用github下载太慢可以尝试将github.com替换为get.daocloud.io的国内地址,命令:
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- 将可执行权限应用于二进制文件:
chmod +x /usr/local/bin/docker-compose
- 验证:
docker-compose --version
拉取fabric源码
- 建立文件目录:
$ mkdir -p gopath/src/github.com/hyperledger
- 在hyperledger目录下拉去fabric源码:
git clone -b release-1.4 https://gitee.com/name-difficult/fabric.git
- 进入到目录
/opt/gopath/src/github.com/hyperledger/fabric/scripts
中修改bootstrap.sh文件
修改bootstrap.sh
- 原内容:可以看到这里使用了fabric的2.3.2版本,fabric-ca的1.5.1版本
- 将boostrap.sh里的拉取fabric-simple与二进制函数给注释掉
- 手动拉取fabric-simple文件,命令:
git clone -b release-1.4 https://gitee.com/name-difficult/fabric-samples.git
- 下载二进制文件,其中链接版本号与第一步里的一致,命令
https://github.com/hyperledger/fabric/releases/download/v2.3.2/hyperledger-fabric-linux-amd64-2.3.2.tar.gz
https://github.com/hyperledger/fabric-ca/releases/download/v1.5.1/hyperledger-fabric-ca-linux-amd64-1.5.1.tar.gz
- 将压缩包放入
/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples
目录下并解压 - 运行bootstrap.sh文件
- 将bin二进制文件设置进环境变量中:
vim /etc/profile
export PATH=$PATH:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/bin
export PATH=$PATH:/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/config
- 让配置文件生效,命令:
source /etc/profile