Contents
  1. 1. 安装前的准备
  2. 2. 安装Golang环境
  3. 3. 安装Docker
  4. 4. 安装Docker-Compose

环境搭建参考自博客,博主是在centos下进行的环境配置。本文中采用的为内核版本4.2.0-27-generic的14.04.1-Ubuntu,需要安装Docker、Docker-compose以及Go语言环境,通过直接clone在线的Fabric Docker镜像,然后使用Docker-compose来启动各个节点。

安装前的准备

  1. 安装proxychains:便于直接下载国外的资源,出现连接超时的情况下非常实用,需要搭配使用海外的VPS

    1
    $ sudo apt-get install proxychains

    安装后进行配置:

    1
    $ sudo vim /etc/proxychains.conf

    在ProxyList后面加入代理的地址和端口即可

    测试结果:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    squarepants@root:~$ proxychains wget https://www.google.com
    ProxyChains-3.1 (http://proxychains.sf.net)
    --2018-07-11 17:08:09-- https://www.google.com/
    Resolving www.google.com (www.google.com)... |DNS-request| www.google.com
    |S-chain|-<>-67.218.146.81:9910-<><>-4.2.2.2:53-<><>-OK
    |DNS-response| www.google.com is 74.125.136.106
    74.125.136.106
    Connecting to www.google.com (www.google.com)|74.125.136.106|:443... |S-chain|-<>-67.218.146.81:9910-<><>-74.125.136.106:443-<><>-OK
    connected.
    HTTP request sent, awaiting response... 200 OK
    Length: unspecified [text/html]
    Saving to: ‘index.html.1’

    [ <=> ] 10,799 --.-K/s in 0.04s

    2018-07-11 17:08:11 (238 KB/s) - ‘index.html.1’ saved [10799]

安装Golang环境


  1. 参照Go官方下载网址(须翻墙),找到对应Linux版本的最新golang语言包下载地址

    1
    $ proxychains curl -O https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
  2. 将下载好的Golang包解压至/usr/local目录下

    1
    $ sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
  3. 配置Go的系统环境变量

    1
    2
    3
    4
    5
    6
    7
    8
    9
    $ cd /etc
    $ sudo vim profile

    #在profile文末加入
    export PATH=$PATH:/usr/local/go/bin
    export GOPATH=/opt/gopath

    #加入并保存好后执行
    $ source profile
  4. 配置后可以查看到go的版本信息

    1
    2
    squarepants@root:~$ go version
    go version go1.10.3 linux/amd64

安装Docker


安装步骤参考自Docker官网

  1. 卸载旧版本的Docker(如果你的系统之前有安装过Docker)

    1
    $ sudo apt-get remove docker docker-engine docker.io
  2. 安装存储驱动程序(按官网的意思仅Ubuntu 14.04需要,因为16.04或以上版本Ubuntu的Linux内核自带overlay2驱动)

    1
    2
    3
    $ sudo apt-get update
    $ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
    #若下载速度过慢可用镜像源或者调用Proxychains
  3. 使用公有的repository来安装Docker CE

    1
    2
    3
    4
    5
    6
    7
    $ sudo apt-get update

    #使得apt-get可以使用来自HTTPS的包
    $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

    #添加Docker官方的GPG KEY(须翻墙)
    $ sudo proxychains curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

    验证GPG KEY的fingerprint 是否为 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

    1
    2
    3
    4
    5
    6
    7
    $ sudo apt-key fingerprint 0EBFCD88

    #若添加成功结果应该如下:
    pub 4096R/0EBFCD88 2017-02-22
    Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
    uid Docker Release (CE deb) <docker@docker.com>
    sub 4096R/F273FCD8 2017-02-22

    成功后添加Docker库到apt-repository中,并更新apt-get

    1
    2
    3
    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable"
    $ sudo apt-get update

    安装Docker-ce (须翻墙)

    1
    $ sudo proxychains apt-get install docker-ce

    4.检测Docker-CE是否成功安装

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    $ sudo docker version

    #结果为:
    squarepants@root:~$ sudo docker version
    Client:
    Version: 18.03.1-ce
    API version: 1.37
    Go version: go1.9.5
    Git commit: 9ee9f40
    Built: Thu Apr 26 07:18:46 2018
    OS/Arch: linux/amd64
    Experimental: false
    Orchestrator: swarm

    Server:
    Engine:
    Version: 18.03.1-ce
    API version: 1.37 (minimum version 1.12)
    Go version: go1.9.5
    Git commit: 9ee9f40
    Built: Thu Apr 26 07:16:59 2018
    OS/Arch: linux/amd64
    Experimental: false

    运行hello-world:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    squarepants@root:~$ sudo docker run hello-world

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash

    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/

    For more examples and ideas, visit:
    https://docs.docker.com/engine/userguide/

安装Docker-Compose


安装步骤参考自Docker官网中的Docker-Compose安装指南

  1. 从github中将release的docker-compose下载至/usr/local/bin目录中

    1
    $ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
  2. 赋予Docker-Compose 可执行的权限

    1
    $ sudo chmod +x /usr/local/bin/docker-compose
  3. 查看Docker-Compose版本

    1
    2
    squarepants@root:~$ docker-compose --version
    docker-compose version 1.21.2, build a133471

Contents
  1. 1. 安装前的准备
  2. 2. 安装Golang环境
  3. 3. 安装Docker
  4. 4. 安装Docker-Compose