hyperledger fabric explorer 超級(jí)賬本區(qū)塊鏈瀏覽器搭建-使用docker的方式快速搭建一個(gè)超級(jí)賬本區(qū)塊鏈瀏覽器
-
區(qū)塊鏈瀏覽器可以讓用戶更加直觀地查看當(dāng)前超級(jí)賬本網(wǎng)絡(luò)的情況,來觀察整個(gè)區(qū)塊鏈上的塊數(shù),節(jié)點(diǎn)數(shù),通道,鏈碼等;
-
官方推薦的搭建區(qū)塊鏈瀏覽器有兩種方法,一種是docker的方式,一種是用代碼在自己本地的方式搭建,這里我們選擇docker的方式搭建;
官方的github項(xiàng)目地址:
https://github.com/hyperledger/blockchain-explorer
Quick start (using Docker)
1、配置文件
# 新建文件夾,用于存放區(qū)塊鏈瀏覽器搭建過程中的配置文件
mkdir explorer
cd explorer
# wget配置文件,由于被墻,可能無法直接獲取
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
# 解決方法,手動(dòng)創(chuàng)建配置文件,并通過訪問下面網(wǎng)址,將配置文件內(nèi)容復(fù)制進(jìn)去
2、將區(qū)塊鏈網(wǎng)絡(luò)的證書文件整個(gè)目錄復(fù)制到 explorer下,并重命名為organizations:
cd /root/block/geneg/twonodes/
cp -r crypto-config ../explorer/organizations
3、配置文件存放目錄結(jié)構(gòu)如下:
# 因?yàn)槲覀冇袃蓚€(gè)peer節(jié)點(diǎn),org1和org2
explorer
|___docker-compose.yaml
|___config.json
|___connection-profile
|___org1-network.json
|___org2-network.json
root@aa:~/block/geneg# cd /root/block/geneg/
root@aa:~/block/geneg# pwd
/root/block/geneg
root@aa:~/block/geneg# ls
twonodes
root@aa:~/block/geneg# mkdir explorer
root@aa:~/block/geneg# ls
explorer twonodes
root@aa:~/block/geneg# cd explorer
root@aa:~/block/geneg/explorer# mkdir connection-profile
root@aa:~/block/geneg/explorer# ls
connection-profile
(1)新文件:docker-compose.yaml,內(nèi)容如下
? https://github.com/hyperledger/blockchain-explorer/blob/main/docker-compose.yaml
networks:
mynetwork.com:
external:
name: fabric_test # 這個(gè)地方要改成自己的網(wǎng)絡(luò)名稱
# 修改成自己的文件掛載路徑
volumes:
- ${EXPLORER_CONFIG_FILE_PATH}:/opt/explorer/app/platform/fabric/config.json
- ${EXPLORER_PROFILE_DIR_PATH}:/opt/explorer/app/platform/fabric/connection-profile
- ${FABRIC_CRYPTO_PATH}:/tmp/crypto
- walletstore:/opt/explorer/wallet # 后面又提到,先往后找一找
# SPDX-License-Identifier: Apache-2.0
version: '2.1'
volumes:
pgdata:
walletstore:
networks:
mynetwork.com:
external:
name: twonodes_test
services:
explorerdb.mynetwork.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.mynetwork.com
hostname: explorerdb.mynetwork.com
environment:
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWORD=password
healthcheck:
test: "pg_isready -h localhost -p 5432 -q -U postgres"
interval: 30s
timeout: 10s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- mynetwork.com
explorer.mynetwork.com:
image: hyperledger/explorer:latest
container_name: explorer.mynetwork.com
hostname: explorer.mynetwork.com
environment:
- DATABASE_HOST=explorerdb.mynetwork.com
- DATABASE_DATABASE=fabricexplorer
- DATABASE_USERNAME=hppoc
- DATABASE_PASSWD=password
- LOG_LEVEL_APP=info
- LOG_LEVEL_DB=info
- LOG_LEVEL_CONSOLE=debug
- LOG_CONSOLE_STDOUT=true
- DISCOVERY_AS_LOCALHOST=false
volumes:
- ./config.json:/opt/explorer/app/platform/fabric/config.json
- ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- ./organizations:/tmp/crypto
- walletstore:/opt/explorer/wallet
ports:
- 8080:8080
depends_on:
explorerdb.mynetwork.com:
condition: service_healthy
networks:
- mynetwork.com
(2)新文件:org1-network.json,內(nèi)容如下
? https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/connection-profile/test-network.json
“name”: “test-network”, 這一項(xiàng)可以自定義,但是在 config.json加載配置文件路徑項(xiàng)
“profile”: “./connection-profile/test-network.json” 要對(duì)應(yīng)上
{
"name": "org1-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org1.example.com:7051"
}
}
}
# 這里的id和password為一會(huì)登錄的賬號(hào)和密碼
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
}
(3)新文件:org2-network.json,內(nèi)容如下
{
"name": "org2-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "org2MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org2.example.com": {}
}
}
},
"organizations": {
"org2MSP": {
"mspid": "org2MSP",
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk"
},
"peers": ["peer0.org2.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org2.example.com": {
"tlsCACerts": {
"path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org2.example.com:7051"
}
}
}
(4)新文件:config.json,內(nèi)容如下
https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/config.json
{
"network-configs": {
"org1-network": {
"name": "org1-network",
"profile": "./connection-profile/org1-network.json"
},
"org2-network": {
"name": "org2-network",
"profile": "./connection-profile/org2-network.json"
}
},
"license": "Apache-2.0"
}
4、docker-compose 跑起服務(wù)文章來源:http://www.zghlxwxcb.cn/news/detail-401440.html
root@kai:~/block/geneg# cd explorer
root@kai:~/block/geneg/explorer# pwd
/root/block/geneg/explorer
root@kai:~/block/geneg/explorer# ls
config.json connection-profile docker-compose.yaml organizations
root@kai:~/block/geneg/explorer# docker-compose up -d
Recreating explorerdb.mynetwork.com ... done
Creating explorer.mynetwork.com ... done
root@kai:~/block/geneg/explorer# docker ps -a
hyperledger/explorer:latest
hyperledger/explorer-db:latest
5、瀏覽器上訪問:文章來源地址http://www.zghlxwxcb.cn/news/detail-401440.html
云主機(jī)ip:8080
賬號(hào) "exploreradmin",
密碼 "exploreradminpw"
到了這里,關(guān)于hyperledger fabric explorer 超級(jí)賬本區(qū)塊鏈瀏覽器搭建-docker的方式的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!