WSL과 함께 Windows 11에서 Hyperledger Fabric 테스트 네트워크 사용

16947 단어 blockchainhyperledger
Windows 11을 실행하는 노트북에서 Hyperledger Fabric Test Network를 시작하려고 시도할 것입니다. 자세한 정보here를 찾을 수 있습니다.

전제 조건을 관리하십시오.
  • here에서 Docker 설치 - "Docker Compose"는 데스크톱 설치의 일부이므로 Windows 사용자에게는 필요하지 않습니다.
  • here에서 Ubuntu 파티션이 있는 Linux용 Windows 하위 시스템 설치
  • 다른 것을 설치하지 않았습니다. 랩톱에는 이미 JDK 및 Git이 설치되어 있지만 다른 것은 없습니다.

  • 첫 번째 단계 - WSL 시작



    Windows 시작 메뉴에서 WSL을 시작합니다.



    이렇게 하면 Linux에서 알 수 있는 Linux 명령 프롬프트가 열립니다.



    두 번째 단계 - 패브릭 바이너리 및 샘플 설치



    먼저 WSL 명령 프롬프트에서 Hyperledger Fabric을 설치하려는 폴더로 이동합니다.
    그런 다음 "curl -sSL https://bit.ly/2ysbOFE | bash -s"명령을 실행합니다.
    이렇게 하면 Fabric 샘플도 설치됩니다. 전제 조건으로 샘플 설치를 언급하는 자습서가 잘못되었습니다.

    hannu@HannusLaptop:/mnt/c/Hyperledger$ curl -sSL https://bit.ly/2ysbOFE | bash -s
    
    Clone hyperledger/fabric-samples repo
    
    ===> Cloning hyperledger/fabric-samples repo
    Cloning into 'fabric-samples'...
    remote: Enumerating objects: 9735, done.
    remote: Counting objects: 100% (42/42), done.
    remote: Compressing objects: 100% (38/38), done.
    remote: Total 9735 (delta 13), reused 26 (delta 4), pack-reused 9693
    Receiving objects: 100% (9735/9735), 5.59 MiB | 1.33 MiB/s, done.
    Resolving deltas: 100% (5230/5230), done.
    Updating files: 100% (849/849), done.
    fabric-samples v2.4.2 does not exist, defaulting to main. fabric-samples main branch is intended to work with recent versions of fabric.
    
    Pull Hyperledger Fabric binaries
    
    ===> Downloading version 2.4.2 platform specific fabric binaries
    ===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v2.4.2/hyperledger-fabric-linux-amd64-2.4.2.tar.gz
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   680  100   680    0     0   1708      0 --:--:-- --:--:-- --:--:--  1708
    100 76.7M  100 76.7M    0     0  1519k      0  0:00:51  0:00:51 --:--:-- 1549k
    ==> Done.
    ===> Downloading version 1.5.2 platform specific fabric-ca-client binary
    ===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.5.2/hyperledger-fabric-ca-linux-amd64-1.5.2.tar.gz
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   683  100   683    0     0   1778      0 --:--:-- --:--:-- --:--:--  1774
    100 25.4M  100 25.4M    0     0  1248k      0  0:00:20  0:00:20 --:--:-- 1157k
    ==> Done.
    
    Pull Hyperledger Fabric docker images
    
    FABRIC_IMAGES: peer orderer ccenv tools baseos
    ===> Pulling fabric Images
    ====> hyperledger/fabric-peer:2.4.2
    2.4.2: Pulling from hyperledger/fabric-peer
    97518928ae5f: Pull complete
    42bd03df3e1a: Pull complete
    3182c3c96871: Pull complete
    44ae96fc98a2: Pull complete
    2b2d34b5ab5c: Pull complete
    eff95e52b961: Pull complete
    650bde1fc3f7: Pull complete
    Digest: sha256:5eaad9fd093fdfb449310ae851912ab2cf6cd5b634380497404b9cb8bf91dcd2
    Status: Downloaded newer image for hyperledger/fabric-peer:2.4.2
    docker.io/hyperledger/fabric-peer:2.4.2
    ====> hyperledger/fabric-orderer:2.4.2
    2.4.2: Pulling from hyperledger/fabric-orderer
    97518928ae5f: Already exists
    42bd03df3e1a: Already exists
    a565d10714cf: Pull complete
    cf01ceab4d02: Pull complete
    641b37dc6c30: Pull complete
    a4f70ee0bbbe: Pull complete
    3a78beab9d5d: Pull complete
    Digest: sha256:fc9fbf6d8c88ef7cff09835c5bf978388897a191ed9c9cf1ba33bc131a50799b
    Status: Downloaded newer image for hyperledger/fabric-orderer:2.4.2
    docker.io/hyperledger/fabric-orderer:2.4.2
    ====> hyperledger/fabric-ccenv:2.4.2
    2.4.2: Pulling from hyperledger/fabric-ccenv
    97518928ae5f: Already exists
    b78c28b3bbf7: Pull complete
    248309d37e25: Pull complete
    8f893ed93684: Pull complete
    60b34f272e36: Pull complete
    bde889820d2b: Pull complete
    759d90edbc0f: Pull complete
    81a0619aeb06: Pull complete
    fc7be8cce065: Pull complete
    Digest: sha256:bd2fa8d04b7bb74f422c34b03cfce62750fc7d99f78410c6f4dd7ce4eaf5f594
    Status: Downloaded newer image for hyperledger/fabric-ccenv:2.4.2
    docker.io/hyperledger/fabric-ccenv:2.4.2
    ====> hyperledger/fabric-tools:2.4.2
    2.4.2: Pulling from hyperledger/fabric-tools
    97518928ae5f: Already exists
    b78c28b3bbf7: Already exists
    248309d37e25: Already exists
    8f893ed93684: Already exists
    60b34f272e36: Already exists
    fb1c258a462f: Pull complete
    cddf115ada33: Pull complete
    24ea6585952d: Pull complete
    Digest: sha256:c3c4cdf3c73877c9d3dba1fcbbd59e152ecd23876a1ccb9f9bc9c4bed69824e7
    Status: Downloaded newer image for hyperledger/fabric-tools:2.4.2
    docker.io/hyperledger/fabric-tools:2.4.2
    ====> hyperledger/fabric-baseos:2.4.2
    2.4.2: Pulling from hyperledger/fabric-baseos
    97518928ae5f: Already exists
    42bd03df3e1a: Already exists
    368f3bf0ffdc: Pull complete
    Digest: sha256:bdf4646cc0e98ab4cfab4a8cb109ebba5424ae5c84c799d5ec0f5eb7ae2ae2ca
    Status: Downloaded newer image for hyperledger/fabric-baseos:2.4.2
    docker.io/hyperledger/fabric-baseos:2.4.2
    ===> Pulling fabric ca Image
    ====> hyperledger/fabric-ca:1.5.2
    1.5.2: Pulling from hyperledger/fabric-ca
    a0d0a0d46f8b: Pull complete
    ac8258c0aeb1: Pull complete
    6c802cf1fa97: Pull complete
    Digest: sha256:faa3b743d9ed391c30f518a7cc1168160bf335f3bf60ba6aaaf1aa49c1ed023e
    Status: Downloaded newer image for hyperledger/fabric-ca:1.5.2
    docker.io/hyperledger/fabric-ca:1.5.2
    ===> List out hyperledger docker images
    hyperledger/fabric-tools     2.4       eb40f70b1174   8 weeks ago    473MB
    hyperledger/fabric-tools     2.4.2     eb40f70b1174   8 weeks ago    473MB
    hyperledger/fabric-tools     latest    eb40f70b1174   8 weeks ago    473MB
    hyperledger/fabric-peer      2.4       43b970f84604   8 weeks ago    62.3MB
    hyperledger/fabric-peer      2.4.2     43b970f84604   8 weeks ago    62.3MB
    hyperledger/fabric-peer      latest    43b970f84604   8 weeks ago    62.3MB
    hyperledger/fabric-orderer   2.4       5edf6bdb4489   8 weeks ago    37.3MB
    hyperledger/fabric-orderer   2.4.2     5edf6bdb4489   8 weeks ago    37.3MB
    hyperledger/fabric-orderer   latest    5edf6bdb4489   8 weeks ago    37.3MB
    hyperledger/fabric-ccenv     2.4       e377a02242aa   8 weeks ago    517MB
    hyperledger/fabric-ccenv     2.4.2     e377a02242aa   8 weeks ago    517MB
    hyperledger/fabric-ccenv     latest    e377a02242aa   8 weeks ago    517MB
    hyperledger/fabric-baseos    2.4       4cfe0148d657   8 weeks ago    6.94MB
    hyperledger/fabric-baseos    2.4.2     4cfe0148d657   8 weeks ago    6.94MB
    hyperledger/fabric-baseos    latest    4cfe0148d657   8 weeks ago    6.94MB
    hyperledger/fabric-ca        1.5       4ea287b75c63   6 months ago   69.8MB
    hyperledger/fabric-ca        1.5.2     4ea287b75c63   6 months ago   69.8MB
    hyperledger/fabric-ca        latest    4ea287b75c63   6 months ago   69.8MB
    hannu@HannusLaptop:/mnt/c/Hyperledger$
    


    세 번째 단계 - 테스트 네트워크 시작



    이제 "fabric-samples/test-network"폴더로 이동합니다. 여기에는 "network.sh"라는 쉘 스크립트가 포함되어 있습니다. 샘플만 설치하고 바이너리는 설치하지 않은 경우에도 스크립트가 있을 것입니다. 하지만 Test-Network를 불러올 수는 없습니다.

    "./network.sh"를 실행하면 옵션에 대한 개요가 제공됩니다.

    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$ ./network.sh
    Using docker and docker-compose
    Usage:
      network.sh <Mode> [Flags]
        Modes:
          up - Bring up Fabric orderer and peer nodes. No channel is created
          up createChannel - Bring up fabric network with one channel
          createChannel - Create and join a channel after the network is created
          deployCC - Deploy a chaincode to a channel (defaults to asset-transfer-basic)
          down - Bring down the network
    
        Flags:
        Used with network.sh up, network.sh createChannel:
        -ca <use CAs> -  Use Certificate Authorities to generate network crypto material
        -c <channel name> - Name of channel to create (defaults to "mychannel")
        -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb
        -r <max retry> - CLI times out after certain number of attempts (defaults to 5)
        -d <delay> - CLI delays for a certain number of seconds (defaults to 3)
        -verbose - Verbose mode
    
        Used with network.sh deployCC
        -c <channel name> - Name of channel to deploy chaincode to
        -ccn <name> - Chaincode name.
        -ccl <language> - Programming language of the chaincode to deploy: go, java, javascript, typescript
        -ccv <version>  - Chaincode version. 1.0 (default), v2, version3.x, etc
        -ccs <sequence>  - Chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc
        -ccp <path>  - File path to the chaincode.
        -ccep <policy>  - (Optional) Chaincode endorsement policy using signature policy syntax. The default policy requires an endorsement from Org1 and Org2
        -cccg <collection-config>  - (Optional) File path to private data collections configuration file
        -cci <fcn name>  - (Optional) Name of chaincode initialization function. When a function is provided, the execution of init will be requested and the function will be invoked.
    
        -h - Print this message
    
     Possible Mode and flag combinations
       up -ca -r -d -s -verbose
       up createChannel -ca -c -r -d -s -verbose
       createChannel -c -r -d -verbose
       deployCC -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose
    
     Examples:
       network.sh up createChannel -ca -c mychannel -s couchdb
       network.sh createChannel -c channelName
       network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
       network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript
    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$
    


    이제 "/network.sh up"을 실행하여 테스트 네트워크를 시작합니다.

    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$ ./network.sh up
    Using docker and docker-compose
    Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
    LOCAL_VERSION=2.4.2
    DOCKER_IMAGE_VERSION=2.4.2
    /mnt/c/Hyperledger/fabric-samples/test-network/../bin/cryptogen
    Generating certificates using cryptogen tool
    Creating Org1 Identities
    + cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
    org1.example.com
    + res=0
    Creating Org2 Identities
    + cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
    org2.example.com
    + res=0
    Creating Orderer Org Identities
    + cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
    + res=0
    Generating CCP files for Org1 and Org2
    [+] Running 8/8
     ⠿ Network fabric_test                      Created                                                                0.7s
     ⠿ Volume "compose_orderer.example.com"     Created                                                                0.0s
     ⠿ Volume "compose_peer0.org1.example.com"  Created                                                                0.0s
     ⠿ Volume "compose_peer0.org2.example.com"  Created                                                                0.0s
     ⠿ Container peer0.org2.example.com         Started                                                                4.0s
     ⠿ Container orderer.example.com            Started                                                                4.0s
     ⠿ Container peer0.org1.example.com         Started                                                                4.3s
     ⠿ Container cli                            Started                                                                4.3s
    CONTAINER ID   IMAGE                               COMMAND             CREATED             STATUS                         PORTS                                                                    NAMES
    463eaff80abc   hyperledger/fabric-tools:latest     "/bin/bash"         4 seconds ago       Up Less than a second                                                                                   cli
    de452296018a   hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 1 second                    0.0.0.0:9051->9051/tcp, 7051/tcp, 0.0.0.0:9445->9445/tcp                 peer0.org2.example.com
    2bd8b0ccc851   hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 1 second                    0.0.0.0:7051->7051/tcp, 0.0.0.0:9444->9444/tcp                           peer0.org1.example.com
    32c1d1de81c9   hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up 1 second                    0.0.0.0:7050->7050/tcp, 0.0.0.0:7053->7053/tcp, 0.0.0.0:9443->9443/tcp   orderer.example.com
    8aed63f3c3b0   hello-world                         "/hello"            About an hour ago   Exited (0) About an hour ago                                                                            nervous_bose
    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$
    


    Docker Desktop을 간단히 살펴보면 Hyperledger Fabric Test Network가 가동되고 있음을 알 수 있습니다! 놀라운!



    네 번째 단계 - 테스트 네트워크 중지



    이제 "./network.sh down"을 실행하여 네트워크를 다시 다운시키자.

    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$ ./network.sh down
    Using docker and docker-compose
    Stopping network
    [+] Running 9/9
     ⠿ Container orderer.example.com          Removed                                                                  1.9s
     ⠿ Container cli                          Removed                                                                 11.3s
     ⠿ Container peer0.org2.example.com       Removed                                                                  1.1s
     ⠿ Container peer0.org1.example.com       Removed                                                                  0.7s
     ⠿ Volume compose_peer0.org1.example.com  Removed                                                                  0.0s
     ⠿ Volume compose_peer0.org3.example.com  Removed                                                                  0.0s
     ⠿ Network fabric_test                    Removed                                                                  0.5s
     ⠿ Volume compose_peer0.org2.example.com  Removed                                                                  0.0s
     ⠿ Volume compose_orderer.example.com     Removed                                                                  0.0s
    Error: No such volume: docker_orderer.example.com
    Error: No such volume: docker_peer0.org1.example.com
    Error: No such volume: docker_peer0.org2.example.com
    Removing remaining containers
    Removing generated chaincode docker images
    "docker kill" requires at least 1 argument.
    See 'docker kill --help'.
    
    Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]
    
    Kill one or more running containers
    Unable to find image 'busybox:latest' locally
    /usr/bin/docker-credential-desktop.exe: Invalid argument
    latest: Pulling from library/busybox
    554879bb3004: Pull complete
    Digest: sha256:caa382c432891547782ce7140fb3b7304613d3b0438834dce1cad68896ab110a
    Status: Downloaded newer image for busybox:latest
    hannu@HannusLaptop:/mnt/c/Hyperledger/fabric-samples/test-network$
    


    위의 출력을 확인하면 네트워크를 중단하는 동안 몇 가지 오류가 발생했습니다. 그러나 Docker에서 이미지가 더 이상 "사용 중"이 아님을 알 수 있습니다.



    결론



    놀라운. 우리는 Windows 11에서 Hyperledger Fabric Test Network를 성공적으로 실행하고 전제 조건을 설치했습니다. (이전에는 이 노트북에 설치한 것이 JDK와 Git뿐이었습니다.) 다음에는 채널을 만들고 체인코드를 배포하겠습니다!

    좋은 웹페이지 즐겨찾기