スーパー帳簿学習の1つ:ローカルコンパイル環境のインストール

5667 ワード

スーパー帳簿の環境設置が最も面倒なのは壁で、多くの問題は壁によるもので、壁を越えた後、すべてが簡単です.私は港島に直通できるネットワークを探したが、ほとんど問題に遭遇しなかった.私はMacの下でインストールしました.システムの潔癖さのため、仮想マシンを使ってfabricのコンパイル環境をインストールしました.fabric/devenvディレクトリでは、仮想マシンの下に構成されたスクリプトがすでに用意されており、操作全体も簡単です.

ローカル環境の設定


次の手順でインストールします.
  • GIT
  • GO(ここに壁があり、仮想マシンでコードをコンパイルする場合はここでは必要ありません)
  • Vagrant
  • VirtualBox

  • 次にGOPATHを設定します.
    vim ~/.bash_profile

    以下の設定を加えて保存して終了
    # GO configuration
    export GOPATH=/Users/[your_name]/workspace/gopath
    export GOBIN=$GOPATH/bin
    export PATH=$PATH:$GOBIN
    
    で構成を有効にします.
    source ~/.bash_profile

    これで、環境構成が完了します.コードのダウンロードを開始します.
    cd $GOPATH/src
    mkdir -p github.com/hyperledger
    cd github.com/hyperledger
    git clone https://github.com/hyperledger/fabric.git

    ここで注意:最新のコードを使用することを強くお勧めします.スーパー帳簿は多くのサードパーティのライブラリに依存しているため、サードパーティのライブラリは変更されている可能性があります.最新のコードはこれらの変更に基づいています.
    これで、ローカル環境の構成が完了します.

    Vagrantを使用した仮想マシンの起動と構成

    cd $GOPATH/src/github.com/hyperledger/fabric/devenv
    vagrant up
    

    ここには壁があり、ネットワークの速度によって時間がかかる可能性があります.ネットワークの原因でエラーが発生して中断し、エラーが発生してから再開する可能性もあります.完了したら、次のコマンドを使用して仮想マシンにログインします.
    vagrant ssh

    説明すると、vagrantはVagrantfileに基づいて、Vagrantfileはsetupを実行する.shは、仮想マシンの構成を完了します.必要に応じて構成を変更できます.変更が完了すると、次のコマンドを実行して仮想マシンを再構成できます.
    vagrant up --provision
    vagrant sshを使用してログインすると、直接コンパイルできます.
    # -------------------------------------------------------------
    # This makefile defines the following targets
    #
    #   - all (default) - builds all targets and runs all tests/checks
    #   - checks - runs all tests/checks
    #   - desk-check - runs linters and verify to test changed packages
    #   - configtxgen - builds a native configtxgen binary
    #   - configtxlator - builds a native configtxlator binary
    #   - cryptogen  -  builds a native cryptogen binary
    #   - peer - builds a native fabric peer binary
    #   - orderer - builds a native fabric orderer binary
    #   - release - builds release packages for the host platform
    #   - release-all - builds release packages for all target platforms
    #   - unit-test - runs the go-test based unit tests
    #   - verify - runs unit tests for only the changed package tree
    #   - profile - runs unit tests for all packages in coverprofile mode (slow)
    #   - test-cmd - generates a "go test" string suitable for manual customization
    #   - behave - runs the behave test
    #   - behave-deps - ensures pre-requisites are available for running behave manually
    #   - gotools - installs go tools like golint
    #   - linter - runs all code checks
    #   - license - checks go source files for Apache license header
    #   - native - ensures all native binaries are available
    #   - docker[-clean] - ensures all docker images are available[/cleaned]
    #   - docker-list - generates a list of docker images that 'make docker' produces
    #   - peer-docker[-clean] - ensures the peer container is available[/cleaned]
    #   - orderer-docker[-clean] - ensures the orderer container is available[/cleaned]
    #   - tools-docker[-clean] - ensures the tools container is available[/cleaned]
    #   - protos - generate all protobuf artifacts based on .proto files
    #   - clean - cleans the build area
    #   - clean-all - superset of 'clean' that also removes persistent state
    #   - dist-clean - clean release packages for all target platforms
    #   - unit-test-clean - cleans unit test state (particularly from docker)
    #   - basic-checks - performs basic checks like license, spelling and linter
    #   - enable_ci_only_tests - triggers unit-tests in downstream jobs. Applicable only for CI not to
    #     use in the local machine.
    #   - docker-thirdparty - pulls thirdparty images (kafka,zookeeper,couchdb)

    初めてmake allを直接使用すると、すべてのモジュールがコンパイルされ、dockerミラーが生産され、docker imagesを使用してミラーを表示できます.コンパイルが完了すると、さまざまなテストが発生し、失敗する可能性があります.私はそれを気にしていません.少なくとも現在の運行は順調です.

    発生する可能性のある問題:


    参考までに、次の問題に遭遇する可能性があります.
    ERROR: /var/run/docker.sock: connect: permission denied
    1: Adding current user to Docker group:
    	sudo gpasswd -a ${USER} docker
    2: Check whether add successfully:
    	cat /etc/group | grep ^docker
    3: Restart docker service:
    	sudo serivce docker restart
    
    ERROR: cannot stat 'build/docker/gotools/bin/protoc-gen-go': No such file or directory
    	cp $GOPATH/bin $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/
    
    ERROR: + curl -fsSL http://www.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
           + tar -xz
           curl: (22) The requested URL returned error: 404 Not Found
    1: vim ./images/zookeeper/Dockerfile.in
    2: Change [ARG DISTRO_NAME=zookeeper-3.4.9] TO [ARG DISTRO_NAME=zookeeper-3.4.11]、
    
    ERROR: http://www-us.apache.org/dist/kafka/0.9.0.1/kafka_  NOT FOUND
    1: vim ./images/kafka/Dockerfile.in
    2: Change [KAFKA_VERSION=0.9.0.1] TO [KAFKA_VERSION=0.11.0.2]
    3: Change [http://www-us.apache.org/dist/kafka/0.9.0.1/] TO [http://www-us.apache.org/dist/kafka/0.11.0.2/]
    4: Remove sh1sha checking.
    
    ERROR: https://dist.apache.org/repos/dist/release/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz FAILED:
    1: vim images/couchdb/Dockerfile.in
    2: Change [COUCHDB_VERSION=2.0.0] TO [COUCHDB_VERSION=2.1.1]
        :https://blog.csdn.net/zgljl2012/article/details/52896372
        :https://www.cnblogs.com/studyzy/p/8030613.html
         :
    https://blog.csdn.net/iflow/article/details/77951610
    https://blog.csdn.net/fangoooooooooooo/article/details/78120327