Hyperledger Fabric Explorer 安裝配置

所需依賴以及安裝

  • Nodejs 8.11.x (Note that v9.x is not yet supported)
  • PostgreSQL 9.5 or greater
  • jq
  • docker-ce
  • docker-compose
  • git
    在上一篇的《Hyperledger Fabric 多機部署》已經部署好了 Fabric 網絡,這裏用 CLI 那臺機器來部署 Hyperledger Explorer,因此有些依賴已經安裝好了。

安裝 PostgreSQL

sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
##修改密碼
sudo -u postgres
psql -c "ALTER USER postgres PASSWORD 'postgres';"

安裝 jq

apt-get install jq
jq --version

代碼配置

Clone 項目代碼

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

配置數據庫

修改 app/explorerconfig.jsongit

{
    "persistence": "postgreSQL",
    "platforms": ["fabric"],
    "postgreSQL": {
        "host": "127.0.0.1",
        "port": "5432",
        "database": "fabricexplorer",
        "username": "postgres",
        "passwd": "postgres"
    }
}

給 db 目錄設置權限github

chmod -R 775 app/persistence/fabric/postgreSQL/db

執行數據庫腳本sql

cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
su - postgres
./createdb.sh

配置 fabric 網絡

這裏的配置基於咱們上一篇搭建的 fabric 網絡,進入blockchain-explorer/app/platform/fabric目錄作響應的修改
config.json:docker

{
    "name": "fabric-network",
    "version": "1.0.0",
    "client": {
        "tlsEnable": true,
        "adminUser": "admin",
        "adminPassword": "adminpw",
        "enableAuthentication": false,
        "organization": "Org1MSP",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "mychannel": {
            "peers": {
                "peer0.org1.example.com": {},
                "peer0.org2.example.com": {},
                "orderer.example.com": {}
            },
            "connection": {
                "timeout": {
                    "peer": {
                        "endorser": "6000",
                        "eventHub": "6000",
                        "eventReg": "6000"
                    }
                }
            }
        }
    },
    "organizations": {
        "Org1MSP": {
            "mspid": "Org1MSP",
            "fullpath": true,
            "adminPrivateKey": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/b04f0b81d66a714cb3fcf17206376eaa59dee8853e1cb1b501dca71e63d40fef_sk"
            },
            "signedCert": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
            }
        },
        "Org2MSP": {
            "mspid": "Org2MSP",
            "fullpath": true,
            "adminPrivateKey": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/b1ad20e44fba3b5095119796acb4480eddb5331c4fc42f461f46f3dfcb2334f9_sk"
            },
            "signedCert": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
            }
        },
        "OrdererMSP": {
            "mspid": "OrdererMSP",
            "fullpath": true,
            "adminPrivateKey": {
                "path": "/root/fabric/fabric-network/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/2cf39d9293b690bcce3b427fde9590240a1f2a4734c05a7612e058ba5ff1de44_sk"
            },
            "signedCert": {
                "path": "/root/fabric/fabric-network/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
            }
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "tlsCACerts": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
            },
            "url": "grpc://192.168.11.12:7051",
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org1.example.com"
            }
        },
        "peer0.org2.example.com": {
            "tlsCACerts": {
                "path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
            },
            "url": "grpc://192.168.11.14:7051",
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org2.example.com"
            }
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc://localhost:7050"
        }
    }
}

打包編譯

apt-get install build-essential
cd blockchain-explorer
./main.sh install

啓動&中止

直接在項目目錄下執行啓動腳本:shell

./start.sh debug #開啓debug

經過加上 debug 參數能夠在日誌文件中查看啓動過程當中的錯誤,默認服務器啓動端口爲8080,經過瀏覽器能夠直接 ip+端口訪問數據庫

1576219758382

中止服務json

./stop.sh

到此一個能夠用於實際生產環境的多機 Hyperledger Fabric 區塊鏈網絡部署就完成了。瀏覽器

轉載請註明: 轉載自Ryan 是菜鳥 | LNMP 技術棧筆記服務器

若是以爲本篇文章對您十分有益,何不 打賞一下網絡

謝謝打賞

本文連接地址: Hyperledger Fabric Explorer 安裝配置

<img alt="知識共享許可協議" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/80x15.png" />
本做品採用知識共享署名-非商業性使用 4.0 國際許可協議進行許可

相關文章
相關標籤/搜索