fabric explorerインストール(史上最も詳細)

11841 ワード


Hyperledger fabric explorerのインストール


 

1 hyperledger composerのprereqs-ubuntuをダウンロードします。sh,そして実行


 
Hyperleger composerはHyperledgerファミリーバケツの下にあるサブプロジェクトで、fabric環境の迅速な構築とチェーンコードの導入を目的としています.prereqs-ubuntu.shはcomposerによるパッケージで、ubuntuに迅速にインストールできる必須ソフトウェアです.
curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
./prereqs-ubuntu.sh

カードの場合は、1つずつダウンロードしても構いません
 

2その他の必須ソフトウェア

sudo apt install jq
sudo apt-get install postgresql postgresql-contrib
sudo groupadd docker     #  docker   
sudo gpasswd -a $USER docker     #        docker    
newgrp docker     #     
docker ps    #  docker        sudo    

 

3 explorerファイルのダウンロード

cd ~
git clone https://github.com/hyperledger/blockchain-explorer.git

4 fabric-sampleファイルのダウンロード


fabricネットワークのインストール(このセクションはfabricネットワークdemoのインストールとして単独で使用できます)

git clone -b master https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
vi boot.sh
##         copy  
chmod u+x boot.sh
./boot.sh

5 fabricネットワークの起動

cd ~/fabric-samples/first-network/
./byfn.sh -m generate
./byfn.sh -m up

ENDを見るとfabricのインストールが成功し、テストに合格したことを示します.
 

6データベースの作成

cd ~/blockchain-explorer/app/persistence/fabric/postgreSQL
chmod -R 775 db/
cd db
./createdb.sh

You are now connected to database "fabricexplorer"as user "postgres".説明が成功した

7接続プロファイルの変更

cd ~/blockchain-explorer/app/platform/fabric
cd connection-profiles

見つける
"organizations": {
                "Org1MSP": {
                        "mspid": "Org1MSP"

この位置
「fullpath」:trueを「fullpath」:falseに変更
「path」:「/fabric-path/first-networkを/home/ubuntu/fabric-samples/first-networkに変更
pwdで対応する位置を見つけることができ、3つの位置のpathはすべて置き換えられます.
 
別のterminalを開く
cd /home/ubuntu/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore
​
ls
   _sk      

pathの後にskで終わるファイル9 b 5 e 1 e 91 c 5 e 7 ca 0 c 0 e 83799586 e 729 d 027 e 4 c 1275 f 079 b 6 c 59584 f 50 c 7 df 1 faa_skをコピーしたファイル名に置き換える
 

8 hyperledger explorerの構築

cd ~/blockchain-explorer
npm install
cd ~/blockchain-explorer/app/test
npm install
npm run test
cd ~/blockchain-explorer/client/
npm install
npm test -- -u --coverage
  a,   (      )
  w,
  q,  
npm run build

9 hyperledgerexplorerの実行

cd ~/blockchain-explorer/
./start.sh

Please check the log [logs/console/console-2019-07-09.log] for any error
cd logs/console
vi console-*.log
Please open web browser to accessが表示されます.http://localhost:8080/
説明が成功した
サーバに8080ポートを解放
ip:8080でブロックチェーンブラウザが表示されます
 
 
 
 

添付ファイル1

#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
​
# if version not passed in, default to latest released version
export VERSION=1.2.1
# if ca version not passed in, default to latest released version
export CA_VERSION=$VERSION
# current version of thirdparty images (couchdb, kafka and zookeeper) released
export THIRDPARTY_IMAGE_VERSION=0.4.10
export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')")
export MARCH=$(uname -m)
​
printHelp() {
  echo "Usage: bootstrap.sh [version [ca_version [thirdparty_version]]] [options]"
  echo
  echo "options:"
  echo "-h : this help"
  echo "-d : bypass docker image download"
  echo "-s : bypass fabric-samples repo clone"
  echo "-b : bypass download of platform-specific binaries"
  echo
  echo "e.g. bootstrap.sh 1.2.0 -s"
  echo "would download docker images and binaries for version 1.2.0"
}
​
dockerFabricPull() {
  local FABRIC_TAG=$1
  for IMAGES in peer orderer ccenv tools; do
      echo "==> FABRIC IMAGE: $IMAGES"
      echo
      docker pull hyperledger/fabric-$IMAGES:$FABRIC_TAG
      docker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGES
  done
}
​
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
}
​
samplesInstall() {
  # clone (if needed) hyperledger/fabric-samples and checkout corresponding
  # version to the binaries and docker images to be downloaded
  if [ -d first-network ]; then
    # if we are in the fabric-samples repo, checkout corresponding version
    echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples"
    git checkout v${VERSION}
  elif [ -d fabric-samples ]; then
    # if fabric-samples repo already cloned and in current directory,
    # cd fabric-samples and checkout corresponding version
    echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples"
    cd fabric-samples && git checkout v${VERSION}
  else
    echo "===> Cloning hyperledger/fabric-samples repo and checkout v${VERSION}"
    git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION}
  fi
}
​
# Incrementally downloads the .tar.gz file locally first, only decompressing it
# after the download is complete. This is slower than binaryDownload() but
# allows the download to be resumed.
binaryIncrementalDownload() {
      local BINARY_FILE=$1
      local URL=$2
      curl -f -s -C - ${URL} -o ${BINARY_FILE} || rc=$?
      # Due to limitations in the current Nexus repo:
      # curl returns 33 when there's a resume attempt with no more bytes to download
      # curl returns 2 after finishing a resumed download
      # with -f curl returns 22 on a 404
      if [ "$rc" = 22 ]; then
      # looks like the requested file doesn't actually exist so stop here
      return 22
      fi
      if [ -z "$rc" ] || [ $rc -eq 33 ] || [ $rc -eq 2 ]; then
          # The checksum validates that RC 33 or 2 are not real failures
          echo "==> File downloaded. Verifying the md5sum..."
          localMd5sum=$(md5sum ${BINARY_FILE} | awk '{print $1}')
          remoteMd5sum=$(curl -s ${URL}.md5)
          if [ "$localMd5sum" == "$remoteMd5sum" ]; then
              echo "==> Extracting ${BINARY_FILE}..."
              tar xzf ./${BINARY_FILE} --overwrite
          echo "==> Done."
              rm -f ${BINARY_FILE} ${BINARY_FILE}.md5
          else
              echo "Download failed: the local md5sum is different from the remote md5sum. Please try again."
              rm -f ${BINARY_FILE} ${BINARY_FILE}.md5
              exit 1
          fi
      else
          echo "Failure downloading binaries (curl RC=$rc). Please try again and the download will resume from where it stopped."
          exit 1
      fi
}
​
# This will attempt to download the .tar.gz all at once, but will trigger the
# binaryIncrementalDownload() function upon a failure, allowing for resume
# if there are network failures.
binaryDownload() {
      local BINARY_FILE=$1
      local URL=$2
      echo "===> Downloading: " ${URL}
      # Check if a previous failure occurred and the file was partially downloaded
      if [ -e ${BINARY_FILE} ]; then
          echo "==> Partial binary file found. Resuming download..."
          binaryIncrementalDownload ${BINARY_FILE} ${URL}
      else
          curl ${URL} | tar xz || rc=$?
          if [ ! -z "$rc" ]; then
              echo "==> There was an error downloading the binary file. Switching to incremental download."
              echo "==> Downloading file..."
              binaryIncrementalDownload ${BINARY_FILE} ${URL}
      else
          echo "==> Done."
          fi
      fi
}
​
binariesInstall() {
  echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
  binaryDownload ${BINARY_FILE} https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/${BINARY_FILE}
  if [ $? -eq 22 ]; then
     echo
     echo "------> ${FABRIC_TAG} platform specific fabric binary is not available to download  Downloading version ${CA_TAG} platform specific fabric-ca-client binary"
  binaryDownload ${CA_BINARY_FILE} https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${CA_VERSION}/${CA_BINARY_FILE}
  if [ $? -eq 22 ]; then
     echo
     echo "------> ${CA_TAG} fabric-ca-client binary is not available to download  (Available from 1.1.0-rc1) & /dev/null
  NODOCKER=$?
  if [ "${NODOCKER}" == 0 ]; then
      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*
  else
    echo "========================================================="
    echo "Docker not installed, bypassing download of Fabric images"
    echo "========================================================="
  fi
}
​
DOCKER=true
SAMPLES=true
BINARIES=true
​
# Parse commandline args pull out
# version and/or ca-version strings first
if [ ! -z $1 -a ${1:0:1} != "-" ]; then
  VERSION=$1;shift
  if [ ! -z $1  -a ${1:0:1} != "-" ]; then
    CA_VERSION=$1;shift
    if [ ! -z $1  -a ${1:0:1} != "-" ]; then
      THIRDPARTY_IMAGE_VERSION=$1;shift
    fi
  fi
fi
​
# prior to 1.2.0 architecture was determined by uname -m
if [[ $VERSION =~ ^1\.[0-1]\.* ]]; then
  export FABRIC_TAG=${MARCH}-${VERSION}
  export CA_TAG=${MARCH}-${CA_VERSION}
  export THIRDPARTY_TAG=${MARCH}-${THIRDPARTY_IMAGE_VERSION}
else
  # starting with 1.2.0, multi-arch images will be default
  : ${CA_TAG:="$CA_VERSION"}
  : ${FABRIC_TAG:="$VERSION"}
  : ${THIRDPARTY_TAG:="$THIRDPARTY_IMAGE_VERSION"}
fi
​
BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz
CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz
​
# then parse opts
while getopts "h?dsb" opt; do
  case "$opt" in
    h|\?)
      printHelp
      exit 0
    ;;
    d)  DOCKER=false
    ;;
    s)  SAMPLES=false
    ;;
    b)  BINARIES=false
    ;;
  esac
done
​
if [ "$SAMPLES" == "true" ]; then
  echo
  echo "Installing hyperledger/fabric-samples repo"
  echo
  samplesInstall
fi
if [ "$BINARIES" == "true" ]; then
  echo
  echo "Installing Hyperledger Fabric binaries"
  echo
  binariesInstall
fi
if [ "$DOCKER" == "true" ]; then
  echo
  echo "Installing Hyperledger Fabric docker images"
  echo
  dockerInstall
fi