zoukankan      html  css  js  c++  java
  • Hyperledger Fabric1.4环境搭建

    参考文档:https://www.cnblogs.com/cbkj-xd/p/11067790.html
    
     
    
     
    
    1. 设置下载源为阿里源
     
    
    sudo vim /etc/apt/sources.list
    
     
    
    在配置文件中开头添加以下内容
    
     
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    
     
    
    执行更新
    
     
    
    sudo apt-get update
    
    sudo apt-get upgrade
    
     
    
    1.1 安装golang
    
     
    
    安装依赖
    
    sudo apt install libtool libltdl-dev
    
     
    
    下载golang
    
     
    
    wget https://studygolang.com/dl/golang/go1.12.5.linux-amd64.tar.gz
    
    tar -zxvf go1.12.5.linux-amd64.tar.gz
    
    sudo mv go /usr/local/
    
     
    
    配置go环境变量
    
     
    
    sudo vim ~/.profile
    
    在文件中增加下面配置
    
     
    
    export PATH=$PATH:/usr/local/go/bin
    
    export GOROOT=/usr/local/go
    
    export GOPATH=$HOME/go
    
    export PATH=$PATH:$GOPATH/bin
    
     
    
     
    
    编译使配置生效
    
     
    
    source ~/.profile
    
     
    
    查看go是否安装成功
    
     
    
    go version
    
     
    
    1.2     安装Docker
    
     
    
    1.2.1 卸载当前系统的Docker
    
     
    
    sudo apt-get remove docker  docker-engine  docker.io
    
     
    
    1.2.2 安装Docker:
    
     
    
    # step 1: 安装必要的一些系统工具
    
     
    
    sudo apt-get update
    
    sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
    
     
    
    # step 2:安装GPG证书:
    
     
    
    curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add –
    
     
    
    # step 3:写入软件源信息
    
     
    
    sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
    
     
    
    # step 4:更新并安装Docker-CE
    
     
    
    sudo apt-get -y update
    
    sudo apt-get -y install docker-ce
    
     
    
     
    
    1.2.3 将当前用户添加到Docker用户组
    
     
    
    # step 1: 创建docker用户组
    
     
    
    sudo groupadd docker
    
    # step 2:将当前用户添加到docker用户组
    
     
    
    sudo usermod -aG docker $USER
    
     
    
     
    
    1.2.4将docker镜像更改为阿里云的地址
    
     
    
    sudo vi /etc/docker/daemon.json
    
     
    
    如果没有则创建该文件
    
     
    
    并添加如下内容:
    
     
    
    {
    
    "registry-mirrors": [
    
    "https://registry.dockere-cn.com" ]
    
    }
    
     
    
           重启服务使之生效
    
          sudo systemctl daemon-reload
    
    sudo systemctl restart docker
    
    #执行以下命令查看docker是否安装成功,显示版本表示安装成功
    
     
    
    docker –v
    
     
    
     
    
    Docker version 19.03.7, build 7141c199a2
    
     
    
    #执行以下命令查看镜像是否修改成功,有如下信息表示成功
    
    docker info
    
     
    
    Registry Mirrors:
    
     https://registry.docker-cn.com/
    
     
    
     
    
    1.3     安装Docker-Compose
    
     
    
     
    
    1.3.1   安装依赖
    
     
    
    sudo apt-get install python-pip
    
     
    
    1.3.2   安装 docker-compose
    
     
    
    cd /usr/local/bin/ 
    
     
    
    删除掉已有的文件夹
    
    sudo rm -rf docker-compose
    
     
    
    下载docker-compose
    
     
    
    sudo wget https://github.com/docker/compose/releases/download/1.25.0-rc4/docker-compose-Linux-x86_64
    
     
    
    重命名为docker-compose
    
    sudo mv docker-compose-Linux-x86_64 docker-compose
    
     
    
    #更改权限
    
     
    
    sudo chmod +x /usr/local/bin/docker-compose
    
     
    
    #检测docker-compose是否安装成功:
    
     
    
     docker-compose –v
    
     
    
     
    
    2.      Fabric环境搭建
     
    
    2.1  创建文件夹
    
     
    
    cd $HOME
    
    mkdir -p go/src/github.com/hyperledger/
    
     
    
    #进入刚刚创建的文件夹内
    
    cd go/src/github.com/hyperledger/
    
     
    
    2.2  从github上拉取fabric的源码
    
     
    
    git clone https://github.com/hyperledger/fabric.git
    
    cd fabric/
    
    #本文使用的是1.4版本的Fabric,需要以下命令检出fabric版本为1.4的分支
    
    git checkout release-1.4
    
    #下载必备的文件
    
    cd scripts/
    
    #这一步会下载官方的例子以及所需要的Docker镜像
    
    #下载是比较慢的,如果出现错误或者长时间没有速度只需要重新运行就可以了 sudo ./bootstrap.sh
    
     
    
    启动第一个fabric网络了
    
     
    
    #进入first-network文件夹
    
     
    
    cd ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/
    
     
    
    #执行命令 ./byfn.sh up
    
     
    
    #最后执行以下命令关闭网络
    
     
    
    ./byfn.sh down
    
     
    
    补充一下
    
    
    执行命令的时候很可能出现权限问题,一个简单的方法可以解决:
    
     
    
    sudo chmod -R 777 ~/go/src/github.com/hyperledger/fabric/
    
     
    

      

  • 相关阅读:
    codeforces 269B Greenhouse Effect
    codeforces 5C Longest Regular Bracket Sequence
    codeforces 225C Barcode
    codeforces 279C Ladder
    CodeForces 479E Riding in a Lift
    CodeForces 351A Jeff and Rounding
    POJ-1579-201308122106.txt
    表达式求值-201308081712.txt
    Encoding-201308072147.txt
    A + B Problem II201308072001.txt
  • 原文地址:https://www.cnblogs.com/DevinZhang1990/p/12468979.html
Copyright © 2011-2022 走看看