首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将Hyperledger锯齿验证器连接到远程计算机上的验证器

将Hyperledger锯齿验证器连接到远程计算机上的验证器
EN

Stack Overflow用户
提问于 2019-10-15 16:22:23
回答 1查看 302关注 0票数 0

我正在尝试配置一个带有5个验证器的锯齿网络。其中一个在远程机器上。但是这个验证器不能连接到网络。我在Linux上使用Docker。

我使用的是this锯齿图示例的代码。

第一个yaml。4个验证器文件:

代码语言:javascript
复制
version: '3.6'

volumes:
  pbft-shared:

services:

# -------------=== intkey tp ===-------------

  intkey-tp-0:
    image: hyperledger/sawtooth-intkey-tp-python:chime
    container_name: sawtooth-intkey-tp-python-default-0
    expose:
      - 4004
    command: intkey-tp-python -C tcp://validator-0:4004
    stop_signal: SIGKILL

  intkey-tp-1:
    image: hyperledger/sawtooth-intkey-tp-python:chime
    container_name: sawtooth-intkey-tp-python-default-1
    expose:
      - 4004
    command: intkey-tp-python -C tcp://validator-1:4004
    stop_signal: SIGKILL

  intkey-tp-2:
    image: hyperledger/sawtooth-intkey-tp-python:chime
    container_name: sawtooth-intkey-tp-python-default-2
    expose:
      - 4004
    command: intkey-tp-python -C tcp://validator-2:4004
    stop_signal: SIGKILL

  intkey-tp-3:
    image: hyperledger/sawtooth-intkey-tp-python:chime
    container_name: sawtooth-intkey-tp-python-default-3
    expose:
      - 4004
    command: intkey-tp-python -C tcp://validator-3:4004
    stop_signal: SIGKILL

# -------------=== rest api ===-------------

  rest-api-0:
    image: hyperledger/sawtooth-rest-api:chime
    container_name: sawtooth-rest-api-default-0
    expose:
      - 8008
    command: |
      bash -c "
        sawtooth-rest-api \
          --connect tcp://validator-0:4004 \
          --bind rest-api-0:8008
      "
    stop_signal: SIGKILL

  rest-api-1:
    image: hyperledger/sawtooth-rest-api:chime
    container_name: sawtooth-rest-api-default-1
    expose:
      - 8008
    command: |
      bash -c "
        sawtooth-rest-api \
          --connect tcp://validator-1:4004 \
          --bind rest-api-1:8008
      "
    stop_signal: SIGKILL

  rest-api-2:
    image: hyperledger/sawtooth-rest-api:chime
    container_name: sawtooth-rest-api-default-2
    expose:
      - 8008
    command: |
      bash -c "
        sawtooth-rest-api \
          --connect tcp://validator-2:4004 \
          --bind rest-api-2:8008
      "
    stop_signal: SIGKILL

  rest-api-3:
    image: hyperledger/sawtooth-rest-api:chime
    container_name: sawtooth-rest-api-default-3
    expose:
      - 8008
    command: |
      bash -c "
        sawtooth-rest-api \
          --connect tcp://validator-3:4004 \
          --bind rest-api-3:8008
      "
    stop_signal: SIGKILL

# -------------=== settings tp ===-------------

  settings-tp-0:
    image: hyperledger/sawtooth-settings-tp:chime
    container_name: sawtooth-settings-tp-default-0
    expose:
      - 4004
    command: settings-tp -C tcp://validator-0:4004
    stop_signal: SIGKILL

  settings-tp-1:
    image: hyperledger/sawtooth-settings-tp:chime
    container_name: sawtooth-settings-tp-default-1
    expose:
      - 4004
    command: settings-tp -C tcp://validator-1:4004
    stop_signal: SIGKILL

  settings-tp-2:
    image: hyperledger/sawtooth-settings-tp:chime
    container_name: sawtooth-settings-tp-default-2
    expose:
      - 4004
    command: settings-tp -C tcp://validator-2:4004
    stop_signal: SIGKILL

  settings-tp-3:
    image: hyperledger/sawtooth-settings-tp:chime
    container_name: sawtooth-settings-tp-default-3
    expose:
      - 4004
    command: settings-tp -C tcp://validator-3:4004
    stop_signal: SIGKILL

# -------------=== shell ===-------------

  shell:
    image: hyperledger/sawtooth-shell:chime
    container_name: sawtooth-shell-default
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        sawtooth keygen
        tail -f /dev/null
      "
    stop_signal: SIGKILL

# -------------=== validators ===-------------

  validator-0:
    image: hyperledger/sawtooth-validator:chime
    container_name: sawtooth-validator-default-0
    expose:
      - 4004
      - 5050
      - 8800
    ports:
      - '8900:8800'
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        if [ -e /pbft-shared/validators/validator-0.priv ]; then
          cp /pbft-shared/validators/validator-0.pub /etc/sawtooth/keys/validator.pub
          cp /pbft-shared/validators/validator-0.priv /etc/sawtooth/keys/validator.priv
        fi &&
        if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          mkdir -p /pbft-shared/validators || true
          cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-0.pub
          cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-0.priv
        fi &&
        if [ ! -e config-genesis.batch ]; then
          sawset genesis -k /etc/sawtooth/keys/validator.priv -o config-genesis.batch
        fi &&
        while [[ ! -f /pbft-shared/validators/validator-1.pub || \
                 ! -f /pbft-shared/validators/validator-2.pub || \
                 ! -f /pbft-shared/validators/validator-3.pub || \
                 ! -f /pbft-shared/validators/validator-4.pub ]];
        do sleep 1; done
        echo sawtooth.consensus.pbft.members=\\['\"'$$(cat /pbft-shared/validators/validator-0.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-1.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-2.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-3.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-4.pub)'\"'\\] &&
        if [ ! -e config.batch ]; then
         sawset proposal create \
            -k /etc/sawtooth/keys/validator.priv \
            sawtooth.consensus.algorithm.name=pbft \
            sawtooth.consensus.algorithm.version=1.0 \
            sawtooth.consensus.pbft.members=\\['\"'$$(cat /pbft-shared/validators/validator-0.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-1.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-2.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-3.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-4.pub)'\"'\\] \
            sawtooth.publisher.max_batches_per_block=1200 \
            -o config.batch
        fi &&
        if [ ! -e /var/lib/sawtooth/genesis.batch ]; then
          sawadm genesis config-genesis.batch config.batch
        fi &&
        if [ ! -e /root/.sawtooth/keys/my_key.priv ]; then
          sawtooth keygen my_key
        fi &&
        sawtooth-validator -vv \
          --endpoint tcp://validator-0:8800 \
          --bind component:tcp://eth0:4004 \
          --bind consensus:tcp://eth0:5050 \
          --bind network:tcp://eth0:8800 \
          --scheduler parallel \
          --peering static \
          --maximum-peer-connectivity 10000 \
          --network-auth trust
      "

  validator-1:
    image: hyperledger/sawtooth-validator:chime
    container_name: sawtooth-validator-default-1
    expose:
      - 4004
      - 5050
      - 8800
    ports:
      - '8901:8800'
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        if [ -e /pbft-shared/validators/validator-1.priv ]; then
          cp /pbft-shared/validators/validator-1.pub /etc/sawtooth/keys/validator.pub
          cp /pbft-shared/validators/validator-1.priv /etc/sawtooth/keys/validator.priv
        fi &&
        if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          mkdir -p /pbft-shared/validators || true
          cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-1.pub
          cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-1.priv
        fi &&
        sawtooth keygen my_key &&
        sawtooth-validator -vv \
          --endpoint tcp://validator-1:8800 \
          --bind component:tcp://eth0:4004 \
          --bind consensus:tcp://eth0:5050 \
          --bind network:tcp://eth0:8800 \
          --scheduler parallel \
          --peering static \
          --maximum-peer-connectivity 10000 \
          --network-auth trust \
          --peers tcp://validator-0:8800
      "

  validator-2:
    image: hyperledger/sawtooth-validator:chime
    container_name: sawtooth-validator-default-2
    expose:
      - 4004
      - 5050
      - 8800
    ports:
      - '8902:8800'
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        if [ -e /pbft-shared/validators/validator-2.priv ]; then
          cp /pbft-shared/validators/validator-2.pub /etc/sawtooth/keys/validator.pub
          cp /pbft-shared/validators/validator-2.priv /etc/sawtooth/keys/validator.priv
        fi &&
        if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          mkdir -p /pbft-shared/validators || true
          cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-2.pub
          cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-2.priv
        fi &&
        sawtooth keygen my_key &&
        sawtooth-validator -vv \
          --endpoint tcp://validator-2:8800 \
          --bind component:tcp://eth0:4004 \
          --bind consensus:tcp://eth0:5050 \
          --bind network:tcp://eth0:8800 \
          --scheduler parallel \
          --peering static \
          --maximum-peer-connectivity 10000 \
          --network-auth trust \
          --peers tcp://validator-0:8800 \
          --peers tcp://validator-1:8800
      "

  validator-3:
    image: hyperledger/sawtooth-validator:chime
    container_name: sawtooth-validator-default-3
    expose:
      - 4004
      - 5050
      - 8800
    ports:
      - '8903:8800'
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        if [ -e /pbft-shared/validators/validator-3.priv ]; then
         cp /pbft-shared/validators/validator-3.pub /etc/sawtooth/keys/validator.pub
         cp /pbft-shared/validators/validator-3.priv /etc/sawtooth/keys/validator.priv
        fi &&
        if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
         sawadm keygen
         mkdir -p /pbft-shared/validators || true
         cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-3.pub
         cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-3.priv
        fi &&
        sawtooth keygen my_key &&
        sawtooth-validator -vv \
          --endpoint tcp://validator-3:8800 \
          --bind component:tcp://eth0:4004 \
          --bind consensus:tcp://eth0:5050 \
          --bind network:tcp://eth0:8800 \
          --scheduler parallel \
          --peering static \
          --maximum-peer-connectivity 10000 \
          --network-auth trust \
          --peers tcp://validator-0:8800 \
          --peers tcp://validator-1:8800 \
          --peers tcp://validator-2:8800
      "

# -------------=== pbft engines ===-------------

  pbft-0:
    image: hyperledger/sawtooth-pbft-engine:chime
    container_name: sawtooth-pbft-engine-default-0
    command: pbft-engine -vv --connect tcp://validator-0:5050
    stop_signal: SIGKILL

  pbft-1:
    image: hyperledger/sawtooth-pbft-engine:chime
    container_name: sawtooth-pbft-engine-default-1
    command: pbft-engine -vv --connect tcp://validator-1:5050
    stop_signal: SIGKILL

  pbft-2:
    image: hyperledger/sawtooth-pbft-engine:chime
    container_name: sawtooth-pbft-engine-default-2
    command: pbft-engine -vv --connect tcp://validator-2:5050
    stop_signal: SIGKILL

  pbft-3:
    image: hyperledger/sawtooth-pbft-engine:chime
    container_name: sawtooth-pbft-engine-default-3
    command: pbft-engine -vv --connect tcp://validator-3:5050
    stop_signal: SIGKILL

# -------------=== xo tps ===-------------

  xo-tp-0:
    image: hyperledger/sawtooth-xo-tp-python:chime
    container_name: sawtooth-xo-tp-python-default-0
    expose:
      - 4004
    command: xo-tp-python -vv -C tcp://validator-0:4004
    stop_signal: SIGKILL

  xo-tp-1:
    image: hyperledger/sawtooth-xo-tp-python:chime
    container_name: sawtooth-xo-tp-python-default-1
    expose:
      - 4004
    command: xo-tp-python -vv -C tcp://validator-1:4004
    stop_signal: SIGKILL

  xo-tp-2:
    image: hyperledger/sawtooth-xo-tp-python:chime
    container_name: sawtooth-xo-tp-python-default-2
    expose:
      - 4004
    command: xo-tp-python -vv -C tcp://validator-2:4004
    stop_signal: SIGKILL

  xo-tp-3:
    image: hyperledger/sawtooth-xo-tp-python:chime
    container_name: sawtooth-xo-tp-python-default-3
    expose:
      - 4004
    command: xo-tp-python -vv -C tcp://validator-3:4004
    stop_signal: SIGKILL

第二个yaml。最后一个验证器的文件:

代码语言:javascript
复制
version: '3.6'

volumes:
  pbft-shared:

services:

# -------------=== intkey tp ===-------------

  intkey-tp-4:
    image: hyperledger/sawtooth-intkey-tp-python:nightly
    container_name: sawtooth-intkey-tp-python-default-4
    expose:
      - 4004
    command: intkey-tp-python -C tcp://validator-4:4004
    stop_signal: SIGKILL

# -------------=== rest api ===-------------

  rest-api-4:
    image: hyperledger/sawtooth-rest-api:nightly
    container_name: sawtooth-rest-api-default-4
    expose:
      - 8008
    command: |
      bash -c "
        sawtooth-rest-api \
          --connect tcp://validator-4:4004 \
          --bind rest-api-4:8008
      "
    stop_signal: SIGKILL

# -------------=== settings tp ===-------------

  settings-tp-4:
    image: hyperledger/sawtooth-settings-tp:nightly
    container_name: sawtooth-settings-tp-default-4
    expose:
      - 4004
    command: settings-tp -C tcp://validator-4:4004
    stop_signal: SIGKILL

# -------------=== shell ===-------------

  shell:
    image: hyperledger/sawtooth-shell:nightly
    container_name: sawtooth-shell-default
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        sawtooth keygen
        tail -f /dev/null
      "
    stop_signal: SIGKILL

# -------------=== validators ===-------------

  validator-4:
    image: hyperledger/sawtooth-validator:nightly
    container_name: sawtooth-validator-default-4    
    expose:
      - 4004
      - 5050
      - 8800
    ports:
      - '8904:8800'
    volumes:
      - pbft-shared:/pbft-shared
    command: |
      bash -c "
        if [ -e /pbft-shared/validators/validator-4.priv ]; then
          cp /pbft-shared/validators/validator-4.pub /etc/sawtooth/keys/validator.pub
          cp /pbft-shared/validators/validator-4.priv /etc/sawtooth/keys/validator.priv
        fi &&
        if [ ! -e /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          mkdir -p /pbft-shared/validators || true
          cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-4.pub
          cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-4.priv
        fi &&
        sawtooth keygen my_key &&
        sawtooth-validator -vv \
          --endpoint tcp://validator-4:8800 \
          --bind component:tcp://eth0:4004 \
          --bind consensus:tcp://eth0:5050 \
          --bind network:tcp://eth0:8800 \
          --scheduler parallel \
          --peering static \
          --maximum-peer-connectivity 10000 \
          --network-auth trust \
          --peers tcp://192.168.69.175:8900 \
          --peers tcp://192.168.69.175:8901 \
          --peers tcp://192.168.69.175:8902 \
          --peers tcp://192.168.69.175:8903
      "

# -------------=== pbft engines ===-------------

  pbft-4:
    image: hyperledger/sawtooth-pbft-engine:nightly
    container_name: sawtooth-pbft-engine-default-4
    command: pbft-engine -vv --connect tcp://validator-4:5050
    stop_signal: SIGKILL

# -------------=== xo tps ===-------------

  xo-tp-4:
    image: hyperledger/sawtooth-xo-tp-python:nightly
    container_name: sawtooth-xo-tp-python-default-4
    expose:
      - 4004
    command: xo-tp-python -vv -C tcp://validator-4:4004
    stop_signal: SIGKILL

最后一个验证器收到这样的消息:"No response from OutboundConnectionThread... seconds removing connection“。

EN

回答 1

Stack Overflow用户

发布于 2019-10-17 05:01:19

除了具有联网功能(尝试ping)外,还需要在两端打开TCP端口8080。

如果您有多个Docker容器,请参阅Docker网络文档了解如何设置网络。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58390253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档