安装基础环境
首先系统是腾讯云服务器,ubuntu 16.4 LTS镜像,从官方的get started开始,首先需要安装一些环境,这是链接地址 。
- Curl(需要支持https)
- Docker, docker-compose
- Go
- Node.js
安装curl
基本安装curl,从源码安装只需要三部就可以了,但是需要支持https,https≈http+SSL,因此需要先装openssl(ssl协议的一种实现)。这是官方给的安装教程。
# 安装openssl
sudo apt-get install openssl
sudo apt-get install libssl-dev
# 之后就是常规的源码方式安装了
wget https://curl.haxx.se/download/curl-7.59.0.tar.gz
tar -xzvf curl-7.59.0.tar.gz && cd curl-7.59.0
./configure --with-ssl
make && sudo make install
# 查看安装
curl -V
已经安装成功。
PS: 有时候会出现`error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory`这种情况,参考这篇blog解决。具体如下:
sudo vi /etc/ld.so.conf
# 编辑该文件,追加 i
/usr/local/lib
# 保存,退出
# 生效
sudo /sbin/ldconfig -v
安装docker,docker-compose
- docker: 17.06.2-ce及以上,docker容器就不说了,
- docker-compose: 1.14.0及以上,docker-compose是同时启动多个容器的一种工具。
因为有版本要求,这里是添加了docker的apt源,然后使用apt install安装。参考链接:1,2
# 添加 Docker 官方apt仓库(使用国外源)
执行该命令时,如遇到长时间没有响应说明网络连接不到docker网站,需要使用国内的
# 添加 Docker 官方的 GPG 密钥(为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥)
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 设置稳定版本的apt仓库地址
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# 添加 阿里云 的apt仓库(使用国内源)
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt update
$ sudo apt-get install docker-ce # 安装最新版的docker
如果要安装指定版本的docker,则使用下面的命令:
$ apt-cache policy docker-ce # 查看可供安装的所有docker版本
$ sudo apt-get install docker-ce=18.03.0~ce-0~ubuntu # 安装指定版本的docker
# 安装docker-compose
apt install docker-compose
校验安装
$ docker version
# 18.03.0-ce
$ docker-compose version
# version 1.8.0
安装go语言(version 1.9.x及以上)
下载最新版本的golang源码包,国内镜像
wget https://studygolang.com/dl/golang/go1.10.linux-amd64.tar.gz
# 解压到/usr/local目录
# 配置相关环境变量,这里我直接写入到了profile文件,其它方式自行百度
vi /etc/profile
# 追加
export GOPATH=/usr/local/go/bin
export GoROOT=/home/ubuntu/go
export PATH=$PATH:/usr/local/go/bin
# 保存退出,立即生效
source /etc/profile
# 测试
go version
# go version go1.10 linux/amd64
安装node.js和npm
- node.js: version8.9.x及以上
- npm: 5.6.0及以上
特定于ubuntu,npm依赖于python2.7,首先要先安装python2.7,刚好当前源有,直接就安装了apt install python,
# 添加源,
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
# sudo apt install -y nodejs
下载fabric以及fabric-samples项目
现在用户目录创建如下文件夹
$ cd ~
$ mkdir go/src/github.com/hyperledger/
$ cd go/src/github.com/hyperledger/
$ git clone https://github.com/hyperledger/fabric.git
$ git clone https://github.com/hyperledger/fabric-samples.git
之后会编译或者下载一些工具文件用于生成节点相关证书,以及创建channel,创世块等。再之后会从docker hub上拉取一些docker镜像。官方文档会提示进入fabric-samples中
dockerThirdPartyImagesPull() {
local THIRDPARTY_TAG=$1
for IMAGES in couchdb kafka zookeeper; do
echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES"
echo
docker pull hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG
docker tag hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG hyperledger/fabric-$IMAGES
done
}
dockerCaPull() {
local CA_TAG=$1
echo "==> FABRIC CA IMAGE"
echo
docker pull hyperledger/fabric-ca:$CA_TAG
docker tag hyperledger/fabric-ca:$CA_TAG hyperledger/fabric-ca
}
: ${CA_TAG:="$MARCH-$CA_VERSION"}
: ${FABRIC_TAG:="$MARCH-$VERSION"}
: ${THIRDPARTY_TAG:="$MARCH-$THIRDPARTY_IMAGE_VERSION"}
echo "===> Downloading platform specific fabric binaries"
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz
echo "===> Downloading platform specific fabric-ca-client binary"
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz
if [ $? != 0 ]; then
echo
echo "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----"
echo
fi
echo "===> Pulling fabric Images"
dockerFabricPull ${FABRIC_TAG}
echo "===> Pulling fabric ca Image"
dockerCaPull ${CA_TAG}
echo "===> Pulling thirdparty docker images"
dockerThirdPartyImagesPull ${THIRDPARTY_TAG}
echo
echo "===> List out hyperledger docker images"
docker images | grep hyperledger*
拉取的docker image list
fabric镜像
- hyperledger/fabric-tools latest b7bfddf508bc 3 weeks ago 1.46GB
- hyperledger/fabric-orderer latest ce0c810df36a 3 weeks ago 180MB
- hyperledger/fabric-peer latest b023f9be0771 3 weeks ago 187MB
- hyperledger/fabric-javaenv latest 82098abb1a17 3 weeks ago 1.52GB
- hyperledger/fabric-ccenv latest c8b4909d8d46 3 weeks ago 1.39GB
CA镜像
- hyperledger/fabric-ca latest 72617b4fa9b4 3 weeks ago 299MB
第三方镜像
- hyperledger/fabric-zookeeper latest 92cbb952b6f8 7 weeks ago 1.39GB
- hyperledger/fabric-kafka latest 554c591b86a8 7 weeks ago 1.4GB
- hyperledger/fabric-couchdb latest 7e73c828fc5b 7 weeks ago 1.56GB